How to use the @pulumi/kubernetes.core function in @pulumi/kubernetes

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 / kubernetes-guides / aws / 03-cluster-configuration / index.ts View on Github external
})),
}, {
    providers: { kubernetes: cluster.provider},
});

// Create Kubernetes namespaces.
const clusterSvcsNamespace = new k8s.core.v1.Namespace("cluster-svcs", undefined, { provider: cluster.provider });
export const clusterSvcsNamespaceName = clusterSvcsNamespace.metadata.name;

const appSvcsNamespace = new k8s.core.v1.Namespace("app-svcs", undefined, { provider: cluster.provider });
export const appSvcsNamespaceName = appSvcsNamespace.metadata.name;

const appsNamespace = new k8s.core.v1.Namespace("apps", undefined, { provider: cluster.provider });
export const appsNamespaceName = appsNamespace.metadata.name;

const nginxNs = new k8s.core.v1.Namespace("ingress-nginx", {metadata: {name: "ingress-nginx"}}, { provider: cluster.provider});

// Create a resource quota in the apps namespace.
const quotaAppNamespace = new k8s.core.v1.ResourceQuota("apps", {
    metadata: {namespace: appsNamespaceName},
    spec: {
        hard: {
            cpu: "20",
            memory: "1Gi",
            pods: "10",
            replicationcontrollers: "20",
            resourcequotas: "1",
            services: "5",
        },
    }
},{
    provider: cluster.provider
github pulumi / pulumi-eks / nodejs / eks / dashboard.ts View on Github external
export function createDashboard(name: string, args: DashboardOptions, parent: pulumi.ComponentResource, k8sProvider: k8s.Provider) {
    // Deploy the latest version of the k8s dashboard.
    const dashboardYaml = [
        path.join(__dirname, "dashboard", "kubernetes-dashboard.yaml"),
        path.join(__dirname, "dashboard", "heapster.yaml"),
        path.join(__dirname, "dashboard", "influxdb.yaml"),
        path.join(__dirname, "dashboard", "heapster-rbac.yaml"),
    ].map(filePath => fs.readFileSync(filePath).toString());
    const dashboard = new k8s.yaml.ConfigGroup(`${name}-dashboard`, {
        yaml: dashboardYaml,
    }, { parent: parent, providers: { kubernetes: k8sProvider } });

    // Create a service account for admin access.
    const adminAccount = new k8s.core.v1.ServiceAccount(`${name}-eks-admin`, {
        metadata: {
            name: "eks-admin",
            namespace: "kube-system",
        },
    }, { parent: parent, provider: k8sProvider });

    // Create a role binding for the admin account.
    const adminRoleBinding = new k8s.rbac.v1.ClusterRoleBinding(`${name}-eks-admin`, {
        metadata: {
            name: "eks-admin",
        },
        roleRef: {
            apiGroup: "rbac.authorization.k8s.io",
            kind: "ClusterRole",
            name: "cluster-admin",
        },
github pulumi / pulumi-kubernetes / examples / nginx / index.ts View on Github external
app: "nginx",
        },
    },
    spec: {
        containers: [{
            image: "nginx:1.7.9",
            name: "nginx",
            ports: [{
                containerPort: 80,
            }],
        }],
    },
});

// Create an nginxvolume
let nginxvolume = new k8s.core.v1.PersistentVolume("redis", {
    metadata: {
        name: "nginxvolume"
    },
    spec: {
        capacity: {
            storage: "10Gi",
        },
        accessModes: ["ReadWriteMany"],
        gcePersistentDisk: {
            pdName: "test-123",
        },
    },
});

// create a redis pod
let redispod = new k8s.core.v1.Pod("redis", {
github pulumi / kubernetes-guides / gcp / 05-app-services / index.ts View on Github external
});

// Configure a new SQL user.
const user = new gcp.sql.User("default", {
    project: config.project,
    instance: db.name,
    password: postgresDbPassword,
});

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

// Create a Secret from the DB connection information.
const dbConn = new k8s.core.v1.Secret(
    "postgres-db-conn",
    {
        data: {
            host: db.privateIpAddress.apply(addr => Buffer.from(addr).toString("base64")),
            port: Buffer.from("5432").toString("base64"),
            username: user.name.apply(user => Buffer.from(user).toString("base64")),
            password: postgresDbPassword.apply(pass => Buffer.from(pass).toString("base64")),
        },
    },
    { provider: provider },
);

// Create a Redis instance.
const cache = new gcp.redis.Instance("redis", {
    tier: "STANDARD_HA",
    memorySizeGb: 1,
github pulumi / examples / aws-ts-eks-migrate-nodegroups / nginx.ts View on Github external
export function createService(
    name: string,
    args: NginxServiceArgs,
): k8s.core.v1.Service {
    const ENABLE_DRAINING: pulumi.Input<{[key: string]: pulumi.Input}> = {
        "service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled": "true",
    };
    const ENABLE_DRAINING_TIMEOUT: pulumi.Input<{[key: string]: pulumi.Input}> = {
        "service.beta.kubernetes.io/aws-load-balancer-connection-draining-timeout": "60",
    };
    return new k8s.core.v1.Service(
        name,
        {
            metadata: {
                // NGINX service name is fixed vs auto-named & ref'd in order for
                // nginx-ing-cntlr arg --publish-service to work.
                name: name,
                labels: args.labels,
                namespace: args.namespace,
                annotations: {
                    ...ENABLE_DRAINING,
                    ...ENABLE_DRAINING_TIMEOUT,
                },
            },
            spec: {
                type: "LoadBalancer",
                ports: [{port: 80, protocol: "TCP", targetPort: "http"}],
github pulumi / examples / kubernetes-ts-jenkins / jenkins.ts View on Github external
constructor(args: JenkinsArgs, opts?: pulumi.ResourceOptions) {
        super("jenkins:jenkins:Instance", args.name, args, opts);

        // The Secret will contain the root password for this instance.
        const secret = new k8s.core.v1.Secret(`${args.name}-secret`, {
            metadata: {
                name: args.name,
            },
            type: "Opaque",
            data: {
                "jenkins-password": Buffer.from(args.credentials.password).toString("base64"),
            },
        }, { parent: this });

        // The PVC provides persistent storage for Jenkins state.
        const pvc = new k8s.core.v1.PersistentVolumeClaim(`${args.name}-pvc`, {
            metadata: {
                name: args.name,
                annotations: {
                    "volume.beta.kubernetes.io/storage-class": `${args.storageClass || "standard" }`,
                },
            },
            spec: {
                accessModes: ["ReadWriteOnce"],
                resources: {
                    requests: {
                        storage: "8Gi",
                    },
                },
            },
        }, { parent: this });
github pulumi / examples / gcp-ts-gke-hello-world / index.ts View on Github external
},
                    ],
                },
            },
        },
    },
    {
        provider: clusterProvider,
    },
);

// Export the Deployment name
export const deploymentName = deployment.metadata.name;

// Create a LoadBalancer Service for the NGINX Deployment
const service = new k8s.core.v1.Service(name,
    {
        metadata: {
            labels: appLabels,
            namespace: namespaceName,
        },
        spec: {
            type: "LoadBalancer",
            ports: [{ port: 80, targetPort: "http" }],
            selector: appLabels,
        },
    },
    {
        provider: clusterProvider,
    },
);
github pulumi / pulumi-kubernetes / tests / sdk / nodejs / examples / helm-skip-crd-rendering / step1 / index.ts View on Github external
import * as k8s from "@pulumi/kubernetes";

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

new k8s.helm.v3.Chart("skip-crd-rendering", {
  skipCRDRendering: true,
  namespace: namespace.metadata.name,
  path: "helm-skip-crd-rendering",
});

new k8s.helm.v3.Chart("allow-crd-rendering", {
  skipCRDRendering: false,
  namespace: namespace.metadata.name,
  path: "helm-allow-crd-rendering",
});
github pulumi / examples / aws-ts-eks-migrate-nodegroups / echoserver.ts View on Github external
export function createService(
    name: string,
    args: EchoserverServiceArgs,
): k8s.core.v1.Service {
    return new k8s.core.v1.Service(
        name,
        {
            metadata: {
                labels: args.labels,
                namespace: args.namespace,
            },
            spec: {
                type: "ClusterIP",
                ports: [{port: 80, protocol: "TCP", targetPort: "http"}],
                selector: args.labels,
            },
        },
        {
            provider: args.provider,
        },
    );

@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 16 days ago

Package Health Score

92 / 100
Full package analysis