Exercise 5.2: Configure the Deployment: Attaching Storage
CP 노드에 연결된 터미널로 이동
NFS 서버 구성 스크립트 실행
wget -O - https://raw.githubusercontent.com/youngwjung/lf-training/main/LFD459/v1.24.1/solutions/s_05/CreateNFS.sh | bashWorker 노드에 연결된 터미널로 이동
NFS 유틸리티 설치
sudo apt -y install nfs-commonCP 노드에 구성한 NFS를 Worker 노드 파일시스템에 마운트
showmount -e CP_IP_ADDRESS sudo mount CP_IP_ADDRESS:/opt/sfw /mnt ls -l /mnt cat /mnt/hello.txtCP 노드에 연결된 터미널로 이동
PersistentVolume 생성
cat <<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 EOF생성된 PersistentVolume 확인
kubectl get pv생성된 PVC가 있는지 확인
kubectl get pvcPVC 생성
cat <<EOF | kubectl create -f - apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-one spec: accessModes: - ReadWriteMany resources: requests: storage: 200Mi EOF생성된 PVC 확인
kubectl get pvcPV 상태 확인
kubectl get pvDeployment 생성
cat <<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 EOF생성된 Pod 확인
kubectl get pod -l app=nginx-nfs생성된 Pod 상세 내용 확인
kubectl describe pod -l app=nginx-nfsPVC 상태 확인
kubectl get pvcCURL 명령어를 통해서 생성된 Pod의 IP주소로 HTTP 요청
curl $(kubectl get pod -l app=nginx-nfs -o=jsonpath='{.items[0].status.podIP}')/hello.txtDeployment 삭제
kubectl delete deployment nginx-nfsPVC 삭제
kubectl delete pvc pvc-onePV 상태 및 ReclaimPolicy 확인
kubectl get pv pvvol-1PV 삭제
kubectl delete pv pvvol-1NFS 서버에 공유된 파일 확인
cat /opt/sfw/hello.txt
PreviousExercise 5.1: Configure the Deployment: ConfigMapsNextExercise 5.3: Using ConfigMaps Configure Ambassador Containers
Last updated