A MicroK8s implementation of Traefik Ingress Controller with Linkerd Service Mesh in VirtualBox Guest Ubuntu VM
There is considerable confusion and lack of good documentation for the implementation of Traefik Ingress Controller with Linkerd Service Mesh within MicroK8s on a bare metal install on VirtualBox Guest Ubuntu OS. This demonstration includes metallb BGP load balancer and revisions to netplan yaml file to enable connections to the Traefik Ingress Controller from Host and connected environments (through Host-Only Network Adapter)
- Install MicroK8s with Snap in Ubuntu: sudo snap install microk8s --classic
- May need to change firewall settings: see https://microk8s.io/tutorials
Edit ~/.bashrc file to include:
- export KUBECONFIG="/var/snap/microk8s/current/credentials/client.config"
- alias kubectl='microk8s kubectl' so that kubectl can be used with microk8s (as in minikube and k8s)
After editing run "source .bashrc" or reboot to enable changes
- Set up MicroK8s with Add Ons: microk8s enable dashboard dns linkerd metallb registry storage traefik
- When metallb is being installed, it will be necessary to add IP addresses for load balancer. These MUST addresses that are unused by VirtualBox Host-Only Adapters but are allocated for the Host-Only Adapter (in the VirtualBox Manager, see Networks --> Properties)
Install Kubernetes Services (Traefik and Whoami), then Deply and add Ingress Routes with Traefik Custom Resource Definitions
- kubectl apply -f 01-traefik-crd.yaml
- kubectl apply -f 02-service.yaml
- kubectl apply -f 03-deploy.yaml
- kubectl apply -f 04-ingress-routes.yaml
- Since metallb load balancer is enable, an external IP will be created for Traefik Ingress Controller - use 'kubectl get services' to show IP Address for Traefik Ingress Controller
- Check that pods are running and deployments are successful: 'kubectl get pods' and 'kubectl get deployments'
- Inject linkerd service mesh into all deployments in current (default) namespace: 'kubectl get deploy -o yaml | microk8s linkerd inject - | kubectl apply -f -'
- From a separate linux terminal, run Linkerd Dashboard: 'microk8s linkerd dashboard'
- For Virtualbox VM's need IP address assigned by metallb to be in VM Host-Only Virtual adapter IP range... Leave some spare IP's between highest last number and metallb IP's...
- metallb will assign IP addresses to any LoadBalancer service - in this case Traefik Ingress Controller... edit netplan yaml file in '/etc/netplan' directory - file in this Guest VM is '01-network-manager-all.yaml'
use the following to add 2nd static ip for enp0s3 - this 2nd IP is Traefik Ingress Controller - loadbalancer - IP
network: version: 2 renderer: NetworkManager ethernets: enp0s3: dhcp4: false optional: true addresses: [192.168.xxx.6/24, 192.168.xxx.12/24] enp0s8: dhcp4: true
- The first enp0s3 address should be the existing Host-Only adapter address (from ifconfig or ip addr) and the second address should be the address assigned by metallb to the Traefik Ingress Controller...
- If enp0s8, a second Host-Only adapter is present, then it should be configured to allow dhcp (and NetworkManager) to determine its setup.
- After changes to this file "sudo netplan try" or "sudo netplan apply"
- From VirtualBox Host (can be Windows or Linux), ping both addresses for enp0s3 adapter to ensure the config is working properly
- From any web browser in VirtualBox Host OS or Guest Ubuntu OS, enter "192.168.xxx.12:8080/dashboard" to see Traefik Dashboard
- From any web browser in VirtualBox Host OS or Guest Ubuntu OS, enter "192.168.xxx.12/whoami" to test Whoami App