Exercise 5.2: Configure the Deployment: Attaching Storage
wget -O - https://raw.githubusercontent.com/youngwjung/lf-training/main/LFD459/v1.24.1/solutions/s_05/CreateNFS.sh | bashsudo apt -y install nfs-commonshowmount -e CP_IP_ADDRESS sudo mount CP_IP_ADDRESS:/opt/sfw /mnt ls -l /mnt cat /mnt/hello.txtcat <<EOF | kubectl create -f - apiVersion: v1 kind: PersistentVolume metadata: name: pvvol-1 spec: capacity: storage: 1Gi accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Retain nfs: path: /opt/sfw server: $(curl -s ifconfig.me) readOnly: false EOFkubectl get pvkubectl get pvccat <<EOF | kubectl create -f - apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-one spec: accessModes: - ReadWriteMany resources: requests: storage: 200Mi EOFkubectl get pvckubectl get pvcat <<EOF | kubectl create -f - apiVersion: apps/v1 kind: Deployment metadata: labels: app: nginx-nfs name: nginx-nfs spec: selector: matchLabels: app: nginx-nfs template: metadata: labels: app: nginx-nfs spec: containers: - image: nginx imagePullPolicy: Always name: nginx volumeMounts: - name: nfs-vol mountPath: /usr/share/nginx/html ports: - containerPort: 80 protocol: TCP volumes: - name: nfs-vol persistentVolumeClaim: claimName: pvc-one EOFkubectl get pod -l app=nginx-nfskubectl describe pod -l app=nginx-nfskubectl get pvccurl $(kubectl get pod -l app=nginx-nfs -o=jsonpath='{.items[0].status.podIP}')/hello.txtkubectl delete deployment nginx-nfskubectl delete pvc pvc-onekubectl get pv pvvol-1kubectl delete pv pvvol-1cat /opt/sfw/hello.txt
PreviousExercise 5.1: Configure the Deployment: ConfigMapsNextExercise 5.3: Using ConfigMaps Configure Ambassador Containers
Last updated