I'm new to K8s and Kubernetes. Could someone please explain me the difference between the following kube state metrics... I've included the best descriptions I could find but I need some more context:
- kube_deployment_spec_replicas - Number of desired pods for a deployment.
- kube_deployment_status_replicas - The number of replicas per deployment.
- kube_deployment_status_replicas_available - The number of available replicas per deployment.
- kube_deployment_status_replicas_unavailable - The number of unavailable replicas per deployment.
So my take away is:
- kube_deployment_spec_replicas=desired
- kube_deployment_status_replicas=current
Then of the current pods, some are available or not.
Does that mean that kube_deployment_status_replicas_unavailable = kube_deployment_status_replicas-kube_deployment_status_replicas_available
Would appreciate any deeper understanding of what exactly these metrics mean.
I think you answered your own question.
In k8s, you can scale up/down deployments, yet that ability depends on the node capacity.
So if you start with a deployment of some service and 2 replicas. This will liekly deploy right away and you'll have 2 pods available right away. 2 desired, 2 available, none unavailable.
Now, say you scale this deployment to 100 pods. You'll have 100 desired, but 2 actual replicas at first, 2 available, then the scheduler will 'schedule' the 100 pods, but the node may not have the capacity, so it may be able to deploy 20, and 80 will be 'pending' and therefore unavailable. Desired is 100, actual is 20, and unavailable is 80, until the cluster scales up (assuming you have autoscaler or you manually add a node), then the pods can be scheduled and will become available.