{"record":{"id":"af0354515c34f996","repo":"derailed/k9s","slug":"desiring-d-replicas-got-d-available","errorCode":null,"errorMessage":"desiring %d replicas got %d available","messagePattern":"desiring (.+?) replicas got (.+?) available","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/render/dp.go","lineNumber":109,"sourceCode":"\tr.ID = client.MetaFQN(&dp.ObjectMeta)\n\tr.Fields = model1.Fields{\n\t\tdp.Namespace,\n\t\tdp.Name,\n\t\tcomputeVulScore(dp.Namespace, dp.Labels, &dp.Spec.Template.Spec),\n\t\tstrconv.Itoa(int(dp.Status.AvailableReplicas)) + \"/\" + strconv.Itoa(int(desired)),\n\t\tstrconv.Itoa(int(dp.Status.UpdatedReplicas)),\n\t\tstrconv.Itoa(int(dp.Status.AvailableReplicas)),\n\t\tmapToStr(dp.Labels),\n\t\tAsStatus(d.diagnose(dp.Status.Replicas, dp.Status.AvailableReplicas)),\n\t\tToAge(dp.GetCreationTimestamp()),\n\t}\n\n\treturn nil\n}\n\nfunc (Deployment) diagnose(desired, avail int32) error {\n\tif desired != avail {\n\t\treturn fmt.Errorf(\"desiring %d replicas got %d available\", desired, avail)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":91,"sourceCodeEnd":114,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/render/dp.go#L91-L114","documentation":"Deployment.diagnose compares status.replicas (desired) with status.availableReplicas; any difference yields 'desiring N replicas got M available'. It is the rollout-health indicator behind the deployment row status, red mid-rollout or when pods cannot become available.","triggerScenarios":"kubectl apply of a new image while pods restart; HPA scaling up faster than pods pass readiness; pods CrashLooping/ImagePullBackOff so availableReplicas never catches up; rollout stuck on PDB/quota.","commonSituations":"Normal deploys (transient), insufficient resources or node pressure, bad probes failing readiness, quota exhaustion, node taints preventing scheduling.","solutions":["If mid-deploy: kubectl rollout status deploy/<name> and wait — it self-clears","If stuck: kubectl get events and kubectl describe deploy <name> to find the blocker","Check pods: kubectl get pods -l <selector> for CrashLoop/ImagePull/Pending and fix the root cause (image, probe, resources)","Verify quotas/PDBs are not blocking scale (kubectl describe resourcequota / pdb)"],"exampleFix":"# before: ready probe too strict, available stays 0/2\nreadinessProbe:\n  httpGet: {path: /healthz, port: 8080}\n  initialDelaySeconds: 0\n  failureThreshold: 1\n# after\nreadinessProbe:\n  httpGet: {path: /healthz, port: 8080}\n  initialDelaySeconds: 10\n  failureThreshold: 3","handlingStrategy":"fallback","validationCode":"if dp.Status.Replicas == dp.Status.AvailableReplicas {\n\tstatus = \"ok\" // skip diagnose\n}","typeGuard":null,"tryCatchPattern":"Treat the diagnose error as row status, not a control-flow failure; pair it with kubectl rollout status in CI to distinguish transient rollouts from stuck ones.","preventionTips":["Make readiness probes fast and accurate so rollouts converge","Size resources/quotas for the replica count you request","Alert on stuck rollouts (availableReplicas unchanged for N minutes), not on every mismatch"],"tags":["deployment","rollout","health","kubernetes"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}