Readiness
Method
If readiness is not ready, it will remove endpoint of pod, so the network is not reachable even it register to DNS. if readiness is ready, it will enable the endpoint of pod, so the network is reachable.
Readiness Setting
image: 192.168.51.130:5000/uwebserverv6
readinessProbe:
tcpSocket:
port: 8000
initialDelaySeconds: 60
periodSeconds: 5
where initialDelaySeonds is delay time to probe the readiness, and after initial Delay, it will start to delete port 8000.
NAME READY STATUS RESTARTS AGE
dep-c-2945203518-dcjjm 0/1 Running 0 1m
To see endpoint, not yet setting
root@kubecontext:~/k8sdeployex/dependency/test2# kubectl get ep
NAME ENDPOINTS AGE
dep-c 1m
Although you see the dep-c's status is running, but in actually the networking is not reachable.
Do not use nslookup
since the name has been register to Sky-DNS.
So if you just use nslookup dep-c
, it will be connected.
After Readiness is ready.
root@kubecontext:~/k8sdeployex/dependency/test2# kubectl get po
NAME READY STATUS RESTARTS AGE
dep-c-3125362030-4tnjk 1/1 Running 0 1m
root@kubecontext:~/k8sdeployex/dependency/test2# kubectl get ep
NAME ENDPOINTS AGE
dep-c 192.168.15.6:8000 1m
Mention that
initialDelaySeconds
is delay time for probe. We set 60 is for after container launched 60secs, we then start to probe. Why is 60 secs, since we assume that the container will load data and is about 60 secs.- Do not use nslookup, since the DNS has registry the IP
root@kubecontext:~/k8sdeployex/dependency# kubectl get svc NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE dep-c 172.18.254.42 <none> 8000/TCP 1m
So you will see nslookup detect is true, but the readiness is not ready.
initContainer Setting
initContainers:
- name: init-myservice
image: 192.168.51.130:5000/emotibot-k8s/busybox:latest
command: ['sh', '-c', 'until nc -v -z -w 1 dep-c 8000 ; do echo waiting for myservice; sleep 2; done;']
#command: ['sh', '-c', 'until nslookup dep-c ; do echo waiting for myservice; sleep 2; done;']
Do not use nslookup, since DNS is registry. use nc to detect domain name and port is better.
No comments:
Post a Comment