#vi rc-probe.yaml
# /var/ready가 pod 안에 있으면 probe에서 통과 시킨다(Ready 상태로 만들어줌)
apiVersion: v1
kind: ReplicationController
metadata:
name: rc-readiness
spec:
replicas: 3
template:
metadata:
labels:
type: test
spec:
containers:
- image: reg.cloud.com/kubia
name: kubia
readinessProbe:
exec:
command:
- ls
- /var/ready
ports:
- containerPort: 8080
protocol: TCP
#vi service.yaml
apiVersion: v1
kind: Service
metadata:
name: test-svc
spec:
selector:
type: test
ports:
- port: 80
targetPort: 8080
[root@host01-4 hk]# k create -f rc-probe.yaml
replicationcontroller "rc-readiness" created
[root@host01-4 hk]# k get po -o wide
NAME READY STATUS RESTARTS AGE IP NODE
rc-readiness-22hxs 0/1 Running 0 10s 10.36.0.2 host01-3.cloud.com
rc-readiness-2pt29 0/1 Running 0 10s 10.44.0.1 host01-2.cloud.com
rc-readiness-h74t2 0/1 Running 0 10s 10.36.0.1 host01-3.cloud.com
#Running 상태이지만 Ready가 아무것도 없다
[root@host01-4 hk]# k create -f service.yaml
service "test-svc" created
[root@host01-4 hk]# k get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 6m
test-svc ClusterIP 10.98.99.22 <none> 80/TCP 4s
[root@host01-4 hk]# k get ep
NAME ENDPOINTS AGE
kubernetes 10.10.12.14:6443 6m
test-svc 9s
#Endpoint가 아무것도 안 떠있다.
[root@host01-4 hk]# k exec rc-readiness-22hxs -- touch /var/ready
#1번 pod에 /var/ready를 만들어준다 (Ready 상태로 만들어주기 위해)
[root@host01-4 hk]# k get ep
NAME ENDPOINTS AGE
kubernetes 10.10.12.14:6443 8m
test-svc 10.36.0.2:8080 1m
#test-svc의 ENDPOINT가 enabled된다
[root@host01-4 hk]# k get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 8m
test-svc ClusterIP 10.98.99.22 <none> 80/TCP 1m
[root@host01-4 hk]# k get po -o wide
NAME READY STATUS RESTARTS AGE IP NODE
rc-readiness-22hxs 1/1 Running 0 4m 10.36.0.2 host01-3.cloud.com
rc-readiness-2pt29 0/1 Running 0 4m 10.44.0.1 host01-2.cloud.com
rc-readiness-h74t2 0/1 Running 0 4m 10.36.0.1 host01-3.cloud.com
#1번 Pod가 Ready 상태로 바뀐다
[root@host01-4 hk]# k exec rc-readiness-2pt29 -- touch /var/ready
[root@host01-4 hk]# k get po -o wide
NAME READY STATUS RESTARTS AGE IP NODE
rc-readiness-22hxs 1/1 Running 0 5m 10.36.0.2 host01-3.cloud.com
rc-readiness-2pt29 1/1 Running 0 5m 10.44.0.1 host01-2.cloud.com
rc-readiness-h74t2 0/1 Running 0 5m 10.36.0.1 host01-3.cloud.com
#2번 Pod Ready 상태로 바뀐다