KubernetesStatefulsetReplicasMismatch #
StatefulSet does not match the expected number of replicas.
Alert Rule
alert: KubernetesStatefulsetReplicasMismatch
annotations:
description: |-
StatefulSet does not match the expected number of replicas.
VALUE = {{ $value }}
LABELS = {{ $labels }}
runbook: https://srerun.github.io/prometheus-alerts/runbooks/kubestate-exporter/kubernetesstatefulsetreplicasmismatch/
summary: Kubernetes StatefulSet replicas mismatch (instance {{ $labels.instance
}})
expr: kube_statefulset_status_replicas_ready != kube_statefulset_status_replicas
for: 10m
labels:
severity: warning
Here is a runbook for the Prometheus alert rule:
Meaning #
The KubernetesStatefulsetReplicasMismatch
alert is triggered when the number of ready replicas in a StatefulSet does not match the expected number of replicas. This alert is raised when the kube_statefulset_status_replicas_ready
metric does not equal the kube_statefulset_status_replicas
metric for a period of 10 minutes.
Impact #
A mismatch in the number of replicas can lead to:
- Inconsistent application behavior
- Loss of data or inconsistent data
- Inability to scale or upgrade the application
- Potential security risks due to unexpected changes in the cluster
Diagnosis #
To diagnose the issue, follow these steps:
- Check the StatefulSet configuration to ensure it is correctly set up and the desired number of replicas is correct.
- Verify that the
kube_statefulset_status_replicas_ready
andkube_statefulset_status_replicas
metrics are correct and up-to-date. - Check the pod logs for any errors or issues that may be preventing the pods from being created or becoming ready.
- Check the cluster events to see if there are any errors or issues related to the StatefulSet or pods.
- Verify that the StatefulSet is not stuck in a rolling update or deployment.
Mitigation #
To mitigate the issue, follow these steps:
- Check the StatefulSet configuration and update it if necessary to ensure the correct number of replicas.
- Verify that the pods are correctly configured and update them if necessary.
- Check for any issues with the cluster or nodes that may be preventing the pods from being created or becoming ready.
- Check for any errors or issues related to the StatefulSet or pods and resolve them.
- If the issue persists, consider rolling back to a previous version of the StatefulSet or pods, or seeking assistance from a Kubernetes administrator.