ファイル
1 2 3 4 5 6 |
kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: ebs-sc provisioner: ebs.csi.aws.com volumeBindingMode: WaitForFirstConsumer |
1 2 3 4 5 6 7 8 9 10 11 |
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: ebs-claim spec: accessModes: - ReadWriteOnce storageClassName: ebs-sc resources: requests: storage: 4Gi |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
apiVersion: apps/v1 kind: Deployment metadata: name: deployment spec: replicas: 2 selector: matchLabels: app: centos template: metadata: labels: app: centos spec: containers: - name: centos image: centos:latest tty: true volumeMounts: - name: persistent-storage mountPath: /mnt volumes: - name: persistent-storage persistentVolumeClaim: claimName: ebs-claim |
実行
1 |
kubectl apply -f testpv/ |
動作確認
1 2 3 4 5 6 |
yuta:~ $ kubectl get pod NAME READY STATUS RESTARTS AGE deployment-687fbd7969-8spch 1/1 Running 0 2m16s deployment-687fbd7969-xk69b 1/1 Running 0 2m16s external-dns-547f4784f7-zqhdf 1/1 Running 0 2d8h yuta:~ $ |
Pod1号機
1 2 3 4 5 6 |
yuta:~ $ kubectl exec -it deployment-687fbd7969-8spch /bin/bash kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead. [root@deployment-687fbd7969-8spch /]# touch /mnt/chinko [root@deployment-687fbd7969-8spch /]# ls -l /mnt/chinko -rw-r--r-- 1 root root 0 Oct 1 07:39 /mnt/chinko [root@deployment-687fbd7969-8spch /]# |
Pod2号機
1 2 3 4 5 6 7 |
yuta:~ $ kubectl exec -it deployment-687fbd7969-xk69b /bin/bash kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead. [root@deployment-687fbd7969-xk69b /]# ls -l /mnt/ total 16 -rw-r--r-- 1 root root 0 Oct 1 07:39 chinko drwx------ 2 root root 16384 Oct 1 07:36 lost+found [root@deployment-687fbd7969-xk69b /]# |