73 lines
3.3 KiB
Plaintext
73 lines
3.3 KiB
Plaintext
Hello, Adolfo from Portainer here
|
|
|
|
In this video I want to show a basic deployment of the traefik ingress controller on a Charmed Kubernetes cluster and how to use it with Portainer.
|
|
|
|
We have a video on how to deploy Portainer on a Charmed Kubenetes cluster that you can watch here and that I highly recommended as it is a pre-req for this tutorial.
|
|
|
|
Charmed Kubernetes comes with a default nginx-ingress controller that uses ports 80 and 443 that are commonly used to access websites, apps and APIs over the internet.
|
|
|
|
Traefik also requires that these ports are available so in this exercise I am going to remove the default nginx-ingress controller. You could have both running on your cluster but that would require more complex configuration of firewall rules that can vary from one cluster environment or cloud provider to another.
|
|
|
|
I am assuming that you have your Portainer deployed already on your Charmed Kubernetes and has access to the cluster via kubectl. helm is also required to deploy traefik so make sure you have this command installed also. It is avaliable via snap.
|
|
|
|
snap install helm --classic
|
|
|
|
Let's start by doing some initial prep-work.
|
|
|
|
I am going to download the default values.yaml file from the traefik git repository to my machine. We will need to modify the helm values.yaml file slightly so we can make it work on our Charmed Kubenetes cluster:
|
|
|
|
wget https://raw.githubusercontent.com/traefik/traefik-helm-chart/master/traefik/values.yaml
|
|
|
|
With the sed command I am going to change a variable that will open ports 80 and 443 to traefik.
|
|
|
|
sed -i 's/\# hostPort: 8000/hostPort: 80/g' values.yaml
|
|
sed -i 's/\# hostPort: 8443/hostPort: 443/g' values.yaml
|
|
|
|
Let's add the traefik repositoy to helm.
|
|
|
|
helm repo add traefik https://helm.traefik.io/traefik
|
|
helm repo update
|
|
|
|
The next step is to remove the default inginx-ngress controller
|
|
|
|
You can do this by typing
|
|
|
|
kubectl delete namespace ingress-nginx-kubernetes-worker
|
|
|
|
Once this nginx-ingress controller is removed we can deploy Traefik using helm making sure that it uses the values.yaml file we just edited.
|
|
|
|
helm install traefik traefik/traefik -f values.yamljuju ssh kubernetes-master/0 -L 30777:localhost:30777 -fN
|
|
|
|
I am going to test this with a couple of apps. But before doing this it is important to mention that I am using a wildcard domain name setup on my DNS server. This simplifies a lot my deployment given I won't need to add each host entry to my DNS server everytime I need to publish an app, webiste or service on my cluster.
|
|
|
|
My wildcard domain is pointing to the worker-0 machine's IP address. You can get the IP address by typing
|
|
|
|
juju status | grep kubernetes-worker/0
|
|
|
|
Ok, now let's go to our Portainer instance and deploy some apps to be routed via traefik. I going to connect to my Portainer instance via a ssh tunnel using juju ssh kubernetes-master/0 -L 30777:localhost:30777 -fN
|
|
|
|
I am going to test deploying caddy and pointing the app to a domain I use for testing purposes called zz11.net
|
|
|
|
I will start by creating a Resource pool for this app here.
|
|
|
|
The hostname will be caddy.zz11.net
|
|
|
|
Now I am going to deploy the Application caddy and use the Resource pool so that traefik can route the incoming request accordingly.
|
|
|
|
Let's try with another tiny app called whoami.
|
|
|
|
containous/whoami
|
|
|
|
dokuwiki
|
|
|
|
bitnami/dokuwiki
|
|
8080
|
|
|
|
16
|
|
|
|
|
|
Deploy and Manage Traefik with Portainer on a Charmed Kubernetes cluster
|
|
|
|
|
|
40436,45
|