diff --git a/content/en/docs/ops/configuration/mesh/app-health-check/index.md b/content/en/docs/ops/configuration/mesh/app-health-check/index.md index d72166ecec..27885bf308 100644 --- a/content/en/docs/ops/configuration/mesh/app-health-check/index.md +++ b/content/en/docs/ops/configuration/mesh/app-health-check/index.md @@ -10,6 +10,7 @@ aliases: - /docs/ops/app-health-check - /docs/ops/setup/app-health-check keywords: [security,health-check] +test: true --- [Kubernetes liveness and readiness probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/) @@ -169,12 +170,12 @@ Instructions below assume you turn on the feature globally via install option. Annotations works the same. {{< text bash >}} -$ kubectl delete -f <(istioctl kube-inject -f @samples/health-check/liveness-http-same-port.yaml@) -$ kubectl apply -f <(istioctl kube-inject -f @samples/health-check/liveness-http-same-port.yaml@) +$ kubectl create ns istio-same-port +$ kubectl -n istio-same-port apply -f <(istioctl kube-inject -f @samples/health-check/liveness-http-same-port.yaml@) {{< /text >}} {{< text bash >}} -$ kubectl get pod +$ kubectl -n istio-same-port get pod NAME READY STATUS RESTARTS AGE liveness-http-975595bb6-5b2z7c 2/2 Running 0 1m {{< /text >}} @@ -189,14 +190,14 @@ Another alternative is to use separate port for health checking and regular traf Run these commands to re-deploy the service: {{< text bash >}} -$ kubectl delete -f <(istioctl kube-inject -f @samples/health-check/liveness-http.yaml@) -$ kubectl apply -f <(istioctl kube-inject -f @samples/health-check/liveness-http.yaml@) +$ kubectl create ns istio-sep-port +$ kubectl -n istio-sep-port apply -f <(istioctl kube-inject -f @samples/health-check/liveness-http.yaml@) {{< /text >}} Wait for a minute and check the pod status to make sure the liveness probes work with '0' in the 'RESTARTS' column. {{< text bash >}} -$ kubectl get pod +$ kubectl -n istio-sep-port get pod NAME READY STATUS RESTARTS AGE liveness-http-67d5db65f5-765bb 2/2 Running 0 1m {{< /text >}} @@ -208,7 +209,5 @@ Note that the image in [liveness-http]({{< github_file >}}/samples/health-check/ Remove the mutual TLS policy and corresponding destination rule added in the steps above: {{< text bash >}} -$ kubectl delete policies default -$ kubectl delete destinationrules default -$ kubectl delete ns istio-io-health +$ kubectl delete ns istio-io-health istio-same-port istio-sep-port {{< /text >}} diff --git a/content/en/docs/ops/configuration/mesh/app-health-check/snips.sh b/content/en/docs/ops/configuration/mesh/app-health-check/snips.sh new file mode 100644 index 0000000000..07065b0c45 --- /dev/null +++ b/content/en/docs/ops/configuration/mesh/app-health-check/snips.sh @@ -0,0 +1,136 @@ +#!/bin/bash + +# Copyright Istio Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#################################################################################################### +# WARNING: THIS IS AN AUTO-GENERATED FILE, DO NOT EDIT. PLEASE MODIFY THE ORIGINAL MARKDOWN FILE: +# docs/ops/configuration/mesh/app-health-check/index.md +#################################################################################################### + +snip_liveness_and_readiness_probes_with_command_option_1() { +kubectl create ns istio-io-health +} + +snip_liveness_and_readiness_probes_with_command_option_2() { +kubectl apply -f - <`) + 1. different elapsed time values (e.g., `30s` is like `5m`) + 1. different ip values (e.g., `172.21.0.1` is like `10.0.0.31`) + 1. prefix match ending with a dash character (e.g., `reviews-v1-12345...` is like `reviews-v1-67890...`) This function is useful for comparing the output of commands that include some run-specific values in the output (e.g., `kubectl get pods`), or when whitespace in the output may be different. diff --git a/tests/configuration/scripts/cleanup.txt b/tests/configuration/scripts/cleanup.txt index e4e2c44121..a9352bdf60 100644 --- a/tests/configuration/scripts/cleanup.txt +++ b/tests/configuration/scripts/cleanup.txt @@ -18,11 +18,8 @@ set -e set -u set -o pipefail -# $snippet cleanup.sh syntax="bash" -$ kubectl -n istio-io-health delete policies default -$ kubectl -n istio-io-health delete destinationrules default -$ kubectl delete ns istio-io-health -$ kubectl delete ns health-global -$ kubectl delete ns health-annotate -$ kubectl delete ns health-sepport -# $endsnippet \ No newline at end of file +source ${REPO_ROOT}/content/en/docs/ops/configuration/mesh/app-health-check/snips.sh + +snip_cleanup_1 + +kubectl delete ns health-annotate diff --git a/tests/configuration/scripts/liveness_and_readiness_probes_with_command.txt b/tests/configuration/scripts/liveness_and_readiness_probes_with_command.txt index 51b0477bc7..8d43f358a2 100644 --- a/tests/configuration/scripts/liveness_and_readiness_probes_with_command.txt +++ b/tests/configuration/scripts/liveness_and_readiness_probes_with_command.txt @@ -18,49 +18,19 @@ set -e set -u set -o pipefail -$ kubectl create ns istio-io-health +source ${REPO_ROOT}/content/en/docs/ops/configuration/mesh/app-health-check/snips.sh -# $snippet auth_policy.sh syntax="bash" -$ kubectl apply -f - <&1) +_verify_like "$out" "$snip_liveness_and_readiness_probes_with_command_option_5_out" "snip_liveness_and_readiness_probes_with_command_option_5" + +kubectl -n istio-io-health delete -f samples/health-check/liveness-command.yaml diff --git a/tests/configuration/scripts/liveness_and_readiness_probes_with_http_annotations.txt b/tests/configuration/scripts/liveness_and_readiness_probes_with_http_annotations.txt index 612bdb0284..c6027fdbd8 100644 --- a/tests/configuration/scripts/liveness_and_readiness_probes_with_http_annotations.txt +++ b/tests/configuration/scripts/liveness_and_readiness_probes_with_http_annotations.txt @@ -18,49 +18,17 @@ set -e set -u set -o pipefail -$ kubectl create ns health-annotate +source ${REPO_ROOT}/content/en/docs/ops/configuration/mesh/app-health-check/snips.sh -# $snippet annotate_pod.sh syntax="bash" -$ kubectl -n health-annotate apply -f - <&1) +expected="NAME READY STATUS RESTARTS AGE +liveness-http-975595bb6-5b2z7c 1/1 Running 0 1m" +_verify_like "$out" "$expected" "verify_health-annotate_pod" + +kubectl -n health-annotate delete deploy/liveness-http diff --git a/tests/configuration/scripts/liveness_and_readiness_probes_with_http_globally.txt b/tests/configuration/scripts/liveness_and_readiness_probes_with_http_globally.txt index 0b415d9abe..3c2319a7c5 100644 --- a/tests/configuration/scripts/liveness_and_readiness_probes_with_http_globally.txt +++ b/tests/configuration/scripts/liveness_and_readiness_probes_with_http_globally.txt @@ -18,29 +18,17 @@ set -e set -u set -o pipefail -$ kubectl create ns health-global +source ${REPO_ROOT}/content/en/docs/ops/configuration/mesh/app-health-check/snips.sh -# $snippet update_config_map.sh syntax="bash" -kubectl get cm istio-sidecar-injector -n istio-system -o yaml | sed -e 's/"rewriteAppHTTPProbe":false/"rewriteAppHTTPProbe":true/' | kubectl apply -f - -# $endsnippet +snip_enable_globally_via_install_option_1 -# $snippet globally_re-deploy.sh syntax="bash" -$ kubectl -n health-global apply -f <(istioctl kube-inject -f @samples/health-check/liveness-http-same-port.yaml@) -# $endsnippet +snip_redeploy_the_liveness_health_check_app_1 -$ kubectl -n health-global rollout status deployment liveness-http --timeout 60s +kubectl -n istio-same-port rollout status deployment liveness-http --timeout 60s -# $snippet re-deploy_globally_check_status.sh syntax="bash" outputis="text" -$ kubectl -n health-global get pod -# $verify verifier="lineRegex" -NAME *READY *STATUS *RESTARTS *AGE -liveness-http-[0-9a-z]*-[0-9a-z]* *2/2 *Running *0 ? -# $endsnippet +out=$(snip_redeploy_the_liveness_health_check_app_2 2>&1) +_verify_like "$out" "$snip_redeploy_the_liveness_health_check_app_2_out" "snip_redeploy_the_liveness_health_check_app_2" -# $snippet delete_globally_deploy.sh syntax="bash" -$ kubectl -n health-global delete -f <(istioctl kube-inject -f @samples/health-check/liveness-http-same-port.yaml@) -# $endsnippet +kubectl -n istio-same-port delete -f samples/health-check/liveness-http-same-port.yaml -# $snippet revert_config_map.sh syntax="bash" -kubectl get cm istio-sidecar-injector -n istio-system -o yaml | sed -e 's/"rewriteAppHTTPProbe":true/"rewriteAppHTTPProbe":false/' | kubectl apply -f - -# $endsnippet +kubectl get cm istio-sidecar-injector -n istio-system -o yaml | sed -e 's/"rewriteAppHTTPProbe": true/"rewriteAppHTTPProbe": false/' | kubectl apply -f - diff --git a/tests/configuration/scripts/liveness_and_readiness_probes_with_http_separate_port.txt b/tests/configuration/scripts/liveness_and_readiness_probes_with_http_separate_port.txt index b281a9d983..28238233c4 100644 --- a/tests/configuration/scripts/liveness_and_readiness_probes_with_http_separate_port.txt +++ b/tests/configuration/scripts/liveness_and_readiness_probes_with_http_separate_port.txt @@ -18,21 +18,13 @@ set -e set -u set -o pipefail -$ kubectl create ns health-sepport +source ${REPO_ROOT}/content/en/docs/ops/configuration/mesh/app-health-check/snips.sh -# $snippet with_separate_port.sh syntax="bash" -$ kubectl -n health-sepport apply -f <(istioctl kube-inject -f @samples/health-check/liveness-http.yaml@) -# $endsnippet +snip_separate_port_1 -$ kubectl -n health-sepport rollout status deployment liveness-http --timeout 60s +kubectl -n istio-sep-port rollout status deployment liveness-http --timeout 60s -# $snippet separate_port_check_status.sh syntax="bash" outputis="text" -$ kubectl -n health-sepport get pod -# $verify verifier="lineRegex" -NAME *READY *STATUS *RESTARTS *AGE -liveness-http-[0-9a-z]*-[0-9a-z]* *2/2 *Running *0 ? -# $endsnippet +out=$(snip_separate_port_2 2>&1) +_verify_like "$out" "$snip_separate_port_2_out" "snip_separate_port_2" -# $snippet delete_with_separate_port.sh syntax="bash" -$ kubectl -n health-sepport delete -f <(istioctl kube-inject -f @samples/health-check/liveness-http.yaml@) -# $endsnippet +kubectl -n istio-sep-port delete -f samples/health-check/liveness-http.yaml