emptyDir 空目录
创建空目录的共享volume
kubectl run kong --image=busybox --dry-run=client -o yaml > kong.yaml
vi kong.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
run: kong
name: kong
spec:
containers:
- image: busybox
name: producer
volumeMounts:
- mountPath: /producer_dir
name: shared-volume
args:
- /bin/sh
- -c
- echo "xiebinzheshishabi " > /producer_dir/test.txt; sleep 33333333
- image: busybox
name: consumer
volumeMounts:
- mountPath: /consumer_dir
name: shared-volume
args:
- /bin/sh
- -c
- cat /consumer_dir/test.txt; sleep 33333333
volumes:
- name: shared-volume
emptyDir: {}
执行:
kubectl apply -f kong.yaml
查看:
kubectl get pod -o wide
kubectl describe pod kong
logs显示容器consumer内容:
kubectl logs kong consumer
pv和pvc
各个节点都要安装:
yum -y install rpcbind nfs-utils
在nfs上:
systemctl start rpcbind
systemctl enable rpcbind
systemctl start nfs-server
systemctl enable nfs-server
mkdir /nfsdata
cat > /etc/exports << EOF
/nfsdata *(rw,sync,no_root_squash)
EOF
systemctl restart nfs-server
在其他随便哪个节点测试
showmount -e 192.168.100.40