Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to implement Pod Readiness Detection

Shulou Source: shulou.com Published: 2022-05-31 16:35:37 09月26日 Update

This article shows you how to achieve Pod ready detection, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.

When the Pod container starts successfully, the configuration and data have not been loaded, as well as other third-party scripting services. In this process, if a client sends a request, it will wait too long and the response will be slow, which will greatly affect the customer's experience. Therefore, in order to avoid processing the client request immediately after the pod starts successfully, instead, wait for the container to enter the "ready" state after all the initialization work is completed. When the readability probe fails, it does not kill or restart the container, but ensures that no client requests to enter the Pod object. Ready probes support three ways: exec,httpGet and tcpSocket.

1. Use exec to detect the existence of files

[root@k8s01 yaml] # kubectl explain pods.spec.containers.readinessProbe

[root@k8s01 yaml] # vim execreadiness.yaml

ApiVersion: v1

Kind: Pod

Metadata:

Labels:

Test: exec-readinessprobe

Name: readinessprobe

Spec:

Containers:

-name: exec-readinessprobe

Image: busybox:latest

Args: ["/ bin/sh", "- c", "touch / tmp/test.txt"]

ReadinessProbe:

Exec:

Command: ["test", "- e", "/ tmp/test.txt"]-- probe whether the file exists, and enter the readiness immediately if it exists

InitialDelaySeconds: 5-use the command command to probe after the Pod initialization is complete (5 seconds)

PeriodSeconds: 5-probe period 5 seconds

[root@k8s01 yaml] # kubectl apply-f execreadiness.yaml

Pod/readinessprobe created

[root@k8s01 yaml] #

The above is how to implement Pod Readiness Detection. 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.

Tags: Probe client client container success content skills files knowledge but concise concise chemical backward cycle commands that is data articles methods Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB OPPO Reno MySQL Shulou Information Linux