Skip to content

Step-By-Step Guide: Installing Nginx Ingress on K3s Pi 4 Cluster

Posted on:September 16, 2023 at 12:00 AM

In our previous article, we successfully set up a k3s Pi cluster. We will now build upon that foundation. Let’s dive in!

Router Port Forwarding Setup.

In order to make the internal applications accessible via the internet, we need to set up port forwarding on our router. This routing process will redirect internet requests coming to ports 80 and 443 to our master private IP node (

Please note, the configuration interface may vary among different routers. Nonetheless, most broadband routers should offer the same functionality pertaining to port forwarding.

Here are my current router settings.

Nginx installation

We’re going to start by installing Nginx on our cluster. In the following guide, we will illustrate how to set up and run Nginx on K3s. At its core, Nginx will listen to inbound requests on the master node’s IP address and subsequently forward these requests to the services operating within our cluster.

1. Config Ip address

Helm charts come with a file called values.yaml which contains the default configuration values. We can override these values by creating your own values.yaml file. Here is an example:

    # Our master node ip address here.
    # Do remember replacing this ip address with your once accordingly.
    loadBalancerIP: ""

2. Download the Helm chart:

Download the Nginix helm chart. You can do this by adding the Nginx repo to the Helm. Run the following commands:

helm repo add nginx-stable
helm repo update

3. Create namespace

kubectl create namespace nginx-ingress

4. Install the Helm chart:

Now you can install the Helm chart using your custom values.yaml file to override the default configuration values. Run the following command:

helm install nginx nginx-stable/nginx-ingress --values values.yaml -n nginx-ingress

5. Verify nginx pod:

After installed successfully, we should be able to find a pod running there: nginx-installed-successfully.png

Nginx Verification

1. Deploy the echo application:

You can deploy an echo server application using a simple Kubernetes deployment and service. The echo server will respond with the same request it receives.

Here is a sample YAML file you can use:

apiVersion: apps/v1
kind: Deployment
  name: echo-deployment
  namespace: default
  replicas: 1
      app: echo
        app: echo
        - name: echo
          image: ealen/echo-server
            - containerPort: 80
apiVersion: v1
kind: Service
  name: echo-service
  namespace: default
    - port: 80
    app: echo

Save this YAML into a file, let’s say echo-app.yaml, and apply it to default namespace (using default namespace in Production is not recommended):

kubectl apply -f echo-app.yaml -n default
  1. Create an ingress rule:

Now that your echo server is running, you can create an ingress rule to route traffic to it.

Here is a sample ingress YAML:

kind: Ingress
  name: echo-ingress
  namespace: default
  ingressClassName: nginx
    # Replace the domain below with your domain accordingly.
    - host:
          - pathType: Prefix
            path: "/"
                name: echo-service
                  number: 80

3. Update your domain DNS

To ensure you can access from the internet, you need to point a domain to your public address.

Here is my DNS configuration on Cloudflare for reference purposes. drunkcoding-cloudflare-dns.png

After all these configurations now we should be able to access your application hosting on our k3s cluster from the internet. When accessing to you able to see the JSON response from the echo pod as below.


Thank you so much for your time, Really appreciate it!

Steven GitHub