Add example showing rollout triggered on ConfigMap data
ADD
kubernetes-ts-configmap-rollout/Pulumi.yaml
+name: configmap-rollout
+description: A Deployment that mounts a ConfigMap; updating the data in the ConfigMap triggers a rollout of the Deployment
+runtime: nodejs

ADD
kubernetes-ts-configmap-rollout/default.conf
+upstream node {
+ server pulumi.github.io;
+}
+server {
+ listen 80;
+ server_name _;
+ root /usr/share/nginx/html;
+ location / {
+ proxy_set_header X-Real-IP \$remote_addr;
+ proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
+ proxy_set_header Host pulumi.github.io;
+ proxy_pass http://node;
+ proxy_redirect off;
+ port_in_redirect off;
+ }
+}

ADD
kubernetes-ts-configmap-rollout/images/rollout.gif
kubernetes-ts-configmap-rollout/images/rollout.gif
Binary files /dev/null and b/kubernetes-ts-configmap-rollout/images/rollout.gif differ

ADD
kubernetes-ts-configmap-rollout/index.ts
+import * as fs from "fs";
+import * as pulumi from "@pulumi/pulumi";
+import * as k8s from "@pulumi/kubernetes";
+
+// Minikube does not implement services of type `LoadBalancer`; require the user to specify if we're
+// running on minikube, and if so, create only services of type ClusterIP.
+let config = new pulumi.Config("rolloutTest");
+let isMinikube = config.require("isMinikube");
+
+const appName = "nginx";
+const appLabels = { app: appName };
+
+// nginx Configuration data to proxy traffic to `pulumi.github.io`. Read from
+// `default.conf` file.
+const nginxConfig = new k8s.core.v1.ConfigMap(appName, {
+ metadata: { labels: appLabels },
+ data: { "default.conf": fs.readFileSync("default.conf").toString() }
+});
+const nginxConfigName = nginxConfig.metadata.apply(m => m.name);
+
+// Deploy 1 nginx replica, mounting the configuration data into the nginx
+// container.
+const nginx = new k8s.apps.v1beta1.Deployment(appName, {
+ metadata: { labels: appLabels },
+ spec: {
+ replicas: 1,
+ template: {
+ metadata: { labels: appLabels },
+ spec: {
+ containers: [
+ {
+ image: "nginx:1.13.6-alpine",
+ name: "nginx",
+ volumeMounts: [{ name: "nginx-configs", mountPath: "/etc/nginx/conf.d" }]
+ }
+ ],
+ volumes: [{ name: "nginx-configs", configMap: { name: nginxConfigName } }]
+ }
+ }
+ }
+});
+
+// Expose proxy to the public Internet.
+const frontend = new k8s.core.v1.Service(appName, {
+ metadata: { labels: nginx.spec.apply(spec => spec.template.metadata.labels) },
+ spec: {
+ type: isMinikube === "true" ? "ClusterIP" : "LoadBalancer",
+ ports: [{ port: 80, targetPort: 80, protocol: "TCP" }],
+ selector: appLabels
+ }
+});
+
+// Export the frontend IP.
+export let frontendIp: pulumi.Output<string>;
+if (isMinikube === "true") {
+ frontendIp = frontend.spec.apply(spec => spec.clusterIP);
+} else {
+ frontendIp = frontend.status.apply(status => status.loadBalancer.ingress[0].ip);
+}

ADD
kubernetes-ts-configmap-rollout/package.json
+{
+ "name": "configmap-rollout",
+ "devDependencies": {
+ "@types/node": "latest"
+ },
+ "dependencies": {
+ "@pulumi/pulumi": "latest",
+ "@pulumi/kubernetes": "latest"
+ }
+}

ADD
kubernetes-ts-configmap-rollout/tsconfig.json
+{
+ "compilerOptions": {
+ "outDir": "bin",
+ "target": "es6",
+ "lib": [
+ "es6"
+ ],
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "sourceMap": true,
+ "experimentalDecorators": true,
+ "pretty": true,
+ "noFallthroughCasesInSwitch": true,
+ "noImplicitAny": true,
+ "noImplicitReturns": true,
+ "forceConsistentCasingInFileNames": true,
+ "strictNullChecks": true
+ },
+ "files": [
+ "index.ts"
+ ]
+}

Add example showing rollout triggered on ConfigMap data