Lately, in my home lab, I have been deploying applications into a K3S cluster. While K3S does not come with a built-in dashboard, I was looking for a solution that would provide a graphical user interface for managing my cluster. I came across Portainer, a lightweight, open-source container management platform that supports a variety of container orchestration platforms, including K3S.

Deploying Portainer into your kubernetes cluster is quite easy and simple. You just need to apply the below yaml file:

kubectl apply -n portainer -f \
https://downloads.portainer.io/ce2-19/portainer.yaml

The above command will expose portainer using NodePort on 30777 for HTTP and 30779 for HTTPS

The official doco can be found here

As I wanted to expose Portainer using Traefik Ingress,

  1. Deleted the existing service
kubectl delete svc portainer -n portainer
  1. Create a service of type ClusterIP
apiVersion: v1
kind: Service
metadata:
  name: portainer
  namespace: portainer
  labels:
    io.portainer.kubernetes.application.stack: portainer
    app.kubernetes.io/name: portainer
    app.kubernetes.io/instance: portainer
    app.kubernetes.io/version: "ce-latest-ee-2.19.1"
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: 9000
      protocol: TCP
      name: http
    - port: 443
      targetPort: 9443
      protocol: TCP
      name: https
    - port: 30776
      targetPort: 30776
      protocol: TCP
      name: edge
  selector:
    app.kubernetes.io/name: portainer
    app.kubernetes.io/instance: portainer
  1. Create a new Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: portainer-ingress
  namespace: portainer
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
  rules:
  - host: portainer.zion 
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: portainer
            port: 
              number: 80