Kubernetes

Kubernetes is an open source project for running and managing containerized applications on a cluster of machines.

Pulumi is an infrastructure-as-code tool that exposes the Kubernetes resource API as an SDK, alongside other SDKs which span common cloud native utilities, cloud provider IaaS offerings, and their catalog of services - managed Kubernetes included.

Use Cases

The various SDKs allow Kubernetes users to leverage Pulumi for novel forms of cluster management, and deployment of app workloads to clusters. Users of Kubernetes and Pulumi can:

  • Instantiate IaaS resources and managed services from any cloud.
  • Provision managed Kubernetes clusters from the major cloud providers.
  • Provision self-managed (open source) Kubernetes clusters on top of raw IaaS resources or on-prem virtualization providers.
  • Create and orchestrate Kubernetes API resources for app workloads, in the programming language of their choice.
  • Manage real code instead of YAML, JSON, DSL’s, or tar archives of templates.
  • Apply standard software development practices to Kubernetes applications, including the use of functions, classes, loops, conditionals, etc.
  • Increase productivity using the power of dev tools such as IDE auto-completion, type & error checking, linting, refactoring, and testing frameworks to validate Kubernetes clusters, app workloads, or both.

Pulumi Kubernetes Provider

The Kubernetes provider for Pulumi can be used to provision any resources available in the Kubernetes API. The Kubernetes provider must be configured with a kubeconfig or other credentials to connect to a taret Kubernetes cluster.

See the full API documentation for complete details of the available Kubernetes provider APIs.

Setup

The Kubernetes provider supports several options for providing access to a Kubernetes cluster. See the Kubernetes setup page for details.

Getting Started

The quickest way to get started with Kubernetes is to follow the Get Started guide.

Additional Kubernetes tutorials are available covering:

  • Clusters on AWS, Azure and GCP
  • Workloads including Guestbook, Helm Charts, Stateless Apps, and more
  • Day Two Tasks including gated deployments and zero downtime upgrades
  • And many more examples and tutorials

Libraries

The following packages are available in package managers:

The Kubernetes provider is open source and available in the pulumi/pulumi-kubernetes repo.

Configuration

The Kubernetes provider accepts the following configuration settings. These can be provided to the default Kubernetes provider via pulumi config set kubernetes:<option>, or passed to the constructor of new kubernetes.Provider to construct a specific instance of the Kubernetes provider.

  • cluster: (Optional) If present, the name of the kubeconfig cluster to use.
  • context: (Optional) If present, the name of the kubeconfig context to use.
  • enableDryRun: (Optional) BETA FEATURE - If present and set to true, enable server-side diff calculations. This feature is in developer preview, and is disabled by default. This config can be specified in the following ways, using this precedence: (1) this enableDryRun parameter or (2) the PULUMI_K8S_ENABLE_DRY_RUN environment variable.
  • kubeconfig: (Optional) The contents of a kubeconfig file. If this is set, this config will be used instead of $KUBECONFIG.
  • namespace: (Optional) The contents of a kubeconfig file. If this is set, this config will be used instead of $KUBECONFIG.
  • renderYamlToDirectory: (Optional) BETA FEATURE - If present, render resource manifests to this directory. In this mode, resources will not be created on a Kubernetes cluster, but the rendered manifests will be kept in sync with changes to the Pulumi program. This feature is in developer preview, and is disabled by default. Note that some computed Outputs such as status fields will not be populated since the resources are not created on a Kubernetes cluster. These Output values will remain undefined, and may result in an error if they are referenced by other resources. Also note that any secret values used in these resources will be rendered in plain text to the resulting YAML.
  • suppressDeprecationWarnings: (Optional) If present and set to true, suppress apiVersion deprecation warnings from the CLI. This config can be specified in the following ways, using this precedence: (1) this suppressDeprecationWarnings parameter or (2) the PULUMI_K8S_SUPPRESS_DEPRECATION_WARNINGS environment variable.

Annotations

A few Pulumi-specific annotations can be applied to Kubernetes resources managed by Pulumi to control aspects of how Pulumi deploys and manages the Kubernetes resource:

  • pulumi.com/skipAwait: Disables Pulumi’s default await logic that waits for a Kubernetes resource to become “ready” before marking the resource as having created or updated succesfully.
  • pulumi.com/timeoutSeconds: Specifies the number of seconds that the Pulumi Kubernetes provider will wait for the resource to become “ready”.

In addition, the Pulumi provider may write the following annotations onto resources it manages:

  • pulumi.com/autonamed: Indicates that the Pulumi Kubernetes provider decided to autoname the resource (instead of using an explicitly provided metadata.name).

Additional Pulumi Packages for Kubernetes Users

For Cluster Management

The following SDKs are available to work with IaaS resources, and managed or self-managed Kubernetes clusters.

The packages are available in Node.js (Javascript and Typescript), Python, Go, and .NET.

Extension Packages

For Workload Management

The pulumi/kubernetes SDK is available to work with, and deploy app workloads to running Kubernetes clusters:

Extension Packages

Crosswalk for Kubernetes

Pulumi Crosswalk for Kubernetes is a collection of industry standard best-practices for managing Kubernetes, and its infrastructure in production.

Get started by deploying stacks of infrastructure architected to enable teams to run and manage Kubernetes in production.

Pulumi Kubernetes Operator

The Pulumi Kubernetes Operator is an extension pattern that enables Kuberentes users to create a Stack as a first-class API resource, and use the StackController to drive the updates of the Stack until success.

Deploying Pulumi Stacks in Kubernetes provides the capability to build out CI/CD and automation systems into your clusters, creating native support to manage your infrastructure alongside your Kubernetes workloads.

Get started with the Pulumi Kubernetes Operator in your continuous delivery pipelines.