feat(k8s-reporter): pod scheduling controls to avoid blocking Karpenter consolidation#985
Conversation
…ns rendering Add nodeSelector, tolerations, affinity and podTemplateAnnotations to the k8s-reporter chart, rendered into the CronJob pod template, so the reporter can be pinned to a stable node group away from Karpenter-managed nodes. Also fix podAnnotations, which was rendered inline on the CronJob metadata and produced invalid YAML for any non-empty value. It is now rendered correctly and kept CronJob-scoped; pod-level annotations use the new podTemplateAnnotations. Document 'Running on EKS with Karpenter' in the README and Mintlify docs (root cause is the consolidateAfter churn timer, ref kubernetes-sigs/karpenter#1921), regenerate README, and bump the chart to 2.3.0. Refs #984 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @AlexKantor87's task in 1m 39s —— View job PR Review: k8s-reporter pod scheduling controls
Nice, focused chart change. The templating is correct and idiomatic, the docs are thorough and technically accurate, and the version bump is right. Overall LGTM with one minor UX note.
What's correct
Minor (non-blocking)
Optional follow-ups
|
| # -- annotations to add to the CronJob object itself. For pod-level annotations (added to each reporter pod), use `podTemplateAnnotations` instead. | ||
| podAnnotations: {} | ||
|
|
||
| # -- annotations to add to the reporter pod template (applied to each Job pod that the CronJob creates) |
There was a problem hiding this comment.
Minor naming asymmetry worth calling out for users: podLabels is applied to the pod template (cronjob.yaml L27–30), while podAnnotations is applied to the CronJob object and the new podTemplateAnnotations to the pod. So podLabels → pod but podAnnotations → CronJob, which is easy to trip over.
Keeping podAnnotations CronJob-scoped for backwards-compat is a reasonable call, but consider making the doc string explicit that it pairs with podLabels differently, e.g.:
| # -- annotations to add to the CronJob object itself. For pod-level annotations (added to each reporter pod), use `podTemplateAnnotations` instead. | |
| podAnnotations: {} | |
| # -- annotations to add to the reporter pod template (applied to each Job pod that the CronJob creates) | |
| # -- annotations to add to the CronJob object itself. NOTE: unlike `podLabels` (which apply to the pod), these apply to the CronJob resource. For pod-level annotations (added to each reporter pod), use `podTemplateAnnotations`. | |
| podAnnotations: {} |
## What Documents the Karpenter node-scheduling controls added to the `k8s-reporter` chart in [kosli-dev/cli#985](kosli-dev/cli#985) (chart 2.3.0), and fixes the reporting tutorial's Helm example. ## Changes - **`helm/k8s_reporter.mdx`** — regenerated from chart 2.3.0. Adds a "Running on EKS with Karpenter (or another node autoscaler)" section and documents the new `nodeSelector`, `tolerations`, `affinity` and `podTemplateAnnotations` values; clarifies that `podAnnotations` is CronJob-scoped. This page is the Mintlify output of the chart's doc templates, so it was regenerated rather than hand-edited. - **`tutorials/report_k8s_envs.md`** — fix the Helm tab's `tutorial-values.yaml`, which still used the pre-v2 `kosliEnvironmentName` / `namespaces` fields (removed in chart v2.0.0), to the current `reporterConfig.environments` list format. Add a short Karpenter callout linking to the reference. ## Why On EKS with Karpenter the reporter CronJob can prevent node consolidation, via the `consolidateAfter` churn timer ([kubernetes-sigs/karpenter#1921](kubernetes-sigs/karpenter#1921)). The chart now exposes scheduling controls to avoid it; this documents them and the correct mitigations (widen the schedule, pin to a stable node group, or run out-of-cluster). It also corrects the tutorial example, which no longer works with chart v2.x. ## Validation - `mint broken-links` passes for the changed pages. (It surfaces one unrelated, pre-existing broken link, `/getting_started/service-accounts` in `working_with_controls.mdx`, which this PR does not touch.) Refs kosli-dev/cli#984, kosli-dev/cli#985 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
Adds pod scheduling controls to the
k8s-reporterchart so the environment reporter can be kept off Karpenter-managed nodes, and fixes apodAnnotationsrendering bug found along the way.Closes #984.
Why
On EKS with Karpenter, the reporter CronJob (default every 5 minutes) can prevent node consolidation. The root cause is Karpenter's
consolidateAfterchurn timer: every reporter pod event resets the node's quiet-period, so a node whoseconsolidateAfteris longer than the reporter interval never becomes consolidatable (kubernetes-sigs/karpenter#1921, confirmed by the maintainers as intended behaviour). The chart previously had no way to pin the reporter to a stable node group.Corrected during review:
karpenter.sh/do-not-disruptis not a fix (it prevents disruption, making consolidation less likely), andcluster-autoscaler.kubernetes.io/safe-to-evictis ignored by Karpenter. The correct mitigations are widening the schedule, pinning to a stable node group (this change), or running out-of-cluster. All three are documented in the new README section.Changes
nodeSelector,tolerations,affinity,podTemplateAnnotations, rendered into the CronJob pod template (spec.jobTemplate.spec.template.specand.metadata.annotations).podAnnotationswas rendered inline asannotations: {{ toYaml ... }}on the CronJob metadata, which produces invalid YAML for any non-empty value (the chart was effectively unusable with a realpodAnnotations). It is now rendered with the idiomatic{{- with }} ... {{- toYaml . | nindent }}and kept CronJob-scoped. Pod-level annotations use the newpodTemplateAnnotations._templates.gotmpl) and Mintlify (_mintlify_templates.gotmpl) sources; regeneratedREADME.md. The four new values are documented automatically in the values tables.2.2.1→2.3.0(minor, backwards-compatible).Testing
helm lint(CI-equivalent, with required values) passes.helm templateverified with defaults (all new blocks omitted cleanly) and with values set (nodeSelector/affinity/tolerations land under the pod spec;podTemplateAnnotationson the pod,podAnnotationson the CronJob object).README.mdregenerated with helm-docs v1.14.2; Mintlify output rendered and checked.Not included (follow-up)
A long-running Deployment mode (an alternative to the CronJob, which would also remove the per-run pod churn) needs a watch/loop mode in the CLI and is out of scope here. Worth a separate issue if there is demand.
🤖 Generated with Claude Code