meta data de esta página
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Próxima revisión | Revisión previa | ||
| virtualizacion:kubernetes:probes [2020/10/29 20:34] – creado lc | virtualizacion:kubernetes:probes [2023/01/18 14:37] (actual) – editor externo 127.0.0.1 | ||
|---|---|---|---|
| Línea 3: | Línea 3: | ||
| Tenemos tres tipos: | Tenemos tres tipos: | ||
| - | * Readiness Probe | + | * Readiness Probe -> Se utiliza para saber cuando un contenedor está listo para aceptar tráfico |
| - | * Liveness Probe | + | * Liveness Probe - > Se usa liveness probe para saber cuando hay que reiniciar un contenedor |
| - | * Startup Probe | + | * Startup Probe -> Se utiliza para saber cuando la aplicación de un container se ha iniciado. (por ejemplo si es una aplicación que tarda mucho en cargar) |
| + | |||
| + | Tenemos tres formas de hacer la comprobación de un probe: | ||
| + | |||
| + | * por HTTP. Se hace una petición GET, si la respuesta no está entre 200 y 300 implica algún tipo de error | ||
| + | * por un comando . Ejecutamos un comando. Si devuelve 0 se considera saludable, si da otro resultado no saludable | ||
| + | * por un puerto TCP Se intenta una conexión TCP a un puerto especificado. Si hay conexión se considera saludable, en caso contrario es que hay problemas | ||
| + | |||
| + | ==== Readiness Probe ==== | ||
| + | |||
| + | ==== Liveness Probe ==== | ||
| + | Con liveness probe revisamos el estado del contenedor y si el estado del contenedor no es el correcto Kubernetes lo reiniciará de forma automática | ||
| + | === Ejemplo de liveness probe por http === | ||
| + | <sxh yaml> | ||
| + | apiVersion: v1 | ||
| + | kind: Pod | ||
| + | metadata: | ||
| + | labels: | ||
| + | test: liveness | ||
| + | name: liveness-http | ||
| + | spec: | ||
| + | containers: | ||
| + | - name: liveness | ||
| + | image: k8s.gcr.io/ | ||
| + | args: | ||
| + | - /server | ||
| + | livenessProbe: | ||
| + | httpGet: | ||
| + | path: /healthz | ||
| + | port: 8080 | ||
| + | httpHeaders: | ||
| + | - name: Custom-Header | ||
| + | value: Awesome | ||
| + | initialDelaySeconds: | ||
| + | periodSeconds: | ||
| + | </ | ||
| + | === Ejemplo de liveness probe por comando === | ||
| + | <sxh yaml> | ||
| + | apiVersion: v1 | ||
| + | kind: Pod | ||
| + | metadata: | ||
| + | labels: | ||
| + | test: liveness | ||
| + | name: liveness-exec | ||
| + | spec: | ||
| + | containers: | ||
| + | - name: liveness | ||
| + | image: k8s.gcr.io/ | ||
| + | args: | ||
| + | - /bin/sh | ||
| + | - -c | ||
| + | - touch / | ||
| + | livenessProbe: | ||
| + | exec: | ||
| + | command: | ||
| + | - cat | ||
| + | - / | ||
| + | initialDelaySeconds: | ||
| + | periodSeconds: | ||
| + | </ | ||
| + | < | ||
| + | === ejemplo de liveness probe por tcp === | ||
| + | <sxh yaml> | ||
| + | apiVersion: v1 | ||
| + | kind: Pod | ||
| + | metadata: | ||
| + | name: goproxy | ||
| + | labels: | ||
| + | app: goproxy | ||
| + | spec: | ||
| + | containers: | ||
| + | - name: goproxy | ||
| + | image: k8s.gcr.io/ | ||
| + | ports: | ||
| + | - containerPort: | ||
| + | readinessProbe: | ||
| + | tcpSocket: | ||
| + | port: 8080 | ||
| + | initialDelaySeconds: | ||
| + | periodSeconds: | ||
| + | livenessProbe: | ||
| + | tcpSocket: | ||
| + | port: 8080 | ||
| + | initialDelaySeconds: | ||
| + | periodSeconds: | ||
| + | </ | ||
| + | ==== Startup Probe ==== | ||
| + | |||
| + | |||
| + | ==== Referencias ==== | ||
| + | * https:// | ||
| + | * https:// | ||