한 Pod 내에서 컨테이너 간 임시 디스크 공유를 위한 방식
kubectl apply -f -<<EOF
apiVersion: v1
kind: Pod
metadata:
name: shared-volumes
spec:
containers:
- image: redis
name: redis
volumeMounts:
- name: shared-storage
mountPath: /data/shared
- image: nginx
name: nginx
volumeMounts:
- name: shared-storage
mountPath: /data/shared
volumes:
- name: shared-storage
emptyDir: {}
EOF
kubectl exec -it shared-volumes --container redis -- /bin/bash
cd /data/shared
echo test… > test.txt
exit
kubectl exec -it shared-volumes --container nginx -- /bin/bash
cd /data/shared
ls

노드 로컬 디스크(/tmp 등)을 컨테이너 내부로 마운트하여 공유
kubectl apply -f -<<EOF
apiVersion: v1
kind: Pod
metadata:
name: hostpath
spec:
containers:
- name: redis
image: redis
volumeMounts:
- name: somepath
mountPath: /data/shared
volumes:
- name: somepath
hostPath:
path: /tmp
type: Directory
EOF
kubectl exec -it pod/hostpath -- /bin/sh
ls -al /data/shared

kubectl get storageclass
kubectl apply -f - <<EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: azurefile
spec:
accessModes:
- ReadWriteMany
storageClassName: azurefile
resources:
requests:
storage: 1Gi
EOF
kubectl get pvc

kubectl apply -f - <<EOF
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
name: order
labels:
app: "order"
spec:
selector:
matchLabels:
app: "order"
replicas: 1
template:
metadata:
labels:
app: "order"
spec:
containers:
- name: "order"
image: "ghcr.io/acmexii/order-liveness:latest"
ports:
- containerPort: 80
volumeMounts:
- mountPath: "/mnt/data"
name: volume
volumes:
- name: volume
persistentVolumeClaim:
claimName: azurefile
EOF
kubectl get all
kubectl exec -it <order-pod-name> -- /bin/sh
cd /mnt/data
echo "NFS Strorage Test.. " > test.txt
ls

kubectl scale deploy order --replicas=2
kubectl get pod -l app=order
kubectl exec -it <새로운 order-pod-name> -- /bin/sh
cd /mnt/data
ls
cat test.txt
# 2번째 컨테이너에서 새 파일 생성
echo "NFS Strorage Test2.. " > test2.txt
