株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

ファイル

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: ebs-sc
provisioner: ebs.csi.aws.com
volumeBindingMode: WaitForFirstConsumer
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ebs-claim
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ebs-sc
  resources:
    requests:
      storage: 4Gi
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

実行

kubectl apply -f testpv/

動作確認

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号機

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号機

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 /]#

<スポンサーリンク>

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)