PersistentVolume Claims
次の条件に合う、新しいPersistentVolumeClaimを作成しなさい
- 名前: pv-volume
- class: app-hostpath-sc
- capacity: 10Mi
pv-volume PersistentVolumeClaimをマウントするPodを作成しなさい
- name: web-server-pod
- image: nginx
- MountPath: /usr/share/nginx/html
- Volume でReadWriteManyアクセス権限を持つように構成する
vi pv-volume.yaml
pv-volume.yaml
(修正前)pv-volume.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: myclaim
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 8Gi
storageClassName: slow
selector:
matchLabels:
release: "stable"
matchExpressions:
- {key: environment, operator: In, values: [dev]}
(修正後)pv-volume.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-volume # name
spec:
accessModes:
- ReadWriteMany # 権限
volumeMode: Filesystem
resources:
requests:
storage: 10Mi
storageClassName: app-hostpath-sc # class
kubectl apply -f ./pv-volume.yaml
vi web-server-pod.yaml
(修正前)web-server-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: web-server-pod
spec:
containers:
- name: myfrontend
image: nginx
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: mypd #mypdを利用する
volumes:
- name: mypd # mypd
persistentVolumeClaim:
claimName: pv-volume # pv-volumeを利用する
kubectl apply -f ./web-server-pod.yaml