---
title: "Web Application on Kubernetes"
description: "Deploy a web application to an existing Kubernetes cluster with Pulumi in TypeScript, Python, Go, C#, YAML, or HCL."
url: "https://www.pulumi.com/dev/templates/kubernetes-application/web-application/"
image: "https://www.pulumi.com/assets/og/dev/templates/kubernetes-application/web-application.png"
---

# Web Application on Kubernetes

Deploy a web application to an existing Kubernetes cluster with Pulumi in TypeScript, Python, Go, C#, YAML, or HCL.

The Kubernetes Web Application template scaffolds a Pulumi project that deploys a web application to an existing Kubernetes cluster using Pulumi's [Kubernetes provider](https://www.pulumi.com/registry/packages/kubernetes). 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.

![An architecture diagram of the Kubernetes Web Application template](./architecture.png)

## Using this template

To use this template, make sure you've already provisioned a [Kubernetes cluster](https://www.pulumi.com/dev/templates/kubernetes/), [installed Pulumi](https://www.pulumi.com/docs/install/) and [`kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl/), and [configured your kubeconfig file](https://www.pulumi.com/registry/packages/kubernetes/installation-configuration#setup). Then create a new [project](https://www.pulumi.com/docs/iac/concepts/projects/) using the template in the language of your choice:

**TypeScript**

```bash
mkdir my-k8s-app && cd my-k8s-app
pulumi new webapp-kubernetes-typescript
```

**Python**

```bash
mkdir my-k8s-app && cd my-k8s-app
pulumi new webapp-kubernetes-python
```

**Go**

```bash
mkdir my-k8s-app && cd my-k8s-app
pulumi new webapp-kubernetes-go
```

**C#**

```bash
mkdir my-k8s-app && cd my-k8s-app
pulumi new webapp-kubernetes-csharp
```

**YAML**

```bash
mkdir my-k8s-app && cd my-k8s-app
pulumi new webapp-kubernetes-yaml
```

**HCL**

```bash
mkdir my-k8s-app && cd my-k8s-app
pulumi new webapp-kubernetes-hcl
```

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.ts` 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`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_up):

```bash
$ pulumi up
```

When the deployment completes, Pulumi exports the following [stack output](https://www.pulumi.com/docs/iac/concepts/stacks/#outputs) values:

**TypeScript / Python / Go / C# / YAML**

**`deploymentName`**

The name of your new Kubernetes Deployment.

**`serviceName`**

The name of your new Kubernetes Service.

**HCL**

**`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](https://www.pulumi.com/docs/iac/concepts/config/) settings:

**TypeScript / Python / Go / C# / YAML**

**`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`.

**HCL**

**`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`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_config_set):

**TypeScript / Python / Go / C# / YAML**

```bash
$ pulumi config set replicas 3
$ pulumi up
```

**HCL**

```bash
$ pulumi config set num_replicas 3
$ pulumi up
```

## Cleaning up

You can cleanly destroy the stack and all of its infrastructure with [`pulumi destroy`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_destroy):

```bash
$ pulumi destroy
```

## Learn more

- Browse other architecture templates in the [Templates gallery](https://www.pulumi.com/templates).
- Explore the [Kubernetes provider API docs](https://www.pulumi.com/registry/packages/kubernetes) in the Pulumi Registry.
- Walk through Pulumi from the ground up in [Pulumi Tutorials](https://www.pulumi.com/dev/browse/?type=tutorial).
- Read the latest [Kubernetes posts on the Pulumi blog](https://www.pulumi.com/blog/tag/kubernetes).
