wonderful-portugal-96162
02/17/2022, 4:17 PMpulumi up
(doing it manually). I have this sample code that deploys a Deployment with one replica.
pulumi up --stack dev -y --refresh=true
does what's expected.
$ k get pods
NAME READY STATUS RESTARTS AGE
nginx-fsbqexby-6799fc88d8-ch2b8 1/1 Running 0 42m
I delete the deployment and run pulumi up --stack dev -y --refresh=true
again and it creates the deployment as expected
$ k get pods
NAME READY STATUS RESTARTS AGE
nginx-w88w29hu-6799fc88d8-w4bvr 0/1 ContainerCreating 0 0s
Cool, let me scale the deployment (my cluster now has drift)
$ k scale deployment nginx-w88w29hu --replicas=3
deployment.apps/nginx-w88w29hu scaled
$ k get pods
NAME READY STATUS RESTARTS AGE
nginx-w88w29hu-6799fc88d8-fdhkh 0/1 ContainerCreating 0 2s
nginx-w88w29hu-6799fc88d8-kq4pp 1/1 Running 0 2s
nginx-w88w29hu-6799fc88d8-w4bvr 1/1 Running 0 63s
Running pulumi up --stack dev -y --refresh=true
again, doesn't do anything. It gives me Resources: 3 unchanged
and the 3 replicas are still there.
$ k get pods
NAME READY STATUS RESTARTS AGE
nginx-w88w29hu-6799fc88d8-fdhkh 1/1 Running 0 90s
nginx-w88w29hu-6799fc88d8-kq4pp 1/1 Running 0 90s
nginx-w88w29hu-6799fc88d8-w4bvr 1/1 Running 0 2m31s
My expectation, is that pulumi up
would detect the drift and correct it for me.main.go
file with appDeploymentReplicas := 2
... running pulumi up --stack dev -y --refresh=true
actually DOES correct the drift
$ k get pods
NAME READY STATUS RESTARTS AGE
nginx-w88w29hu-6799fc88d8-kq4pp 1/1 Running 0 4m31s
nginx-w88w29hu-6799fc88d8-w4bvr 1/1 Running 0 5m32s
prehistoric-activity-61023
02/17/2022, 4:36 PMexpected state
(source code)
⢠state
(stored in Pulumi Service or custom backends)
⢠current state
(actual state of your infrastructure)pulumi up
= compare expected state
with state
and perform actions to sync them
pulumi refresh
= compare state
with current state
and allow to overwrite state
in case of differencespulumi refresh
can detect that deployment was removed but it doesnāt update replicaCount
(so if the deployment is scaled, it doesnāt see any changes) - let me try to repro thisbusy-journalist-6936
02/17/2022, 4:44 PMwonderful-portugal-96162
02/17/2022, 4:45 PMpulumi
prehistoric-activity-61023
02/17/2022, 4:46 PMpulumi new kubernetes-python
⢠pulumi up
-> it created a new deployment with one replica
⢠I changed the source code (increased number of replicas to 2)
⢠pulumi up
-> it scaled the deployment
⢠I manually descreased the number of replicas via: k scale deploy nginx-biohg2sj --replicas=1
⢠pulumi up
-> nothing to do here (expected)
⢠pulumi refresh
-> it properly detects that the actual state differs from what it thinks it should be š¤Type Name Plan Info
pulumi:pulumi:Stack pulumi_playground-dev
~ āā kubernetes:apps/v1:Deployment nginx update [diff: ~metadata,spec,status]
...
~ spec : {
progressDeadlineSeconds: 600
~ replicas : 2 => 1
...
refresh
action and do pulumi up
, itās gonna correct the drift.wonderful-portugal-96162
02/17/2022, 4:59 PMprehistoric-activity-61023
02/17/2022, 5:00 PMpulumi up
with additional env var?
PULUMI_K8S_ENABLE_DRY_RUN=true pulumi up
wonderful-portugal-96162
02/17/2022, 5:10 PMprehistoric-activity-61023
02/17/2022, 5:12 PMkubectly apply
, via kubectl edit
, via kubectl patch
).wonderful-portugal-96162
02/17/2022, 5:16 PMprehistoric-activity-61023
02/17/2022, 5:16 PMPULUMI_K8S_ENABLE_DRY_RUN
enables so called server-side diff and thatās why it can detect changes introduced locally (at least some of them?). AFAIK before that, a āmagic annotationā <http://kubectl.kubernetes.io/last-applied-configuration|kubectl.kubernetes.io/last-applied-configuration>
was used and thatās why some changes remain undetected (because they didnāt update this annotation).wonderful-portugal-96162
02/17/2022, 5:17 PMPULUMI_K8S_ENABLE_DRY_RUN
on the Pulumi Kubrentes Operator?prehistoric-activity-61023
02/17/2022, 5:17 PMbusy-journalist-6936
02/17/2022, 5:18 PMenableDryRun
BETA FEATURE - If present and set to true, enable server-side diff calculations
wonderful-portugal-96162
02/17/2022, 5:20 PMpulumi config set kubernetes:enableDryRun
busy-journalist-6936
02/17/2022, 5:23 PMpulumi config set \
--stack dev kubernetes:enableDryRun true
wonderful-portugal-96162
02/17/2022, 5:52 PM