Deploy and Manage Traefik with Portainer on a Charmed Kubernetes cluster

by Adolfo Delorenzo, on March 18, 2021

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:

 

Interested in running Portainer in a business environment?

Portainer Business is our fully featured, fully supported business product. It is used by some of the largest organizations in the world to deliver a powerful self-service container management experience for developers and IT teams. With more than 500,000 active users, Portainer is proven to be the simplest and most effective way of managing Docker, Swarm, and Kubernetes environments.

GET 5 NODES OF PORTAINER BUSINESS FREE

Topics:kubernetesSecurityPartner

Comments