In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you the process of kubernetes container health testing and readiness testing. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
1. Health detection exec probe apiVersion: v1kind: Podmetadata: name: liveness-execspec: containers:-name: liveness-demo image: busybox args: # Command for container initialization execution-/ bin/sh-- c-touch / tmp/healthy; sleep 10; rm-rf / tmp/healthy Sleep 600 # means that as soon as the container runs, it creates a file, sleeps for 10 seconds, and then deletes the file livenessProbe: # Health check exec: # ExecAction, executes a specific command in the container, returns 0 for command exit, indicates success # TCPSocketAction, and performs TCP check based on container IP address and specific port. Port opening indicates success # HTTPGetAction Initiate a HTTP request based on container IP, port and access path If the return code is between 200,400 and > successful command:-cat-/ tmp/healthy # use exec to detect whether "/ tmp/healthy" exists. Restart http probe apiVersion: v1kind: Podmetadata: name: liveness-httpspec: containers:-name: liveness-http image: nginx livenessProbe: httpGet: path: / index.html # probe path port: 80 scheme: HTTP initialDelaySeconds: 20 # indicates that the container starts 20 seconds later For the first probe, default 0s periodSeconds: 3 # means that each 3 s probe defaults to 10 s timeoutSeconds: 1 # indicates that the probe timeout defaults 1 s successThreshold: 1 # indicates that the probe fails again to the normal state, and that if the probe succeeds one time in a row, it is marked as normal. Default failureThreshold: 5 # indicates that it returns to normal state. If you want to detect 5 failures in a row, it will be marked as a failure by default 3 times.
[root@localhost] # kubectl exec liveness-http-it-/ bin/bash
# Log in to the container
Root@liveness-http:/# rm / usr/share/nginx/html/index.html
# manually delete index.html file to trigger manually
Kubectl describe pod liveness-exec | grep Liveness:
# run the command to view the probe status information
Properties of httpGet
Host: hostname or IP
Scheme: link type, HTTP or HTTPS. Default is HTTP.
Path: request path
HttpHeaders: custom request header
Port: request port
TCP probe apiVersion: v1kind: Podmetadata: name: liveness-tcpspec: containers:-name: liveness-tcp image: nginx livenessProbe: tcpSocket: port: 802. Ready state probe-execapiVersion: v1kind: Podmetadata: name: readiness-execspec: containers:-name: readiness-exec image: nginx args: ["/ bin/sh", "- c", "while true; do touch / tmp/ready; sleep 10; rm-f / tmp/ready; sleep 10; done "] # means creation of a file is paused for 10s, deletion of a file is paused for 10s, infinite loop readinessProbe: # ready state monitoring exec: command: [" cat "," / tmp/ready "] initialDelaySeconds: 5 periodSeconds: 1 # the container jumps back and forth in normal and abnormal states every 10 seconds
The configuration of readiness is similar to that of liveness. Other probes can be changed from livenessProbe to readinessProbe.
3. The restart policy status value describes that the Pod has been created by Pending API Server, but there are still one or more container images that have not been created in the unavailable node or Pod, including the process of downloading images. All containers within the Runnung Pod have been created, and at least one container is running, starting, or restarting. All containers in the Succeeded Pod exit after successful execution, and will not be restarted. All containers in the Failed Pod have exited, but at least one container exited in a failed state. Unknown is unable to obtain the status of the Pod for some reason, possibly due to poor network communication. ApiVersion: v1kind: Podmetadata: name: liveness-execspec: restartPolicy: Never # Always: when the container fails, kubelet automatically restarts the container, and normal exit also restarts # OnFailure: when the container terminates and the exit code is not 0, kubelet automatically restarts the container. Normal exit does not restart # Never: kubelet will not restart the container regardless of its running status, regardless of whether it exits normally or not. Do not restart containers:-name: liveness-exec image: busybox args:-/ bin/sh-- c-touch / tmp/healthy Sleep 10; rm-rf / tmp/healthy; sleep 600livenessProbe: exec: command:-cat-/ tmp/healthy the above is the process of kubernetes container health testing and readiness testing. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.