ClusterNap

Guide

Argo CD, Flux and Helm

GitOps tools keep the cluster matching Git, including spec.replicas. When ClusterNap scales a namespace to zero at night, they may scale it straight back up. One setting fixes that.

What happens without it

ClusterNap notices when a sleeping workload is scaled back up. It does not fight the GitOps tool: it leaves that workload running until morning, stops counting it as saved, and warns you in Slack and on the dashboard. Everything else in the namespace keeps sleeping. Nothing breaks, but you lose the savings on that workload.

The fix is the same one you would use for a HorizontalPodAutoscaler: tell the GitOps tool that replica counts are managed elsewhere.

Argo CD

Per application, ignore replica differences and keep syncs from overwriting them:

apiVersion: argoproj.io/v1alpha1
kind: Application
spec:
  ignoreDifferences:
    - group: apps
      kind: Deployment
      jsonPointers: [/spec/replicas]
    - group: apps
      kind: StatefulSet
      jsonPointers: [/spec/replicas]
  syncPolicy:
    syncOptions:
      - RespectIgnoreDifferences=true

ignoreDifferences stops self-heal from treating the change as drift; RespectIgnoreDifferences=true stops the next sync, triggered by any other change, from writing the Git value back.

Or for every application at once, in the argocd-cm ConfigMap (still add the sync option per application):

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-cm
  namespace: argocd
data:
  resource.customizations.ignoreDifferences.apps_Deployment: |
    jsonPointers:
      - /spec/replicas
  resource.customizations.ignoreDifferences.apps_StatefulSet: |
    jsonPointers:
      - /spec/replicas

Flux

Kustomizations: remove spec.replicas from the Deployment and StatefulSet manifests of dev namespaces, as you would with an HPA. Flux then no longer owns the field.

HelmReleases: if drift detection is on, exclude replicas from it:

apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
spec:
  driftDetection:
    mode: enabled
    ignore:
      - paths: ["/spec/replicas"]
        target:
          kind: Deployment

A chart upgrade still renders the chart's replica count; see the Helm note below.

Helm and kubectl

helm upgrade and kubectl scale during a sleep set replicas explicitly. ClusterNap treats that as intentional and leaves the workload running until the namespace wakes, then manages it normally again. Deploy during working hours, or wake the namespace from the dashboard first.