[인프런 워밍업 클럽 4기 - DevOps] [미션4]PVC/PV 응용과제

[인프런 워밍업 클럽 4기 - DevOps] [미션4]PVC/PV 응용과제

PVC/PV, Deployment, Service, HPA 응용 과제

 

1. PV, PVC

 

1~4. local 동작 확인

image

image

// 2번 - Container 임시 폴더 확인
kubectl exec -n anotherclass-123 -it api-tester-1231-5d4f6454fb-28b8k -- ls /usr/src/myapp/tmp
// 2번 - Container 영구저장 폴더 확인
kubectl exec -n anotherclass-123 -it api-tester-1231-5d4f6454fb-28b8k -- ls /usr/src/myapp/files/dev
// 2번 - master node 폴더 확인
ls /root/k8s-local-volume/1231

 image

// 3번 - Pod 삭제 
[root@k8s-master ~]# kubectl delete -n anotherclass-123 pod api-tester-1231-5d4f6454fb-28b8k

image

4번 API - 파일 조회

imageimage

1-2. hostPath 동작 확인 - Deployment 수정 후 [1~4] 실행

     spec:
      volumes:
        - name: files
          hostPath:
            path: /root/k8s-local-volume/1231
        - name: secret-datasource
          secret:
            secretName: api-tester-1231-postgresql
            defaultMode: 420

[1~4]확인

// 1번 API - 파일 생성
http://192.168.56.30:31231/create-file-pod
http://192.168.56.30:31231/create-file-pv

// 2번 - Container 임시 폴더 확인
[root@k8s-master ~]# kubectl exec -n anotherclass-123 -it api-tester-1231-7b47f86c96-pklt9 -- ls /usr/src/myapp/tmp
// 2번 - Container 영구저장 폴더 확인
[root@k8s-master ~]# kubectl exec -n anotherclass-123 -it api-tester-1231-7b47f86c96-pklt9 -- ls /usr/src/myapp/files/dev
// 2번 - master node 폴더 확인
[root@k8s-master ~]# ls /root/k8s-local-volume/1231

// 3번 - Pod 삭제
[root@k8s-master ~]# kubectl delete -n anotherclass-123 pod api-tester-1231-7b47f86c96-pklt9

// 4번 API - 파일 조회
http://192.168.56.30:31231/list-file-pod
http://192.168.56.30:31231/list-file-pv

 imageimageimageimageimage

 

2. Deployment

2-1. RollingUpdate 하기

 

image

kubectl set image -n anotherclass-123 deployment/api-tester-1231 api-tester-1231=1pro/api-tester:v2.0.0

image

배포 되는동안 2개의 버전이 공존함

 

2-2. RollingUpdate (maxUnavailable: 0%, maxSurge: 100%) 하기

 

  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0%
      maxSurge: 100%

image

2개의 버전이 공존하지 않음

 

2-3. Recreate 하기

  strategy:
    type: Recreate

image

배포중 서비스 중단

 

2-4. Rollback

imageimage

버전 v1.0에서 v2.0으로 롤백 성공 

 

3. Service

3-1. Pod 내부에서 Service 명으로 API 호출 [서비스 디스커버리]

image

3-2. Deployment에서 Pod의 ports 전체 삭제, Service targetPort를 http -> 8080으로 수정

// Deployment      
containers:
        - name: api-tester-1231
          image: 1pro/api-tester:v2.0.0
          envFrom:
            - configMapRef:
                name: api-tester-1231-properties
// Service
spec:
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
      nodePort: 31231

 image

4. HPA - search

4-1. 부하 발생

 imageimage

4-2. [behavior] 미사용으로 적용

imageimageimage

 

 

 

댓글을 작성해보세요.

채널톡 아이콘