2
Make the Deployment ready.
Exec into the Pod and create file /tmp/ready .
Observe that the Pod is ready.
정답
controlplane $ cat space.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: space-alien-welcome-message-generator
name: space-alien-welcome-message-generator
spec:
replicas: 1
selector:
matchLabels:
app: space-alien-welcome-message-generator
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: space-alien-welcome-message-generator
spec:
containers:
- image: httpd:alpine
name: httpd
resources: {}
readinessProbe:
exec:
command:
- stat
- /tmp/ready
initialDelaySeconds: 10
periodSeconds: 5
status: {}
controlplane $ k get po
NAME READY STATUS RESTARTS AGE
space-alien-welcome-message-generator-676884c5db-9vsts 0/1 Running 0 21m
controlplane $ k exec space-alien-welcome-message-generator-676884c5db-9vsts -- touch /tmp/ready
controlplane $ k get po
NAME READY STATUS RESTARTS AGE
space-alien-welcome-message-generator-676884c5db-9vsts 1/1 Running 0 22m
풀이
stat는 리눅스/유닉스 시스템에서 파일이나 디렉토리의 상태 정보를 출력하는 명령어initialDelaySeconds: 10은 Pod가 시작된 후 10초 동안 기다린 후 ReadinessProbe를 실행하라는 의미periodSeconds: 5는 이후에 5초마다 ReadinessProbe를 실행하여 /tmp/ready 파일이 존재하는지 확인kubectl exec 명령을 사용하여 해당 Pod에 접속 -> 접속한 후, /tmp/ready라는 파일을 생성해야 함exec는 Kubernetes에서 Pod 내부에서 명령어를 실행하는 데 사용되는 명령어touch는 지정한 경로에 파일이 없으면 새로운 빈 파일을 생성