Web Application on Kubernetes
The Kubernetes Web Application template scaffolds a Pulumi project that deploys a web application to an existing Kubernetes cluster using Pulumi’s Kubernetes provider. The template creates a new namespace, a Deployment to run the application, and a Service that exposes it outside the cluster. It ships with placeholder app content so the project deploys end to end out of the box.


Using this template#
To use this template, make sure you’ve already provisioned a Kubernetes cluster, installed Pulumi and kubectl, and configured your kubeconfig file. Then create a new project using the template in the language of your choice:
mkdir my-k8s-app && cd my-k8s-apppulumi new webapp-kubernetes-typescriptAlternatively, you can create and configure a new project with this template (webapp-kubernetes-typescript) in Pulumi Cloud.
mkdir my-k8s-app && cd my-k8s-apppulumi new webapp-kubernetes-pythonAlternatively, you can create and configure a new project with this template (webapp-kubernetes-python) in Pulumi Cloud.
mkdir my-k8s-app && cd my-k8s-apppulumi new webapp-kubernetes-goAlternatively, you can create and configure a new project with this template (webapp-kubernetes-go) in Pulumi Cloud.
mkdir my-k8s-app && cd my-k8s-apppulumi new webapp-kubernetes-csharpAlternatively, you can create and configure a new project with this template (webapp-kubernetes-csharp) in Pulumi Cloud.
mkdir my-k8s-app && cd my-k8s-apppulumi new webapp-kubernetes-yamlAlternatively, you can create and configure a new project with this template (webapp-kubernetes-yaml) in Pulumi Cloud.
mkdir my-k8s-app && cd my-k8s-apppulumi new webapp-kubernetes-hclAlternatively, you can create and configure a new project with this template (webapp-kubernetes-hcl) in Pulumi Cloud.
Follow the prompts to complete the new-project wizard. When it’s done, you’ll have a complete Pulumi project that’s ready to deploy and configured with the most common settings. Feel free to inspect the code in index.tsindex.js__main__.pymain.goProgram.csProgram.fsProgram.vbApp.javaPulumi.yaml for a closer look.
Deploying the project#
The template requires no additional configuration. By default, it will deploy an Nginx container. Once the new project is created, you can deploy it with pulumi up:
pulumi upWhen the deployment completes, Pulumi exports the following stack output values:
- deploymentName
The name of your new Kubernetes Deployment.
- serviceName
The name of your new Kubernetes Service.
- deploymentName
The name of your new Kubernetes Deployment.
- serviceName
The name of your new Kubernetes Service.
- deploymentName
The name of your new Kubernetes Deployment.
- serviceName
The name of your new Kubernetes Service.
- deploymentName
The name of your new Kubernetes Deployment.
- serviceName
The name of your new Kubernetes Service.
- deploymentName
The name of your new Kubernetes Deployment.
- serviceName
The name of your new Kubernetes Service.
- deployment_name
The name of your new Kubernetes Deployment.
- service_name
The name of your new Kubernetes Service.
Output values like these are useful in many ways, most commonly as inputs for other stacks or related cloud resources.
Customizing the project#
Projects created with the Kubernetes Application template expose the following configuration settings:
- namespace
The name of the namespace to be created in your existing cluster. Defaults to
default.- replicas
The number of replicated Pods to be created in your new Deployment. Defaults to
1.
- namespace
The name of the namespace to be created in your existing cluster. Defaults to
default.- replicas
The number of replicated Pods to be created in your new Deployment. Defaults to
1.
- namespace
The name of the namespace to be created in your existing cluster. Defaults to
default.- replicas
The number of replicated Pods to be created in your new Deployment. Defaults to
1.
- namespace
The name of the namespace to be created in your existing cluster. Defaults to
default.- replicas
The number of replicated Pods to be created in your new Deployment. Defaults to
1.
- namespace
The name of the namespace to be created in your existing cluster. Defaults to
default.- replicas
The number of replicated Pods to be created in your new Deployment. Defaults to
1.
- k8s_namespace
The name of the namespace to be created in your existing cluster. Defaults to
webapp.- num_replicas
The number of replicated Pods to be created in your new Deployment. Defaults to
1.
All of these settings are optional and may be adjusted either by editing the stack configuration file directly (by default, Pulumi.dev.yaml) or by changing their values with pulumi config set:
pulumi config set replicas 3pulumi uppulumi config set replicas 3pulumi uppulumi config set replicas 3pulumi uppulumi config set replicas 3pulumi uppulumi config set replicas 3pulumi uppulumi config set num_replicas 3pulumi upCleaning up#
You can cleanly destroy the stack and all of its infrastructure with pulumi destroy:
pulumi destroyLearn more#
- Browse other architecture templates in the Templates gallery.
- Explore the Kubernetes provider API docs in the Pulumi Registry.
- Walk through Pulumi from the ground up in Pulumi Tutorials.
- Read the latest Kubernetes posts on the Pulumi blog.