How do I build a Kubernetes core configmap with Pulumi?
To create a Kubernetes ConfigMap using Pulumi in TypeScript, you need to define the ConfigMap resource with the necessary metadata and data fields. A ConfigMap is used to store configuration data in key-value pairs. Below is an example of how to create a ConfigMap using Pulumi.
The following TypeScript code demonstrates how to create a ConfigMap in a Kubernetes cluster:
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
// Create a Kubernetes ConfigMap
const configMap = new k8s.core.v1.ConfigMap("example-configmap", {
metadata: {
name: "example-configmap",
namespace: "default",
},
data: {
"config-key-1": "config-value-1",
"config-key-2": "config-value-2",
},
});
// Export the name of the ConfigMap
export const configMapName = configMap.metadata.name;
In this example:
- We import the necessary Pulumi and Kubernetes packages.
- We create a new ConfigMap named
example-configmap
in the default namespace. - We define two key-value pairs in the
data
field of the ConfigMap. - We export the name of the ConfigMap for reference.
By running this Pulumi program, you will create a ConfigMap in your Kubernetes cluster with the specified configuration data. This example demonstrates how to manage Kubernetes resources using Pulumi’s infrastructure as code approach.
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.