mirror of https://github.com/istio/istio.io.git
Add health check using TCP socket (#8246)
This commit is contained in:
parent
dcd0e8c93f
commit
353444de45
|
@ -17,8 +17,9 @@ test: yes
|
||||||
[Kubernetes liveness and readiness probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/)
|
[Kubernetes liveness and readiness probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/)
|
||||||
describes several ways to configure liveness and readiness probes including:
|
describes several ways to configure liveness and readiness probes including:
|
||||||
|
|
||||||
1. Command
|
1. [Command](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-command)
|
||||||
1. HTTP request
|
1. [HTTP request](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-http-request)
|
||||||
|
1. [TCP Probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-tcp-liveness-probe)
|
||||||
|
|
||||||
The command approach works with Istio regardless of whether or not mutual TLS is enabled.
|
The command approach works with Istio regardless of whether or not mutual TLS is enabled.
|
||||||
|
|
||||||
|
@ -86,6 +87,7 @@ to disable the probe rewrite option. Make sure you add the annotation to the
|
||||||
anywhere else (for example, on an enclosing deployment resource).
|
anywhere else (for example, on an enclosing deployment resource).
|
||||||
|
|
||||||
{{< text yaml >}}
|
{{< text yaml >}}
|
||||||
|
kubectl apply -f - <<EOF
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
|
@ -114,6 +116,7 @@ spec:
|
||||||
port: 8001
|
port: 8001
|
||||||
initialDelaySeconds: 5
|
initialDelaySeconds: 5
|
||||||
periodSeconds: 5
|
periodSeconds: 5
|
||||||
|
EOF
|
||||||
{{< /text >}}
|
{{< /text >}}
|
||||||
|
|
||||||
This approach allows you to disable the health check probe rewrite gradually on individual deployments,
|
This approach allows you to disable the health check probe rewrite gradually on individual deployments,
|
||||||
|
@ -128,6 +131,40 @@ to disable the probe rewrite globally. **Alternatively**, update the configurati
|
||||||
$ kubectl get cm istio-sidecar-injector -n istio-system -o yaml | sed -e 's/"rewriteAppHTTPProbe": true/"rewriteAppHTTPProbe": false/' | kubectl apply -f -
|
$ kubectl get cm istio-sidecar-injector -n istio-system -o yaml | sed -e 's/"rewriteAppHTTPProbe": true/"rewriteAppHTTPProbe": false/' | kubectl apply -f -
|
||||||
{{< /text >}}
|
{{< /text >}}
|
||||||
|
|
||||||
|
## Liveness probes using the TCP socket
|
||||||
|
|
||||||
|
A third type of liveness probe uses a TCP socket.
|
||||||
|
|
||||||
|
{{< text yaml >}}
|
||||||
|
kubectl apply -f - <<EOF
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: liveness-tcp
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: liveness-tcp
|
||||||
|
version: v1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: liveness-tcp
|
||||||
|
version: v1
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: liveness-tcp
|
||||||
|
image: docker.io/istio/health:example
|
||||||
|
ports:
|
||||||
|
- containerPort: 8001
|
||||||
|
livenessProbe:
|
||||||
|
tcpSocket:
|
||||||
|
port: 8001
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 5
|
||||||
|
EOF
|
||||||
|
{{< /text >}}
|
||||||
|
|
||||||
## Cleanup
|
## Cleanup
|
||||||
|
|
||||||
Remove the namespace used for the examples:
|
Remove the namespace used for the examples:
|
||||||
|
|
|
@ -51,6 +51,7 @@ liveness-6857c8775f-zdv9r 2/2 Running 0 4m
|
||||||
ENDSNIP
|
ENDSNIP
|
||||||
|
|
||||||
! read -r -d '' snip_disable_the_http_probe_rewrite_for_a_pod_1 <<\ENDSNIP
|
! read -r -d '' snip_disable_the_http_probe_rewrite_for_a_pod_1 <<\ENDSNIP
|
||||||
|
kubectl apply -f - <<EOF
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
|
@ -79,12 +80,43 @@ spec:
|
||||||
port: 8001
|
port: 8001
|
||||||
initialDelaySeconds: 5
|
initialDelaySeconds: 5
|
||||||
periodSeconds: 5
|
periodSeconds: 5
|
||||||
|
EOF
|
||||||
ENDSNIP
|
ENDSNIP
|
||||||
|
|
||||||
snip_disable_the_probe_rewrite_globally_1() {
|
snip_disable_the_probe_rewrite_globally_1() {
|
||||||
kubectl get cm istio-sidecar-injector -n istio-system -o yaml | sed -e 's/"rewriteAppHTTPProbe": true/"rewriteAppHTTPProbe": false/' | kubectl apply -f -
|
kubectl get cm istio-sidecar-injector -n istio-system -o yaml | sed -e 's/"rewriteAppHTTPProbe": true/"rewriteAppHTTPProbe": false/' | kubectl apply -f -
|
||||||
}
|
}
|
||||||
|
|
||||||
|
! read -r -d '' snip_liveness_probes_using_the_tcp_socket_1 <<\ENDSNIP
|
||||||
|
kubectl apply -f - <<EOF
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: liveness-tcp
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: liveness-tcp
|
||||||
|
version: v1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: liveness-tcp
|
||||||
|
version: v1
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: liveness-tcp
|
||||||
|
image: docker.io/istio/health:example
|
||||||
|
ports:
|
||||||
|
- containerPort: 8001
|
||||||
|
livenessProbe:
|
||||||
|
tcpSocket:
|
||||||
|
port: 8001
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 5
|
||||||
|
EOF
|
||||||
|
ENDSNIP
|
||||||
|
|
||||||
snip_cleanup_1() {
|
snip_cleanup_1() {
|
||||||
kubectl delete ns istio-io-health
|
kubectl delete ns istio-io-health
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue