In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Pod viability detection: used to determine whether the container handles the "running" state. If the test fails, kubelet will terminate the container and decide whether to restart according to the startup policy (restartPolicy). If the container is not defined, it defaults to "Success". There are three methods supported by survivor detection: ExecAction,TCPSocketAction,HTTPGetAction.
1. Use exec to detect the existence of files
[root@k8s01 yaml] # kubectl explain pods.spec.containers.livenessProbe
[root@k8s01 yaml] # vim execaction.yaml
ApiVersion: v1kind: Podmetadata: labels: test: exec-execaction name: execactionspec: containers:-name: execaction image: busybox:latest args: ["/ bin/sh", "- c", "touch / tmp/test.txt"]-- create test.txt file after container startup livenessProbe: exec: command: ["test", "- e", "/ tmp/test.txt"]-- check test.txt file If there is a Pod to start normally, if there is no Pod creation is not successful
[root@k8s01 yaml] # kubectl apply-f execaction.yaml
Pod/execaction created
[root@k8s01 yaml] #
two。 Probe ports using tcp protocol
[root@k8s01 yaml] # vim tcpaction.yaml
ApiVersion: v1kind: Podmetadata: labels: test: tcp-execaction name: tcpactionspec: containers:-name: tcpaction image: nginx:latest ports:-name: http containerPort: 80-- expose port 80 livenessProbe: tcpSocket:-- use tcp to detect port: http-- you can write protocols or ports here. Http defaults to port 80.
[root@k8s01 yaml] # kubectl apply-f tcpaction.yaml
Pod/tcpaction created
[root@k8s01 yaml] #
3. Probe services using the http protocol
[root@k8s01 yaml] # vim httpaction.yaml
ApiVersion: v1kind: Podmetadata: labels: test: http-execaction name: httpactionspec: containers:-name: httpaction image: nginx:latest ports:-name: http containerPort: 80 lifecycle: postStart:-- before the container starts, start the following command exec: command: ["/ bin/sh", "- c" "echo 123 > / usr/share/nginx/html/test.html"] livenessProbe: httpGet: path: / test.html-- probe whether nginx accesses the test.html page port: http
[root@k8s01 yaml] # kubectl apply-f httpaction.yaml
Pod/httpaction created
[root@k8s01 yaml] #
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.