Kubernetes/KoudKloud - CKAD with Tests

Probe 설정

비번변경 2021. 12. 2. 21:54

Probe란 컨테이너에서 kubelet에 의해 주기적으로 수행되는 진단(diagnostic)을 말한다. 이 글에서는 컨테이너가 요청을 처리할 준비가 되었는지 여부를 나타내는 Readiness Probe와, 컨테이너가 동작 중인지에 대한 여부를 나타내는 Liveness Probe를 설정하는 방법을 간단하게 정리한다.

Readiness Probe 설정

포드 정의 yaml 파일 내 spec > containers 아래에 readinessProbe 필드를 추가하여 설정한다. 

예시는 지정한 포트 및 경로에서 컨테이너의 IP주소에 대한 HTTP Get 요청 수행하는 httpGet을 설정한 yaml 파일이다.

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2021-11-23T11:20:20Z"
  labels:
    name: simple-webapp
  name: simple-webapp-2
  namespace: default
  resourceVersion: "744"
  uid: a7f36981-7dab-4925-a552-a415443afdeb
spec:
  containers:
  - env:
    - name: APP_START_DELAY
      value: "80"
    image: kodekloud/webapp-delayed-start
    imagePullPolicy: Always
    name: simple-webapp
    ports:
    - containerPort: 8080
      protocol: TCP
    resources: {}
    readinessProbe:
      httpGet:
        path: /ready
        port: 8080

 

Liveness Probe 설정

포드 정의 yaml 파일 내 spec > containers 아래에 livenessProbe 필드를 추가하여 설정한다.

예시는 지정한 포트 및 경로에서 컨테이너의 IP주소에 대한 HTTP Get 요청 수행하는 httpGet을 설정한 yaml 파일이다.

spec:
  containers:
  - image: kodekloud/webapp-delayed-start
    imagePullPolicy: Always
    name: simple-webapp
    ports:
    - containerPort: 8080
      protocol: TCP
    livenessProbe:
      httpGet:
        path: /live
        port: 8080
      initialDelaySeconds: 80
      periodSeconds: 1

 

 


2021.07.28 - 포드 상태와 readinessProbe

https://kubernetes.io/ko/docs/concepts/workloads/pods/pod-lifecycle/

 

파드 라이프사이클

이 페이지에서는 파드의 라이프사이클을 설명한다. 파드는 정의된 라이프사이클을 따른다. Pending 단계에서 시작해서, 기본 컨테이너 중 적어도 하나 이상이 OK로 시작하면 Running 단계를 통과하

kubernetes.io

 

728x90