k8s
Minikube host directory 마운트하기
바리새인
2024. 12. 31. 11:55
apiVersion: v1
kind: Pod
metadata:
name: host-mount-pod
spec:
containers:
- name: test-container
image: busybox
command: [ "sleep", "3600" ]
volumeMounts:
- mountPath: /data
name: host-volume
volumes:
- name: host-volume
hostPath:
path: /mnt/data
특정 그룹으로 마운트하기(작동안함)
apiVersion: v1
kind: Pod
metadata:
name: host-mount-pod
spec:
securityContext:
fsGroup: 2000 # Group ID of the specific account
containers:
- name: test-container
image: busybox
command: [ "sleep", "3600" ]
volumeMounts:
- mountPath: /data
name: host-volume
volumes:
- name: host-volume
hostPath:
path: /mnt/data
특정 사용자로 마운트하기(작동안함)
apiVersion: v1
kind: Pod
metadata:
name: host-mount-pod
spec:
securityContext:
runAsUser: 1000 # Replace with the user ID
containers:
- name: test-container
image: busybox
command: [ "sleep", "3600" ]
volumeMounts:
- mountPath: /data
name: host-volume
volumes:
- name: host-volume
hostPath:
path: /mnt/data
init Container를 사용해서 변경(작동함)
apiVersion: v1
kind: Pod
metadata:
name: host-mount-pod
spec:
initContainers:
- name: volume-permission-fix
image: busybox
command: ["sh", "-c", "chown -R 1000:1000 /data"]
volumeMounts:
- mountPath: /data
name: host-volume
containers:
- name: test-container
image: busybox
command: [ "sleep", "3600" ]
volumeMounts:
- mountPath: /data
name: host-volume
volumes:
- name: host-volume
hostPath:
path: /mnt/data