1 개요[ | ]
- k8s configMap optional
yaml
Copy
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test
image: nginx
volumeMounts:
- name: vol
mountPath: /test/
volumes:
- name: vol
configMap:
name: not-exists
Console
Copy
$ kubectl apply -f a.yaml
pod/dapi-test-pod created
$ kubectl get pod dapi-test-pod
NAME READY STATUS RESTARTS AGE
dapi-test-pod 0/1 ContainerCreating 0 29s
$ kubectl describe pod dapi-test-pod | grep Events: -A9
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 73s default-scheduler Successfully assigned default/dapi-test-pod to node1
Warning FailedMount 9s (x8 over 73s) kubelet MountVolume.SetUp failed for volume "vol" : configmap "not-exists" not found
yaml
Copy
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test
image: nginx
volumeMounts:
- name: vol
mountPath: /test/
volumes:
- name: vol
configMap:
name: not-exists
optional: true
Console
Copy
$ kubectl delete -f a.yaml; kubectl apply -f a.yaml
pod "dapi-test-pod" deleted
pod/dapi-test-pod created
$ kubectl get pod dapi-test-pod
NAME READY STATUS RESTARTS AGE
dapi-test-pod 1/1 Running 0 9s
$ kubectl exec dapi-test-pod -it -- df | grep /test
/dev/sda1 36937420 18030912 18890124 49% /test
$ kubectl exec dapi-test-pod -it -- mount | grep /test
/dev/sda1 on /test type ext4 (ro,relatime,commit=30)
$ kubectl exec dapi-test-pod -it -- ls -alF /test
total 12
drwxrwxrwx 3 root root 4096 Jan 3 11:22 ./
drwxr-xr-x 1 root root 4096 Jan 3 11:22 ../
drwxr-xr-x 2 root root 4096 Jan 3 11:22 ..2022_01_03_11_22_44.308401016/
lrwxrwxrwx 1 root root 31 Jan 3 11:22 ..data -> ..2022_01_03_11_22_44.308401016/
$ kubectl exec dapi-test-pod -it -- ls -alF /test/..2022_01_03_11_22_44.308401016/
total 8
drwxr-xr-x 2 root root 4096 Jan 3 11:22 ./
drwxrwxrwx 3 root root 4096 Jan 3 11:22 ../
2 같이 보기[ | ]
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.