hello, we have a use case in which the configmap h...
# kubernetes
m
hello, we have a use case in which the configmap has been set to auto naming and deleteBeforeReplace is also set to false, AND the value of the data is retrieved from pulumi.all and not sure if it is for this reason, Pulumi would think that there's a change in the data of the configmap and it always delete the old configmap and create a new one. As such, it creates a cascading effect like force replacement of the kubernetes job or deployment that rely on the configmap. Is there a way to avoid Pulumi from thinking that there's change in data when we use pulumi.all to retrieve the values?
a
I’m not a kubernetes expert, but using an output combinator like
pulumi.all
should have no effect on if a resource needs to be updated/replaced. If you could show some example code, I’d be happy to help diagnose the problem, or escalate to someone more familiar with the area.
m
Copy code
const dNSRecordSet = new GoogleDnsRecordSetComponent('app', {
            gcpProjectName: props.gcpProjectName,
        },{
            parent: this,
        });

        const appConfig = pulumi
        .all([
            dNSRecordSet.cdnAddress,
        ])
        .apply(
            ([
                cdnAddress,
            ]) =>
                JSON.stringify({
                    key: {
                        value1: cdnAddress,
                        value2: String(new Date().getTime()),
                    }
                })
        );


        const jobConfigmapData = {};
		jobConfigmapData[`config.${props.environment}.json`] = appConfig;

		const jobConfigmap = new k8s.core.v1.ConfigMap(
			'job-configmap',
			{
				metadata: {
					namespace: props.namespace,
				},
				data: jobConfigmapData,
			},
			{
				parent: this,
				provider: props.clusterProvider,
				deleteBeforeReplace: false,
			}
		);
something like this, I think the problem is the data is depending on the current date time, each time when Pulumi run the plan, the configmap data will then be updated. I thought configmap data can be updated on the fly in Kubernetes without deleting and recreating it
a
Yeah, if
appConfig
depends on the current time, then everything that depends on it will require an update each time you run
pulumi up
. Its up to
k8s.core.v1.ConfigMap
to decide if that change can be done in place (update) or needs a replacement. P.S. From the example you have, you don’t need the
pulumi.all
. You can just apply on the
dNSRecordSet.cdnAddress
.
m
noted, is there a way to avoid the configmap from being recreated?
a
There is a provider option in beta called
<https://www.pulumi.com/registry/packages/kubernetes/api-docs/provider/#enableconfigmapmutable_yaml|enableConfigMapMutable>
.
m
so just add that environment variable in the runtime?
a
That should do it.
m
can I set the name of the configmap? or it has to be auto rename?
b
can you show a diff of when this replace happens?
m
currently I have it auto rename and set deleteBeforeReplace to false and enabled the new environment variable PULUMI_K8S_ENABLE_CONFIGMAP_MUTABLE in my runtime, but the latest plan is still trying to delete and recreate the configmap
the difference is still in the data, which takes the value of the current time at runtime
b
Pulumi would think that there’s a change in the data of the configmap and it always delete the old configmap and create a new one
i’d like to see what Pulumi thinks is changing. If the data is changing, it will obviously replace the config map
m
Copy code
~ data: {
              ~ config.staging.json: (json) {
                  ~ key: {
                        value*****: "34.*****60.84.6"
                      ~ value2: "*****67***************[38;5;*****m8005567" => "*****67***************9766826"
                    }
                }
            }
@ previewing update....
some of the value is masked but basically they are just timestamp
b
ah, so you’re trying to use the
enableConfigMapMutable
option, now I understand
can you file an issue please? looks like that isn’t working as expected
m
does it intend to work for configmap without auto naming (aka fix name)?