Skip to content
Securely manage Docker, Swarm, Kubernetes and Podman clusters in the cloud, on-premise, and in the data center.
Secure app deployment and device management for your Industrial IoT, IoT and Edge devices.
Let Portainer's Managed Platform Services accelerate your containerization journey.
Manage all your Docker, Swarm, Kubernetes and Podman clusters from a single secure interface.
Portainer empowers Platform Engineering teams to deliver efficient, user-centric services.
Empower your business by adopting containerization the easy way with Portainer.
Deploy to and manage your fleet of remote devices centrally and securely.
Onboard, manage and deploy workloads across hundreds of devices securely with Portainer.
Deployment scenarios
Partner Solutions
blog-banner
Adolfo DelorenzoMarch 18, 20211 min read

Deploy and Manage Traefik with Portainer on a Charmed Kubernetes cluster

In this post you will learn a basic deployment of the Traefik ingress controller on a Charmed Kubernetes cluster and how to use it with Portainer. Please make sure to check our blog post here on how to use Portainer on a Charmed Kubernetes cluster as it is a pre-req for this tutorial.

Assumptions:

  • You have a Charmed Kubernetes cluster deployed
  • You have access to your cluster via kubectl
  • You have helm installed
  • You have a wildcard domain name setup on your DNS server. Another option is to add each host used on your cluster to your DNS server.

Initial prep-work

Let's start with some initial prep-work to prepare your cluster so you can do a basic deployment of Traefik.

  1. Download the Traefik values.yaml file from their repository with the command :
    wget https://raw.githubusercontent.com/traefik/traefik-helm-chart/master/traefik/values.yaml
  2. Change the values.yaml file with sed so Traefik has access to ports 80 and 443:
    sed -i 's/\# hostPort: 8000/hostPort: 80/g' values.yaml sed -i 's/\# hostPort: 8443/hostPort: 443/g' values.yaml
  3. Add the Trafik repo to helm:
    helm repo add traefik https://helm.traefik.io/traefik helm repo update
  4. Remove the nginx-ingress-controller:
    kubectl delete namespace ingress-nginx-kubernetes-worker
  5. Deploy traefik:
    helm install traefik traefik/traefik -f values.yaml
  6. Access your Portainer instance via a ssh tunnel:
    juju ssh kubernetes-master/0 -L 30777:localhost:30777 -fN

Setup Portainer

  1. Go to Cluster->Setup and add the traefik ingress controller:

Adding an App

  1. Start by adding a Resource pool in order to deploy an app to be routed via traefik:


  2. In this tutorial we are going to deploy Caddy:


  3. Go to Applications->Add application and fill in the options for Caddy. Make sure to select the caddy resource pool that you created earlier:
  4. After selecting the appropriate options, the last step is to publish your app. At the end of the App creation you need to select:
    1. Ingress - Publish this application via the HTTP route
    2. Click on publish a new port
    3. Add the container port, in this case 80
    4. Add the route, in this case / (root path)
  5. After the app is deployed you can open the HTTP route configured in your resource pool to access Caddy:
  6. You will see the default Caddy first page in your browser window:

COMMENTS

Related articles