15 Şubat 2022 Salı

Probe Çeşitleri

Giriş
3 tane temel probe var.
1. Startup
2. Readiness
3. Liveness

Şeklen şöyle


Startup Probe
Startup Probe yazısına taşıdım

Readiness Probe
Readiness Probe yazısına taşıdım

Liveness Probe
Liveness Probe yazısına taşıdım

Süreler
Alanlar şöyle
- initialDelaySeconds : Probe'un ilk başlama süresini geciktirir
- timeoutSeconds : Probe'un cevap vermesini ne kadar bekleyeceğimizi belirtir.
- failureThreshold : Probe başarısız ise kaç defa daha tekrar deneyeceğimizi belirtir.
- successThreshold : Probe'un kaç tane başarılı sonuç döndükten sonra gerçekten başarılı kabul edileceğini belirtir.
- periodSeconds : Probe'un kaç saniye bir çalıştırılacağını belirtir.
Açıklaması şöyle
The first one is the initial delay (initialDelaySeconds) which defines the amount of time in seconds to wait before executing the probe for the first time. This interval is particularly good when we have applications with lots of dependencies and/or large loading time. If this property is not set, the probe will be executed as soon as the container is loaded.

After this initial delay, the probe is executed and kubelet waits for a certain amount of time for a result before assuming a fail for timeout (timeoutSeconds). Keep in mind that if you have a short timeout, you may have false results just because your application had no time enough to process the action. The default value is 1 second which is enough for most situations but I highly recommend to define a realistic value for each application.

If the probe fails, kubelet tries again how many times as set in the failureThreshold property, this way any temporary unavailability won’t cause the probe to put the container in a failed state. Only after the last consecutive failed attempt the container will be considered failed. If not set, the default number of attempts is 3.

In some situations a single successful result may not be enough to really ensure the health of our container. In this case, the successThreshold property sets how many consecutive times the action needs to be successful to change the state of a container from failed to successful.

We can also set the interval between one execution and another, in seconds, using the periodSeconds property. If not set, the probe will be executed every 10 seconds.

Probe Actions
httpGet
Shell Command

httpGet Probe Action
Söz dizimi şöyle
<probe-type>:
   httpGet:
     path: /my/healthcheck/endpoint?param=value
     port: 8080
     httpHeaders:
     - name: SomeHeaderName
       value: someHeaderValue
     - name: AnotherHeaderName
       value: "Another Header Value"
   initialDelaySeconds: 5
   periodSeconds: 10
   (...)
Örnek - path + port
Şöyle yaparız
apiVersion: v1
kind: Pod
metadata:
 name: simple-webapp
 labels:
 name: simple-webapp
spec:
 containers:
 — name: simple-webapp
 image: simple-webapp
 ports:
 — containerPort: 8080
 livenessProbe:
  httpGet: 
      path: /api/healthy
      port: 8080
  initialDelaySeconds: 10
  periodSeconds: 5
  failureThreshold: 8
 readinessProbe:
  httpGet: 
      path: /api/ready
      port: 8080
  initialDelaySeconds: 10
  periodSeconds: 5
  failureThreshold: 8
Örnek - path + port
Şöyle yaparız
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: backend
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: backend
      annotations:
        prometheus.io/scrape: 'true'
    spec:
      containers:
      - name: backend
        image: spring-boot-hpa
        imagePullPolicy: IfNotPresent
        env:
        - name: ACTIVEMQ_BROKER_URL
          value: "tcp://queue:61616"
        - name: STORE_ENABLED
          value: "false"
        - name: WORKER_ENABLED
          value: "true"
        ports:
        - containerPort: 8080
        livenessProbe:
          initialDelaySeconds: 5
          periodSeconds: 5
          httpGet:
            path: /health
            port: 8080
        resources:
          limits:
            memory: 512Mi
Örnek - httpHeaders
Şöyle yaparız
apiVersion: v1
kind: Pod
metadata:
  labels:
    test: liveness
  name: liveness-http
spec:
  containers:
  - name: liveness
    image: k8s.gcr.io/liveness
    args:
    - /server
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
        httpHeaders:
        - name: Custom-Header
          value: Awesome
      initialDelaySeconds: 3
      periodSeconds: 3
Shell Command Probe Action
Örnek
Şöyle yaparız
<probe-type>:
   exec:
     command:
     - /app/bin/myFantasticConsoleApp.exe
     - param1
     - "param 2"
   initialDelaySeconds: 5
   periodSeconds: 10
   (...)
TCP Port Check
Örnek
Şöyle yaparız
<probe-type>:
   tcpSocket:
     port: 5677
   initialDelaySeconds: 5
   periodSeconds: 10
   (...)







Hiç yorum yok:

Yorum Gönder

Cluster Propotional Autoscaler - ReplicaSet Ekler/Siler

Giriş Açıklaması şöyle CPA aims to horizontally scale the number of Pod replicas based on the cluster’s scale. A common example is DNS ser...