Package: pulumi-kubernetes
Pulumi Kubernetes Resource ProviderThe Kubernetes resource provider for Pulumi lets you create, deploy, and manage Kubernetes API resources and workloads in a running cluster. For a streamlined Pulumi walkthrough, including language runtime installation and Kubernetes configuration, select "Get Started" below.IntroductionKubernetes API Version SupportHow does API support for Kubernetes work?ReferencesPrerequisitesInstallingQuick ExamplesDeploying a YAML ManifestDeploying a Helm ChartDeploying a Workload using the Resource APIContributingCode of ConductIntroductionpulumi-kubernetesprovides an SDK to create any of the API resources
available in Kubernetes.This includes the resources you know and love, such as:DeploymentsReplicaSetsConfigMapsSecretsJobs etc.Kubernetes API Version SupportThepulumi-kubernetesSDK closely tracks the latest upstream release, and provides access
to the full API surface, including deprecated endpoints.
The SDK API is 100% compatible with the Kubernetes API, and is
schematically identical to what Kubernetes users expect.We support Kubernetes clusters with version >=1.9.0.How does API support for Kubernetes work?Pulumi’s Kubernetes SDK is manufactured by automatically wrapping our
library functionality around the Kubernetes resourceOpenAPI
specas soon as a
new version is released! Ultimately, this means that Pulumi users do not have
to learn a new Kubernetes API model, nor wait long to work with the latest
available versions.Note: Pulumi also supports alpha and beta APIs.Visit theFAQfor more details.ReferencesReference DocumentationAPI DocumentationNode.js APIPython APIAll ExamplesHow-to GuidesPrerequisitesInstall Pulumi.Install a language runtime such asNode.js,Pythonor.NET.Install a package managerFor Node.js, useNPMorYarn.For Python, usepip.For .NET, use Nuget which is integrated with thedotnetCLI.Have access to a running Kubernetes clusterIfkubectlalready works for your running cluster, Pulumi respects and uses this configuration.If you do not have a cluster already running and available, we encourage you to
explore Pulumi's SDKs for AWS EKS, Azure AKS, and GCP GKE. Visit theAPI reference docs in the Pulumi Registryfor more details.Installkubectl.InstallingThis package is available in many languages in the standard packaging formats.For Node.js use eithernpmoryarn:npm:npminstall@pulumi/kubernetesyarn:yarnadd@pulumi/kubernetesFor Python usepip:pipinstallpulumi-kubernetesFor .NET, dependencies will be automatically installed as part of your Pulumi deployments usingdotnet build.To use from Go, usego installto grab the latest version of the library$ go install github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes@latestQuick ExamplesThe following examples demonstrate how to work withpulumi-kubernetesin
a couple of ways.Examples may include the creation of an AWS EKS cluster, although an EKS cluster
isnotrequired to usepulumi/kubernetes. It is simply used to ensure
we have access to a running Kubernetes cluster to deploy resources and workloads into.Deploying a YAML ManifestThis example deploys resources from a YAML manifest file path, using the
transient, defaultkubeconfigcredentials on the local machine, just askubectldoes.import*ask8sfrom"@pulumi/kubernetes";constmyApp=newk8s.yaml.ConfigFile("app",{file:"app.yaml"});Deploying a Helm ChartThis example creates an EKS cluster withpulumi/eks,
and then deploys a Helm chart from the stable repo using thekubeconfigcredentials from the cluster'sPulumi provider.import*aseksfrom"@pulumi/eks";import*ask8sfrom"@pulumi/kubernetes";// Create an EKS cluster.constcluster=neweks.Cluster("my-cluster");// Deploy Wordpress into our cluster.constwordpress=newk8s.helm.v3.Chart("wordpress",{repo:"stable",chart:"wordpress",values:{wordpressBlogName:"My Cool Kubernetes Blog!",},},{providers:{"kubernetes":cluster.provider}});// Export the cluster's kubeconfig.exportconstkubeconfig=cluster.kubeconfig;Deploying a Workload using the Resource APIThis example creates a EKS cluster withpulumi/eks,
and then deploys an NGINX Deployment and Service using the SDK resource API, and thekubeconfigcredentials from the cluster'sPulumi provider.import*aseksfrom"@pulumi/eks";import*ask8sfrom"@pulumi/kubernetes";// Create an EKS cluster with the default configuration.constcluster=neweks.Cluster("my-cluster");// Create a NGINX Deployment and Service.constappName="my-app";constappLabels={appClass:appName};constdeployment=newk8s.apps.v1.Deployment(`${appName}-dep`,{metadata:{labels:appLabels},spec:{replicas:2,selector:{matchLabels:appLabels},template:{metadata:{labels:appLabels},spec:{containers:[{name:appName,image:"nginx",ports:[{name:"http",containerPort:80}]}],}}},},{provider:cluster.provider});constservice=newk8s.core.v1.Service(`${appName}-svc`,{metadata:{labels:appLabels},spec:{type:"LoadBalancer",ports:[{port:80,targetPort:"http"}],selector:appLabels,},},{provider:cluster.provider});// Export the URL for the load balanced service.exportconsturl=service.status.loadBalancer.ingress[0].hostname;// Export the cluster's kubeconfig.exportconstkubeconfig=cluster.kubeconfig;ContributingIf you are interested in contributing, please see thecontributing docs.Code of ConductYou can read the code of conducthere.