How to use @pulumi/kubernetes - 10 common examples

To help you get started, we’ve selected a few @pulumi/kubernetes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pulumi / pulumi-kubernetes / tests / integration / yaml-url / step1 / index.ts View on Github external
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import * as k8s from "@pulumi/kubernetes";

// Create two test namespaces to allow test parallelism.
const namespace = new k8s.core.v1.Namespace("test-namespace");
const namespace2 = new k8s.core.v1.Namespace("test-namespace2");

function configFile(name: string, namespace: string, resourcePrefix?: string): k8s.yaml.ConfigFile {
    return new k8s.yaml.ConfigFile(name, {
        file: "https://raw.githubusercontent.com/pulumi/pulumi-kubernetes/master/tests/examples" +
            "/yaml-guestbook/yaml/guestbook.yaml",
        resourcePrefix: resourcePrefix,
        transformations: [
            (obj: any) => {
                if (obj !== undefined) {
                    if (obj.metadata !== undefined) {
                        obj.metadata.namespace = namespace;
                    } else {
                        obj.metadata = {namespace: namespace};
                    }
                }
github pulumi / pulumi-kubernetes / tests / examples / provider / index.ts View on Github external
// Copyright 2016-2018, Pulumi Corporation.  All rights reserved.

import * as k8s from "@pulumi/kubernetes";

// Create a new provider
const myk8s = new k8s.Provider("myk8s", {});

// Create a new provider with dry run enabled.
const myk8s2 = new k8s.Provider("myk8s2", {
    enableDryRun: true,
});

// Create a Pod using the custom provider
const nginxcontainer = new k8s.core.v1.Pod("nginx", {
    spec: {
        containers: [{
            image: "nginx:1.7.9",
            name: "nginx",
            ports: [{ containerPort: 80 }],
        }],
    },
}, { provider: myk8s });

// TODO(levi): Uncomment once https://github.com/pulumi/pulumi-kubernetes/issues/792 is fixed.
// // Create a Pod using the custom provider
github pulumi / pulumi-kubernetes / tests / examples / helm-local / index.ts View on Github external
function chart(resourcePrefix?: string): k8s.helm.v2.Chart {
    return new k8s.helm.v2.Chart("nginx-lego", {
        // Represents chart `stable/nginx-lego@v0.3.1`.
        path: "nginx-lego",
        version: "0.3.1",
        resourcePrefix: resourcePrefix,
        values: {
            // Override for the Chart's `values.yml` file. Use `null` to zero out resource requests so it
            // can be scheduled on our (wimpy) CI cluster. (Setting these values to `null` is the "normal"
            // way to delete values.)
            nginx: {resources: null},
            default: {resources: null},
            lego: {resources: null}
        },
        transformations: [
            // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of
            // LoadBalancer.
            (obj: any) => {
github pulumi / pulumi-kubernetes / tests / integration / istio / step1 / istio.ts View on Github external
"cluster-admin-binding",
    {
        metadata: { name: "cluster-admin-binding" },
        roleRef: {
            apiGroup: "rbac.authorization.k8s.io",
            kind: "ClusterRole",
            name: "cluster-admin"
        },
        subjects: [
            { apiGroup: "rbac.authorization.k8s.io", kind: "User", name: config.gcpUsername }
        ]
    },
    { provider: k8sProvider }
);

export const istio = new k8s.helm.v2.Chart(
    appName,
    {
        chart: "istio",
        namespace: namespace.metadata.name,
        version: "1.0.1",
        fetchOpts: { repo: "https://istio.io/charts/" },
        // for all options check https://github.com/istio/istio/tree/master/install/kubernetes/helm/istio
        values: { kiali: { enabled: true } }
    },
    { dependsOn: [namespace, adminBinding], providers: { kubernetes: k8sProvider } }
);
github pulumi / pulumi-kubernetes / tests / sdk / nodejs / examples / yaml-guestbook / index.ts View on Github external
// Copyright 2016-2018, Pulumi Corporation.  All rights reserved.

import * as k8s from "@pulumi/kubernetes";

// Create resources from standard Kubernetes guestbook YAML example.
const guestbook = new k8s.yaml.ConfigGroup("guestbook", { files: "yaml/*.yaml" });

// Export the (cluster-private) IP address of the Guestbook frontend.
export const frontendIp = guestbook.getResource("v1/Service", "frontend", "spec").clusterIP;
github pulumi / pulumi-kubernetes / tests / sdk / nodejs / aliases / step2 / index.ts View on Github external
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import * as k8s from "@pulumi/kubernetes";

//
// Force a rollout and ensure update completes successfully.
//

new k8s.yaml.ConfigFile("alias-test", {file: "manifests/av1DeploymentRollout.yaml"});
github pulumi / pulumi-kubernetes / tests / sdk / nodejs / get / step1 / index.ts View on Github external
const namespace = new k8s.core.v1.Namespace("test-namespace");

//
// `get`s the Kubernetes API service.
//

const svc = k8s.core.v1.Service.get("kube-api", "default/kubernetes");

// This will fail with a TypeError if the status was not populated (i.e. the .get isn't working)
export const loadBalancer = svc.status.loadBalancer;

//
// Create a CustomResourceDefinition, a CustomResource, and then `.get` it.
//

const ct = new k8s.apiextensions.v1beta1.CustomResourceDefinition("crontab", {
    metadata: { name: "crontabs.stable.example.com" },
    spec: {
        group: "stable.example.com",
        version: "v1",
        scope: "Namespaced",
        names: {
            plural: "crontabs",
            singular: "crontab",
            kind: "CronTab",
            shortNames: ["ct"]
        }
    }
});

new k8s.apiextensions.CustomResource(
    "my-new-cron-object",
github pulumi / pulumi-kubernetes / tests / sdk / nodejs / crds / step2 / index.ts View on Github external
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import * as k8s from "@pulumi/kubernetes";

const namespace = new k8s.core.v1.Namespace("test-namespace");

//
// Delete the CustomResourceDefinition. On the next refresh, the CustomResource will be
// automatically deleted from the state rather than returning a "kind not found" error.
// This is a contrived example for testing, and it doesn't make any sense to delete a
// CRD while leaving related CRs.
//

new k8s.apiextensions.CustomResource(
    "my-new-foobar-object",
    {
        apiVersion: "stable.example.com/v1",
        kind: "FooBar",
        metadata: {
            namespace: namespace.metadata.name,
            name: "my-new-foobar-object",
        },
        spec: { foo: "such amaze" }
    },
);
github pulumi / pulumi-kubernetes / tests / integration / get / step1 / index.ts View on Github external
import * as k8s from "@pulumi/kubernetes";

const namespace = new k8s.core.v1.Namespace("test-namespace");

//
// `get`s the Kubernetes API service.
//

k8s.core.v1.Service.get("kube-api", "default/kubernetes");

//
// Create a CustomResourceDefinition, a CustomResource, and then `.get` it.
//

const ct = new k8s.apiextensions.v1beta1.CustomResourceDefinition("crontab", {
    metadata: { name: "crontabs.stable.example.com" },
    spec: {
        group: "stable.example.com",
        version: "v1",
        scope: "Namespaced",
        names: {
            plural: "crontabs",
            singular: "crontab",
            kind: "CronTab",
            shortNames: ["ct"]
        }
    }
});

new k8s.apiextensions.CustomResource(
    "my-new-cron-object",
github pulumi / pulumi-kubernetes / tests / sdk / nodejs / crds / step1 / index.ts View on Github external
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import * as k8s from "@pulumi/kubernetes";

const namespace = new k8s.core.v1.Namespace("test-namespace");

//
// Create a CustomResourceDefinition and a CustomResource.
//

new k8s.apiextensions.v1beta1.CustomResourceDefinition("foobar", {
    metadata: { name: "foobars.stable.example.com" },
    spec: {
        group: "stable.example.com",
        version: "v1",
        scope: "Namespaced",
        names: {
            plural: "foobars",
            singular: "foobar",
            kind: "FooBar",
            shortNames: ["fb"]
        }
    }
});

new k8s.apiextensions.CustomResource(
    "my-new-foobar-object",

@pulumi/kubernetes

[![Build Status](https://travis-ci.com/pulumi/pulumi-kubernetes.svg?token=eHg7Zp5zdDDJfTjY8ejq&branch=master)](https://travis-ci.com/pulumi/pulumi-kubernetes) [![Slack](http://www.pulumi.com/images/docs/badges/slack.svg)](https://slack.pulumi.com) [![NPM

Apache-2.0
Latest version published 5 days ago

Package Health Score

92 / 100
Full package analysis