Exercise 3.3: Configure Probes

  1. simpleapp.yaml 파일을 텍스트 에디터에서 열고 아래와 같이 수정 - readinessProbe 추가

    ....
    spec:
      ....
      template:
        ....
        spec:
          containers:
          - image: 10.111.235.60:5000/simpleapp
            imagePullPolicy: Always
            name: simpleapp
            readinessProbe:
              periodSeconds: 5
              exec:
                command:
                - cat
                - /tmp/healthy
            resources: {}
    ....
  2. Deployment 삭제 후 재생성

    {
        kubectl delete deployment simpleapp
        kubectl create -f ~/app1/simpleapp.yaml
    }
  3. Deployment 및 Pod 상태 확인

    kubectl get deploy,pod -l app=simpleapp
  4. Pod의 상세내용 확인

    kubectl describe pod \
    $(kubectl get pod -l app=simpleapp -o=jsonpath='{.items[0].metadata.name}')
  5. 한개의 Pod에 /tmp/healthy 파일 생성

    kubectl exec \
    $(kubectl get pod -l app=simpleapp -o=jsonpath='{.items[0].metadata.name}') \
    -- touch /tmp/healthy
  6. Pod 상태 확인

    kubectl get pod -l app=simpleapp
  7. Deployment로 생성된 모든 Pod 이름 확인

    kubectl get pod -l app=simpleapp -o=jsonpath='{.items[*].metadata.name}'
  8. 모든 Pod에 /tmp/healthy 파일 생성

    for name in $(kubectl get pod -l app=simpleapp -o=jsonpath='{.items[*].metadata.name}')
    do
    kubectl exec $name -- touch /tmp/healthy
    done
  9. Pod 상태 확인

    kubectl get pod -l app=simpleapp
  10. 새로운 컨테이너를 추가하고 Readiness 및 Liveness Probe 명시

    cat <<EOF | kubectl apply -f -
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: simpleapp
      name: simpleapp
    spec:
      replicas: 10
      selector:
        matchLabels:
          app: simpleapp
      template:
        metadata:
          labels:
            app: simpleapp
        spec:
          containers:
          - image: $repo/simpleapp
            name: simpleapp
            readinessProbe:
              periodSeconds: 5
              exec:
                command:
                - cat
                - /tmp/healthy
          - name: goproxy
            image: k8s.gcr.io/goproxy:0.1
            ports:
            - containerPort: 8080
            readinessProbe:
              tcpSocket:
                port: 8080
              initialDelaySeconds: 5
              periodSeconds: 10
            livenessProbe:
              tcpSocket:
                port: 8080
              initialDelaySeconds: 15
              periodSeconds: 20
    EOF
  11. Deployment 및 Pod 상태 확인

    kubectl get deploy,pod -l app=simpleapp
  12. Deployment의 배포 상태 확인

    kubectl rollout status deployment simpleapp
  13. Deployment의 상세 내용 확인

    kubectl describe deployments.apps simpleapp
  14. 새로 생성된 Pod의 상세 내용 확인

    kubectl describe pod \
    $(kubectl get pod -l app=simpleapp -o=jsonpath='{.items[-1].metadata.name}')
  15. 모든 Pod에 /tmp/healthy 파일 생성

    for name in $(kubectl get pod -l app=simpleapp -o name)
    do
    kubectl exec $name -c simpleapp -- touch /tmp/healthy
    done
  16. Pod 상태 확인

    kubectl get pod -l app=simpleapp
  17. 모든 Pod에 /tmp/healthy 파일 생성

    for name in $(kubectl get pod -l app=simpleapp -o name)
    do
    kubectl exec $name -c simpleapp -- touch /tmp/healthy
    done
  18. Pod 상태 확인

    kubectl get pod -l app=simpleapp
  19. Pod의 상세내용 확인

    kubectl describe pod $(kubectl get pod -l app=simpleapp -o=jsonpath='{.items[-1].metadata.name}')
  20. Deployment 삭제

    kubectl delete deployment simpleapp

Last updated