How do I provision a Kubernetes ConfigMap patch?
In this example, we will provision a Kubernetes ConfigMap patch using Pulumi. A ConfigMap allows you to decouple configuration artifacts from image content to keep containerized applications portable. We will create a ConfigMap and then apply a patch to it.
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
// Define a namespace
const namespace = new k8s.core.v1.Namespace("example-namespace", {
metadata: {
name: "example-namespace",
},
});
// Create a ConfigMap
const configMap = new k8s.core.v1.ConfigMap("example-configmap", {
metadata: {
namespace: namespace.metadata.name,
name: "example-configmap",
},
data: {
"key1": "value1",
"key2": "value2",
},
});
// Patch the ConfigMap
const configMapPatch = new k8s.core.v1.ConfigMapPatch("example-configmap-patch", {
metadata: {
namespace: namespace.metadata.name,
name: configMap.metadata.name,
},
data: {
"key2": "new-value2",
"key3": "value3",
},
}, { dependsOn: configMap });
Key Points
- We define a namespace to organize our resources.
- We create a ConfigMap with initial key-value pairs.
- We apply a patch to the ConfigMap to update an existing key and add a new key.
Summary
In this example, we provisioned a Kubernetes ConfigMap and applied a patch to it using Pulumi. This allows you to manage and update configurations dynamically in a Kubernetes cluster.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.