쿠버네티스 공부 1

00_8_3·2021년 4월 29일
0

쿠버네티스 공부

목록 보기
1/11

개발환경

  • 윈도우10 pro
  • wsl2, window for docker
  • minikube

minikube 설치 링크텍스트

기본 명령어

$ minikube start
$ minikube status
$ minikube stop
$ minikube delete

$ kubectl get nodes
$ kubectl get pods
// 야믈파일로 redis123이미지로 redis.yaml을 만든다.
$ kubectl run redis --image=redis123 --dry-run=client -o yaml > redis.yaml
// 만든 야믈로 pod 생성
$ kubectl create pod redis.yaml
// 생성된 pods 확인
$ kubectl get pods
// 특정 pod 상세정보  -> redis123 이미지 잘못 수정 필요
$ kubectl decribe pod redis
$ kubectl edit pod redis
// redis 파드 수정 후 몇 초 걸려서 pod 정상 재실행
$ kubectl get pods
// pods들 실시간 변화 확인가능
$ kubectl get pods -o wide --watch

livenessProbe 란

livenessProbe란 컨테이너의 건강검진!

  • nginx.yaml
...

    livenessProbe:
      httpGet:
        path: /
        port: 80
        
      periodSeconds: 30
      successThreshold: 1
      timeoutSeconds: 3
      failureThreshold: 3
  • 80 포트로 접근해서 컨테이너의 healty 체크를 해준다.
  • periodSeconds, successThreshold, timeoutSeconds, failureThreshold를 명시하지 않으면 디폴트 값으로 실행된다.

연습

문제 :

  • 동작되는 Pod내 컨테이너에 /tmp/healty 파일이 있는지 5초마다 확인
  • Pod 실행 후 10초 후부터 검사
  • 성공횟수 1번, 실패횟수 연속 2번
  • 정답
apiVersion: v1

kind: Pod
metadata:
  name: liveness-exam
spec:
  containers:
  - name: busybox-container
    image: busybox
    args:
    - /bin/sh
    - -c
    - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
    livenessProbe:
      exec:
        command:
        - ls
        - /tmp/healthy
      initialDelaySeconds: 10
      periodSeconds: 5
      successThreshold: 1
      failureThreshold: 2
      ```

0개의 댓글