What's the use of the Kubernetes probe?
This article mainly introduces the use of Kubernetes probe, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Kubernetes provides a probe (Probe) to test the health of the container. In fact, we have to check not only the health of the container, but also the health of the applications arranged in the container.
There are two types of Probe:
LivenessProbe: survival probe. If the check fails, it will kill the container and restart the operation according to Pod's restartPolicy policy.
ReadinessProbe: ready probe, if the check fails, Kubernetes will remove Pod from the service endpoints.
Probe supports the following three inspection methods:
HttpGet: send a HTTP request and return the 200-400 range status code as successful.
Exec: the status code returned by the Shell command is 0 as successful.
TcpSocket: the initiating TCP Socket was established successfully.
Let's give the configuration of each inspection method:
Exec check
ApiVersion: v1kind: Podmetadata: labels: test: liveness name: liveness-execspec: containers:-name: liveness image: busybox args:-/ bin/sh-- c-touch / tmp/healthy; sleep 30; rm-rf / tmp/healthy Sleep 60000livenessProbe: # # livenessProbe check type exec: # # exec check method command:-cat-/ tmp/healthy initialDelaySeconds: 5 # # check 5 seconds after the container starts periodSeconds: 5 # # check every 5 seconds
HttpGet check
ApiVersion: v1kind: Podmetadata: labels: test: liveness name: liveness-httpspec: containers:-name: liveness image: k8s.gcr.io/liveness args:-/ server livenessProbe: # # livenessProbe httpGet: # # httpGet checking method path: / healthz port: 8080 httpHeaders:-name: Custom-Header value: Awesome initialDelaySeconds: 3 periodSeconds: 3
TcpSocket check
ApiVersion: v1kind: Podmetadata: name: goproxy labels: app: goproxyspec: containers:-name: goproxy image: k8s.gcr.io/goproxy:0.1 ports:-containerPort: 8080 readinessProbe: # # readinessProbe check type tcpSocket: # # tcpSocket check method port: 8080 initialDelaySeconds: 5 periodSeconds: 10 livenessProbe: # # livenessProbe check type tcpSocket: # # tcpSocket check method Port: 8080 initialDelaySeconds: 15 periodSeconds: 20 Thank you for reading this article carefully I hope the article "what is the use of Kubernetes probe" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!