기타/K8S
udemy)CKA 강의 듣고 따라하기_5장_lifecycle :: mightytedkim
MightyTedKim
2022. 3. 31. 07:34
728x90
반응형
CKA 강의 듣고 따라하기_5장_application lifecycle management
+ 후기
수강 기간: 20220330~20220402(4일)
1시간 30분짜리 챕터지만 목차상으로는 어려워보이는 것은 없을 것 같음
1. rollout은 히스토리 관리할 수 있어서 좋은듯
2. docker의 cmd, entrypoint 개념 복습해서 좋음
3. configmap, secret 적용하는법 복습
4. initcontainer의 개념
Course content
Section 1: Introduction 7 / 7 | 20min : 강의 개요
Section 2: Core Concepts 40 / 40 | 2hr 57min : 기본 오브젝트 설명
Section 3: Scheduling 31 / 31 | 1hr 50min : scheduler, taint, tolerations, node affinity, static pod 설명
Section 4: Logging & Monitoring 8 / 8 | 13min : metrics, top, logs
Section 5: Application Lifecycle Management 1 / 28 | 1hr 31min

87. Application Lifecycle Management - Section Introduction 1min
> 강의 소개
88. Download Slide Deck 1min
> 강의 자료
89. Rolling Updates and Rollbacks 7min
> 운영할 때, pod delete 하는 방식으로 했었는데, 관련 정보 얻어서 유익했음
기본 deployment 전략 - pod를 모두 죽이지 않고, 중단 없이 pod를 재설정하는 것 recreate vs rollingupdate - 공통점 : controller가 관리 - scale down 전체 vs scale down 1개씩 upgrade & rollback $k get replicasets - 과거 내역이 0 0 0 $k rollout undo deployment/myapp-deployment - 돌릴 수 있음, 작업은 rollback/명령어는 rollout $ k rollout history deployment/myapp-deployment - 히스토리를 볼 수있음 |
90. Practice Test - Rolling Updates and Rollbacks 0min
> strategytype으로 설정할 수 있다는 걸 배웠음. 의미 있음
# strategtype이라는게 있었음 $ k describe deployment.apps/frontend | grep StrategyTyoe StrategyType: RollingUpdate # recreate, rollingupate 2개 있음 # default는 rollingupdate $ cay deploymet.yaml apiVersion: apps/v1 kind: Deployment metadata: name: frontend namespace: default spec: replicas: 4 selector: matchLabels: name: webapp strategy: type: Recreate # update 상황을 보려면 describe의 event를 보면됨 |
91. Solution: Rolling update : (Optional) 8min
> 위에 기입
92. Configure Applications 7min
> 알고는 있지만 정리가 필요한 영역이었는데 좋았음
docker conatiner는 프로세스용이지 os용은 아님 1. BASIC $ docker run ubuntu sleep 5 2. CMD # ubuntu-sleeper ``` From Ubuntu CMD sleep 5 ``` $ docker run ubuntu-sleeper $ docker run ubuntu-sleeper sleep 10 #adjust 3. ENTRYPOINT ``` # ubuntu-sleeper2 From Ubuntu ENTRYPOINT ["sleep"] ``` $ docker run ubuntu-sleeper2 10 4. entrypoint + cmd ``` # ubuntu-sleeper3 From Ubuntu ENTRYPOINT ["sleep"] CMD ["5"] 5. entrypoint 덮어쓰기 $ docker run --entrypoint sleep2.0 ubuntu-sleeper3 10 # cmd : sleep2.0 10 |
94. Commands and Arguments 3min
> 나중에 도움 될 예시
pod.yaml에도 additional argument를 전달할 수 있음 spec: containers: - name: ubuntu-sleeper image: ubuntu-sleeper command: ["sleep2.0"] #ENTRYPOINT args: ["10'] #CMD |
95. Practice Test - Commands and Arguments 0min
> cmd, args 관련 yaml 연습
96. Solution - Commands and Arguments (Optional) 11min
> 특별한거 없었음
97. Configure Environment Variables in Applications 1min
> 환경 변수 설정하는 3가지법
# 3가지 방법이 있음 spec: env: - name: APP_COLOR value: pink - name: APP_COLOR valueFrom: configMapKeyRef - name: APP_COLOR valueFrom: secretKeyRef |
98. Configuring ConfigMaps in Applications 5min
> configmap 생성 및 적용 방법
pod 배포할 때 conf설정을 같이 주면됨 #--from-literal, --from-file $ k create configmap app-config --from-literal=APP_COLOR=blue --from-literal=APP_MOD=prod $ k create configmap app-config --from-file=app_config.properties 1. create $ cat config-map.yaml apiVersion: v1 kind: ConfigMap metada: name: app-config data: APP_COLOR: blue 2. inject envFrom: - configMapRef: name : app-config envFrom: - name: APP_COLOR valueFrom: configMapKeyRef: name : app-config key: APP_COLOR volumes: - name: app-config-volume configmap: name: app-config |
99. Practice Test: Environment Variables 0min
> configmap 관련 문제나옴
configmap 설정 변경하려면 pod 재시작해야함 |
100. Solution - Environment Variables (Optional) 9min
> 은근 헷갈렸음
나중에 헷갈릴것 같아서 메모 spec: containers: - envFrom: - configMapRef: name: webapp-config-map configmap 약자는 cm $ k get cm $ k explain pods --recursive | grep enFrom -A3 로 복붙할 설정 조회 |
101. Configure Secrets in Applications 6min
>비밀번호 저장, 인코딩되서 저장이됨
1. create $ k create secret generic app-secret --from-literal=DB_HOST=mysql $ k create secret generic app-secret --from-file=app_secret.properties # 조회하기 $ echo -n 'mysql' | base64 BXlzcWw= $ echo -n 'BXlzcWw=' | base64 --decode mysql 2. inject envFrom: - secretRef: name : app-config envFrom: - name: DB_Password valueFrom: configMapKeyRef: name : app-secret key: DB_Password volumes: - name: app-secret-volume secret: secretName: app-secret $ cat /opt/app-secret-volumes/DBPassword |
102. A note about Secrets! 1min
> secret 관련 문제, config와 비슷함
# secret 도 지우고 실행해야함 |
103. Practice Test - Secrets 0min
> 특별한 내용 없음
104. Solution - Secrets (Optional) 10min
> 특별한 내용 없음
105. Scale Applications 1min
> 앞에서 다뤘다는 코멘트만 있음
106. Multi Container PODs 2min
> side-car 컨테이너가 이거
동일한 lifecycle을 공유하는 컨테이너들은 단일 pod에 묶어서 사용할 수 있음 이러면 서비스나 볼륨을 같이 사용하기 때문에 효율적임 |
107. Practice Test - Multi Container PODs 1min
> elastic 예시가 나와서 특이했음
오랜만에 elasticsearch 봐서 재밋었음 |
108. Solution - Multi-Container Pods (Optional) 10min
> 특별한 건 없었음
109. Multi-container PODs Design Patterns 1min
>
3가지 디자인 패턴이 있음 - sidecar : 로깅 - adapter,ambassador: cka 시험에 포함안되서 패스, 일단 있다는 것만 알아두기 |
110. InitContainers 2min
> 기본적인 설명
111. Practice Test - Init Containers 1min
pod 시작할 때 먼저 실행되는 컨테이너 spec: containers: - name: myapp-container image: busybox:1.28 command: ['sh', '-c', 'echo The app is running! && sleep 3600'] initContainers: - name: init-myservice image: busybox:1.28 command: ['sh', '-c', "until nslookup myservice.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for myservice; sleep 2; done"] https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ |
> 특별한건 없었음
112. Solution - Init Containers (Optional) 8min
initcontainer도 pod 재생성해야됨, 수정 안됨 |
> 특별한건 없었음
113. Self Healing Applications 1min
> self healing은 범위가 아미
Replication controller로 self healing함 libendess, readiness probs 이용해서 상태 체크함 - 하지만 cka 시험에 들가는 범위가 아님 , ckad에서 필요함 |
114. If you like it, Share it! 1min
> 별거엇음
728x90
반응형