# 3. Deploying Applications on Your K3s Cluster - Practical Examples

Once your K3s cluster is up and running, the next step is deploying applications. Whether you're experimenting with Kubernetes for the first time or testing production-ready workloads locally, K3s makes it simple and efficient. In this blog, we’ll walk through deploying a web application, adding a database service, and managing apps using Helm. By the end, you’ll have a solid understanding of deploying and monitoring applications on your K3s cluster.

---

## Preparing Your Environment

Before we dive into deploying applications, let’s ensure your environment is ready:

### Prerequisites

1. A functioning K3s cluster. (If you haven’t set one up yet, check out our guide on [Getting Started with K3s](https://chatgpt.com/g/g-QFqqnKe65-techblogai/c/679539df-5cdc-8009-9a9b-f28271768bea#).)
    
2. `kubectl` installed and configured to communicate with your cluster.
    
3. Basic familiarity with Kubernetes concepts (pods, deployments, services).
    
4. Optional: Install **Helm** (we’ll cover this later).
    

To verify your setup, run:

```bash
kubectl get nodes
```

You should see your K3s node(s) listed with a `STATUS` of `Ready`.

---

## Example Deployments

Let’s start with a simple example: deploying a web application and a database service alongside it.

### Deploying a Web Application

We’ll deploy a basic NGINX-based web app using a YAML manifest.

1. **Create a file named** `web-app.yaml`:
    

```yaml
apiVersion: apps/v1  
kind: Deployment  
metadata:  
  name: web-app  
  labels:  
    app: web-app  
spec:  
  replicas: 2  
  selector:  
    matchLabels:  
      app: web-app  
  template:  
    metadata:  
      labels:  
        app: web-app  
    spec:  
      containers:  
      - name: nginx  
        image: nginx:latest  
        ports:  
        - containerPort: 80  
---  
apiVersion: v1  
kind: Service  
metadata:  
  name: web-app-service  
spec:  
  selector:  
    app: web-app  
  ports:  
  - protocol: TCP  
    port: 80  
    targetPort: 80  
  type: LoadBalancer
```

2. **Apply the manifest:**
    

```bash
kubectl apply -f web-app.yaml
```

3. **Verify the deployment:**
    

```bash
kubectl get pods
```

You should see two pods running for the `web-app` deployment.

4. **Access the app:**  
    Find the external IP or port assigned to the `web-app-service` using:
    

```bash
kubectl get svc web-app-service
```

Access the web app in your browser or via `curl`.

---

### Adding a Database Service

Now, let’s add a database service (e.g., MySQL) to work alongside the web app.

1. **Create a file named** `mysql.yaml`:
    

```yaml
apiVersion: v1  
kind: PersistentVolumeClaim  
metadata:  
  name: mysql-pvc  
spec:  
  accessModes:  
    - ReadWriteOnce  
  resources:  
    requests:  
      storage: 1Gi  
---  
apiVersion: apps/v1  
kind: Deployment  
metadata:  
  name: mysql  
  labels:  
    app: mysql  
spec:  
  replicas: 1  
  selector:  
    matchLabels:  
      app: mysql  
  template:  
    metadata:  
      labels:  
        app: mysql  
    spec:  
      containers:
      - name: mysql
        image: mysql:8.0
        env:  
        - name: MYSQL_ROOT_PASSWORD  
          value: rootpassword  
        ports:  
        - containerPort: 3306  
        volumeMounts:  
        - mountPath: /var/lib/mysql  
          name: mysql-storage  
      volumes:  
      - name: mysql-storage  
        persistentVolumeClaim:  
          claimName: mysql-pvc  
---  
apiVersion: v1  
kind: Service  
metadata:  
  name: mysql  
spec:  
  ports:  
  - port: 3306  
  selector:  
    app: mysql  
  type: ClusterIP
```

2. **Apply the manifest:**
    

```bash
kubectl apply -f mysql.yaml
```

3. **Verify the deployment:**
    

```bash
kubectl get pods
```

Ensure the MySQL pod is running and its `STATUS` is `Running`.

Now your web app can connect to the MySQL service using the service name `mysql` and port `3306`.

---

## Using Helm Charts

K3s is fully compatible with Helm, a powerful Kubernetes package manager. Helm simplifies deploying and managing complex applications with reusable templates.

### Installing Helm

1. **Download Helm:**
    

```bash
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
```

2. **Verify installation:**
    

```bash
helm version
```

### Deploying Applications with Helm

Let's use Helm to deploy WordPress (a web app + database combo).

**Note:** As of August 2025, Bitnami Helm charts have been deprecated. We'll use community-maintained alternatives.

1. **Add the Helm repo:**


```bash
helm repo add presslabs https://presslabs.github.io/charts
helm repo update
```

2. **Install WordPress:**


```bash
helm install my-wordpress presslabs/wordpress-operator
```

Alternatively, you can use a custom WordPress setup with the mysql:8.0 deployment we created earlier.

3. **Check the status:**


```bash
helm status my-wordpress
```

4. **Access the application:**
    Get the external IP of the WordPress service:


```bash
kubectl get svc
```

Visit the IP in your browser to see your WordPress site in action.

---

## Monitoring and Managing Applications

Monitoring your applications is critical, even in a local environment. Here are a few tools and techniques for managing your K3s workloads:

### Using `kubectl` for Basic Monitoring

* Check pod status:
    
    ```bash
    kubectl get pods
    ```
    
* View pod logs:
    
    ```bash
    kubectl logs <pod-name>
    ```
    

### Adding Metrics with Prometheus and Grafana

**Note:** Since Bitnami charts are deprecated, we'll use community-maintained alternatives.

1. Deploy Prometheus and Grafana using Helm:


```bash
# Add prometheus-community repo
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update

# Install kube-prometheus-stack (includes both Prometheus and Grafana)
helm install prometheus prometheus-community/kube-prometheus-stack

# Alternatively, install Grafana separately
helm install grafana grafana/grafana
```

2. Access the Grafana dashboard and connect it to Prometheus as a data source for visualizing metrics.
    

---

## Conclusion

Deploying applications on K3s is not only straightforward but also versatile enough to handle a wide range of use cases. Whether you’re deploying simple web apps, integrating databases, or managing complex workloads with Helm, K3s provides the tools and simplicity to get the job done.

### What’s Next?

* Experiment with scaling your applications and using K3s in multi-node setups.
    
* Explore CI/CD pipelines for automating application deployments on your K3s cluster.
    
* Dive deeper into monitoring tools like Prometheus, Grafana, and Loki for a robust observability stack.
    

Have questions or cool deployment ideas? Let us know in the comments below!


