Giriş
Açıklaması şöyle. Pod hemen hizmet sunmaya başlamaz. Önce Readiness Probe başarılı bir sonuç dönmelidir.
The readiness probe is employed to determine whether the application is ready to receive traffic.
Örneğin Pod'un bağımlı olduğu diğer Pod'ların hazır olup olmadığı kontrol edilir. Açıklaması şöyle
The most common use of this probe is to check if all dependencies of a pod are available. For example, if your application depends on a database, two other services and a message bus, you could implement a method to verify all these external components are ready. In case of failure, you can even provide different codes and responses for different kinds of fails to track down what component is failing.
Bu probe tek bir sefer değil sürekli çağrılır. Açıklaması şöyle. Yani bu probe kısa ve hızlı çalışmalıdır.
... some developers seems to ignore or forget the fact that this probe is not executed only during the startup of a container. It will be repeatedly executed and every time if fails the container will be removed from the list of available services for requests. Thus this probe should not execute long/heavy tasks to avoid overloading services. A busy service also my take longer to execute the probe and return false failures due to timeout.
timeoutSeconds Alanı
Açıklaması şöyle. Probe cevabın belirtilen sürede gelmesini bekler. Eğer cevap geç gelirse başarısız kabul edilir.
Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1.
successThreshold Alanı
Açıklaması şöyle. Readiness Probe belirtilen sayı kadar başarılı olduktan sonra container ready kabul edilir
The successThreshold for readinessProbe determines the number of consecutive successful probe responses required to mark the container as ready. If the probe succeeds for the specified number of consecutive times, Kubernetes considers the container ready and includes it in the load balancer rotation to start receiving traffic.
Örnek
Şöyle yaparız
readinessProbe: httpGet: path: /health port: 8080 initialDelaySeconds: 5 periodSeconds: 10 successThreshold: 2
Açıklaması şöyle.
In the above example, the readinessProbe sends an HTTP GET request to /health on port 8080 every 10 seconds, starting 5 seconds after the container starts. The successThreshold is set to 2, meaning that the probe must succeed two consecutive times for the container to be considered ready.
Readiness'i Kontrol Etmek İçin Yöntemler
Açıklaması şöyle.
The readinessProbe can be configured to use different methods to determine the container’s readiness. Some common methods include executing a command inside the container, making an HTTP request to a specific endpoint, or checking a TCP socket.
httpGet
Kullanlan alanlar şöyle
httpGet/path
httpGet/port
initialDelaySeconds
periodSeconds
application.properties dosyasında şöyle yaparız
management.endpoint.health.probes.enabled=true
Böylece iki tane endpoint etkin hale geliyor. Bunlar şöyle
/actuator/health/liveness /actuator/health/readiness
Şöyle yaparız
apiVersion: apps/v1 kind: Deployment metadata: name: spring-boot-actuator-app spec: selector: matchLabels: app: spring-boot-actuator-app replicas: 2 template: metadata: labels: app: spring-boot-actuator-app spec: containers: - name: spring-boot-actuator-app image: spring-boot-actuator-app:0.0.1 imagePullPolicy: IfNotPresent ports: - containerPort: 8080 livenessProbe: httpGet: path: /actuator/health/liveness port: 8080 initialDelaySeconds: 3 periodSeconds: 3 readinessProbe: httpGet: path: /actuator/health/readiness port: 8080 initialDelaySeconds: 3 periodSeconds: 3
Örnek
Şöyle yaparız
readinessProbe: httpGet: path: /actuator/health/readiness port: 8080 periodSeconds: 1 failureThreshold: 3 initialDelaySeconds: 10 timeoutSeconds: 1
Hiç yorum yok:
Yorum Gönder