[k8s] storage of emptyDir

 

[4.1]
## emptyDir

mkdir /labfile/storagefile
cd /labfile/storagefile

vim empty-pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: em
spec:
  containers:
  - image: ubuntu
    name: test-container
    volumeMounts:
    - mountPath: /cache
      name: cache-volume
    args:
    - /bin/sh
    - -c
    - sleep 30000
  volumes:
  - name: cache-volume
    emptyDir: {}

kubectl apply -f empty-pod.yaml
kubectl exec em -it /bin/sh

cd /cache
cat > hello.file<<EOF
hello
world
EOF
exit

kubectl get pod -o wide
ssh cce01-node1-IP
crictl ps

crictl inspect container-id

cd host_path
ls
cat hello.file

exit
kubectl delete pod em

ssh cce01-node1-IP
cd /var/lib/kubelet/pods
ll

 

[4.2]
## emptyDir limit storage

vim limit-pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: em2
spec:
  containers:
  - image: ubuntu
    name: test-container2
    volumeMounts:
    - mountPath: /cache
      name: cache-volume
    args:
    - /bin/sh
    - -c
    - sleep 30000
  volumes:
  - name: cache-volume
    emptyDir:
      sizeLimit: 1Gi

kubectl apply
-f limit-pod.yaml kubectl exec -it em2 /bin/sh cd /cache dd if=/dev/zero of=/cache/test2g bs=1M count=2048 exit kubectl get pod STATUS show : Error

 

posted on 2025-04-12 10:17  天涯人  阅读(9)  评论(0)    收藏  举报

导航