Announcing Kustomize Support
Kubernetes is complex, and there are many ways to manage Kubernetes resources. Pulumi supports many of these options, including native code SDKs, YAML, Helm, and now, Kustomize. There's no need to rewrite your existing configurations to get started with Pulumi. You can efficiently adopt existing resources to deploy your modern application and save time and effort.
Over the past year, we've heard from many users that they'd like to manage Kustomize resources directly with Pulumi. The v2.4.0 release of our Kubernetes provider adds support for Kustomize to all of our SDKs (Go, TypeScript, .NET, Python). One of our primary goals at Pulumi is to meet users where they are. Our support for Kustomize, Helm, and YAML means that you don't have to "boil the ocean" to get started with Pulumi. The following examples show you how to get started with Pulumi and Kustomize today!
Working with local files
Let's see how to deploy a Kustomization from a local directory.
import * as k8s from "@pulumi/kubernetes";
new k8s.kustomize.Directory("helloWorldLocal", {
directory: "./helloWorld",
});
Working with git repos
We can also use Kustomizations directly from a git repository, local or remote, by specifying the path to the directory.
import * as k8s from "@pulumi/kubernetes";
new k8s.kustomize.Directory("helloWorldRemote", {
directory: "https://github.com/kubernetes-sigs/kustomize/tree/v3.3.1/examples/helloWorld",
});A better way to Kustomize
One of my favorite parts of Pulumi's Kubernetes SDK is the ability to apply transformations to resource definitions. This feature allows you to make changes to existing definitions before they are applied to a cluster. This saves the headache of forking an upstream repo just to make a few tweaks, and then trying to keep those changes in sync! Transformations are available for the Helm, Kustomize, and YAML SDKs.
INFO
Kustomize overlays can be used for a similar purpose, but require changing files in the directory. Transformations happen in memory, and are not persisted to disk. Keep both options in mind when you want to modify an existing configuration.
import * as k8s from "@pulumi/kubernetes";
new k8s.kustomize.Directory("helloWorldRemote", {
directory: "https://github.com/kubernetes-sigs/kustomize/tree/v3.3.1/examples/helloWorld",
transformations: [
(obj: any) => {
if (obj.kind === "Service") {
obj.spec.type = "ClusterIP"
}
}
]
});Learn More
If you'd like to learn about Pulumi and how to manage your infrastructure and Kubernetes through code, get started today. Pulumi is open source and free to use.
For further examples on how to use Pulumi to create Kubernetes clusters, or deploy workloads to a cluster, check out the rest of the Kubernetes tutorials.
As always, you can check out our code on GitHub, follow us on Twitter, subscribe to our YouTube channel, or join our Community Slack channel if you have any questions, need support, or just want to say hello.