1. Answers
  2. Apply 'app=true' Label to a Kubernetes Namespace

How do I apply 'app=true' label to a Kubernetes namespace?

In this guide, we will demonstrate how to apply the label app=true to a Kubernetes namespace using Pulumi. Labels in Kubernetes are key/value pairs that are attached to objects such as pods, services, and namespaces. They are used to organize and select subsets of objects.

Key Points:

  • We will create a Kubernetes namespace.
  • We will apply the label app=true to this namespace.
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";

// Create a new Kubernetes namespace
const namespace = new k8s.core.v1.Namespace("example-namespace", {
    metadata: {
        name: "example-namespace",
        labels: {
            app: "true"  // Apply the 'app=true' label
        }
    }
});

// Export the namespace name
export const namespaceName = namespace.metadata.name;

Summary:

In this guide, we created a Kubernetes namespace and applied the label app=true to it using Pulumi. Labels help in organizing and managing Kubernetes resources effectively. The provided code block demonstrates how to define and apply a label to a namespace in Kubernetes using Pulumi.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up