Pulumi Kubernetes Provider

4.28.0 · active · verified Mon Apr 13

pulumi-kubernetes is a Pulumi package for creating and managing Kubernetes resources using Python, allowing Infrastructure as Code deployments. It is currently at version 4.28.0 and follows a regular release cadence, often aligning with new Kubernetes API versions and Pulumi core updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a basic Kubernetes Namespace resource using the Pulumi Kubernetes provider. It sets up a new namespace and exports its name. Ensure your kubeconfig is correctly set up for Pulumi to access your Kubernetes cluster.

import pulumi
import pulumi_kubernetes as kubernetes

# Create a Kubernetes Namespace
my_namespace = kubernetes.core.v1.Namespace(
    "my-namespace",
    metadata={
        "name": "test-ns-from-pulumi",
        "labels": {"environment": "dev"}
    }
)

# Export the name of the namespace
pulumi.export("namespace_name", my_namespace.metadata["name"])

# To run: 
# 1. Ensure KUBECONFIG is set or your ~/.kube/config is configured.
# 2. pulumi new python --dir my-k8s-project
# 3. cd my-k8s-project
# 4. pip install pulumi-kubernetes
# 5. Replace __main__.py content with this code.
# 6. pulumi up

view raw JSON →