본문 바로가기
OS/kubernetes

🥰 kubernetes job에 liveness 및 readiness 설정 샘플

by Knowledge Store In Hyunsoft 2024. 8. 26.

 

 

 

Kubernetes에서 Job에 대한 liveness 및 readiness 프로브를 설정하는 것은 일반적으로 불필요합니다. 이는 Job의 목적이 단순히 하나 이상의 Pod를 실행하여 작업을 완료하는 것이기 때문입니다. 그러나 특정 시나리오에서는 liveness 및 readiness 프로브를 사용하여 Job의 상태를 모니터링하고, 필요한 경우 적절히 대응할 수 있습니다.

 

  • kubernetes Job YAML 샘플
apiVersion: batch/v1
kind: Job
metadata:
  name: example-job
spec:
  template:
    spec:
      containers:
      - name: example-container
        image: busybox
        command: ["/bin/sh", "-c", "echo 'Starting job...'; sleep 300; echo 'Job complete'"]
        
        # Readiness Probe
        readinessProbe:
          exec:
            command: ["cat", "/tmp/ready"]
          initialDelaySeconds: 5
          periodSeconds: 10
          failureThreshold: 3
          successThreshold: 1
        
        # Liveness Probe
        livenessProbe:
          exec:
            command: ["sh", "-c", "ps aux | grep 'sleep 300'"]
          initialDelaySeconds: 15
          periodSeconds: 20
          failureThreshold: 3
        
      restartPolicy: Never
  backoffLimit: 4
728x90

댓글