> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neterial.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy App to k8s

> Deploy an application to Kubernetes using kubectl

Deploy a simple nginx app using Kubernetes manifests. This verifies your cluster is working and shows the kubectl workflow.

## Prerequisites

Complete [Getting Started](/index) steps 1-5 to set up CLI and create a VM.

## Get your workload hostname

```sh theme={null}
neterial infra get workload-hostname
```

Save this value - you'll need it for the Ingress configuration.

## Create the manifest

Create a file named `web-app.yaml` with the following content, or [download it here](/guides/web-app.yaml.txt).

Replace `<your-workload-hostname>` with your actual hostname from the previous step.

```yaml theme={null}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
    spec:
      containers:
      - name: web-app
        image: nginx
        command:
          - /bin/sh
          - -c
          - "echo 'Hello from k8s!' > /usr/share/nginx/html/index.html && nginx -g 'daemon off;'"
---
apiVersion: v1
kind: Service
metadata:
  name: web-app
spec:
  selector:
    app: web-app
  ports:
  - port: 80
    targetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web-app
  annotations:
    kubernetes.io/ingressClassName: "traefik"
    traefik.ingress.kubernetes.io/router.entrypoints: web,websecure
    traefik.ingress.kubernetes.io/router.tls.certresolver: default
    traefik.ingress.kubernetes.io/router.tls: "true"
spec:
  rules:
    - host: "web-app.<your-workload-hostname>"
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web-app
                port:
                  number: 80
```

## Deploy

```sh theme={null}
kubectl apply -f web-app.yaml
```

## Verify

Check the deployment is ready:

```sh theme={null}
kubectl get deployment web-app
```

Get your app URL:

```sh theme={null}
kubectl get ingress web-app -o jsonpath='{.spec.rules[0].host}'
```

Open `https://<hostname>` in your browser. You should see:

> Hello from k8s!

TLS certificate is provisioned automatically (may take a minute).

## Clean up

```sh theme={null}
kubectl delete -f web-app.yaml
```
