Skip to main contentIBM Cloud-Native

Observability

Liveness and Readiness Probes

A Probe is a diagnostic performed periodically by the kubelet on a Container. To perform a diagnostic, the kubelet calls a Handler implemented by the Container. There are three types of handlers:

ExecAction: Executes a specified command inside the Container. The diagnostic is considered successful if the command exits with a status code of 0.

TCPSocketAction: Performs a TCP check against the Container’s IP address on a specified port. The diagnostic is considered successful if the port is open.

HTTPGetAction: Performs an HTTP Get request against the Container’s IP address on a specified port and path. The diagnostic is considered successful if the response has a status code greater than or equal to 200 and less than 400.

The kubelet can optionally perform and react to three kinds of probes on running Containers:

livenessProbe: Indicates whether the Container is running.

readinessProbe: Indicates whether the Container is ready to service requests.

startupProbe: Indicates whether the application within the Container is started.

Resources

OpenShift

IKS

References

apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: app
image: busybox
command: ['sh', '-c', "echo Hello, Kubernetes! && sleep 3600"]
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
shareProcessNamespace: true
containers:
- name: app
image: bitnami/nginx

Container Logging

Application and systems logs can help you understand what is happening inside your cluster. The logs are particularly useful for debugging problems and monitoring cluster activity.

Kubernetes provides no native storage solution for log data, but you can integrate many existing logging solutions into your Kubernetes cluster.

Resources

OpenShift

IKS

References

apiVersion: v1
kind: Pod
metadata:
name: counter
spec:
containers:
- name: count
image: busybox
command: ['sh','-c','i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 5; done']

Get Logs

oc logs

Use Stern to View Logs

brew install stern
stern . -n default

Monitoring Applications

To scale an application and provide a reliable service, you need to understand how the application behaves when it is deployed. You can examine application performance in a Kubernetes cluster by examining the containers, pods, services, and the characteristics of the overall cluster. Kubernetes provides detailed information about an application’s resource usage at each of these levels. This information allows you to evaluate your application’s performance and where bottlenecks can be removed to improve overall performance.

Prometheus, a CNCF project, can natively monitor Kubernetes, nodes, and Prometheus itself.

Resources

OpenShift

IKS

References

apiVersion: v1
kind: Pod
metadata:
name: 500m
spec:
containers:
- name: app
image: gcr.io/kubernetes-e2e-test-images/resource-consumer:1.4
resources:
apiVersion: v1
kind: Pod
metadata:
name: 200m
spec:
containers:
- name: app
image: gcr.io/kubernetes-e2e-test-images/resource-consumer:1.4
resources:
oc get projects
oc api-resources -o wide
oc api-resources -o name
oc get nodes,ns,po,deploy,svc
oc describe node --all

Activities

TaskDescriptionLink
Try It Yourself
ProbesCreate some Health & Startup Probes to find what’s causing an issue.Probes