Does the operator support drift detection?
# pulumi-kubernetes-operator
Does the operator support drift detection?
Could you expand what you mean by drift detection? You want the defined stack settings to stomp on external modifications automatically?
Sorry for delay, distracted by client work, yes, If any changes are made to the infrastructure managed via Pulumi I'd want it to be restored to the state defined in the pulumi source code/yaml that the operator is applied. Obviously you'd want this to be an optional feature that could be enabled.
So we have a means to do this now - but I haven't tried it explicitly. You can set the new
field on a stack and track a branch instead of a specific commit. This will cause the stack to be resynced periodically even if desired state specified in the HEAD commit on that branch has been reached. You can also set the
field to set the frequency with which this resync should occur. You will want to enable the
option to force pulumi to refresh its state from the backing resource during a resync to detect a drift. After which it should assert the state backed to the desired state in the backing repository/branch
👍 1
So I came here to ask this very question and I'm trying these settings but it's not changing it back to the desired state
Copy code
apiVersion: <|>
kind: Stack
  name: nginx-k8s-stack
      type: Secret
        name: pulumi-api-secret
        key: accessToken
  stack: christianh814/quickstart/dev
  projectRepo: <>
  branch: "refs/heads/main"
  destroyOnFinalize: true
  retryOnUpdateConflict: true
  continueResyncOnCommitMatch: true
  resyncFrequencySeconds: 30
  refresh: true
The code (golang) deploys the NGINX deployment with one replica. But when I scale it to 3...
Copy code
k scale deployment nginx-j2wvuiws --replicas=3
It never goes back down to 1
Copy code
$ k get pods -l app=nginx
NAME                              READY   STATUS    RESTARTS   AGE
nginx-j2wvuiws-85b98978db-dx4l7   1/1     Running   0          5m43s
nginx-j2wvuiws-85b98978db-sr8m8   1/1     Running   0          6m47s
nginx-j2wvuiws-85b98978db-zljgg   1/1     Running   0          5m43s
pulumi stack history
shows that it is running (every 30 seconds like I put in my config above). Am I missing something?
So I saw the same behavior with
pulumi up
so maybe this is a generic thing...
Just an update, doing
pulumi config set kubernetes:enableDryRun true --stack dev
fixed my issue (until that's the default behavior)
I’m not really sure why that fixed it, I wouldn’t expect that to change anything
I'm not 100% sure either. Not sure how Pulumi calculates diff. If it uses the same 3way diff Kuberentes does or if it uses something else. But the behavior is/was. Without that config, I experienced the above behavior.
Sorry I missed this - yes dry run would help here. See
pulumi logo 1