Automate K3S cluster deployment on vSphere using Ansible and a VM Template

Recently, I had to deploy a bunch of VMs to a vSphere cluster. Although there are many VMware solutions that can achieve this, I wanted to get my hands dirty with Ansible. Lets begin by installing pyvmomi root@ubuntu:~# apt install pip -y root@ubuntu:~# apt-get update root@ubuntu:~# pip install pyvmomi Install the VMware vSphere Automation SDK for Python root@ubuntu:~# pip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git Install ansible root@ubuntu:~# sudo apt install software-properties-common root@ubuntu:~# sudo apt install ansible Create a new Ansible role Ansible Roles let you automatically load related vars, files, tasks, handlers, and other Ansible artifacts based on a known file structure....

March 12, 2024 · 4 min · Jahnin Rajamoni

Installing and configuring the vSphere CSI Driver in K3S

Environment: vSphere 7. VM Hardware Version 19 Two VMs running Debian 11.9 SSH Enabled Root login via SSH enabled. Not best practise, but as this is a lab, I did not want to troubleshoot permission related issues. Edit /etc/ssh/sshd_config Add "PermitRootLogin: yes" Restart SSHD - systemctl restart sshd Install govc root@control1:~# export GOVC_INSECURE=1 root@control1:~# export GOVC_URL='https://administrator@vsphere.local:<PASSWORD>@vc802.gs.labs' root@control1:~# curl -L -o - "https://github.com/vmware/govmomi/releases/latest/download/govc_$(uname -s)_$(uname -m).tar.gz" | tar -C /usr/local/bin -xvzf - govc Enable UUID # List existing VMs using govc ls /Datacenter/vm/VMName root@control1:~# govc vm....

February 16, 2024 · 8 min · Jahnin Rajamoni

Failed to Call Webhook when deploying Metallb in K3s

After installing metallb using helm, I hit the below error when applying the IP Adress Pool. Error from server (InternalError): error when creating "ip-pool.yaml": Internal error occurred: failed calling webhook "ipaddresspoolvalidationwebhook.metallb.io": failed to call webhook: Post "https://metallb-webhook-service.metallb-system.svc:443/validate-metallb-io-v1beta1-ipaddresspool?timeout=10s": context deadline exceeded Error from server (InternalError): error when creating "ip-pool.yaml": Internal error occurred: failed calling webhook "l2advertisementvalidationwebhook.metallb.io": failed to call webhook: Post "https://metallb-webhook-service.metallb-system.svc:443/validate-metallb-io-v1beta1-l2advertisement?timeout=10s": context deadline exceeded The IPAdressPool yaml: apiVersion: metallb.io/v1beta1 kind: IPAddressPool metadata: name: default-pool namespace: metallb-system spec: addresses: - 172....

February 16, 2024 · 2 min · Jahnin Rajamoni

Three Node K3s Using Install Script

I was looking for an alternative to k3sup method to install a k3s cluster.( Refer this link on how to setup k3s using k3sup.) Most of the content below is based from the quick start guide here - https://docs.k3s.io/quick-start Generate a token that will be used to join additional nodes to the kubernetes cluster": openssl rand -hex 10 > k3s_secret.txt Install the first control plane node: curl -sfL https://get.k3s.io | K3S_TOKEN=cat k3s_secret....

February 10, 2024 · 3 min · Jahnin Rajamoni

Enable Traefik Dashboard in K3s

K3S deploys traefik as its ingress controller. The traefik dashboard in not enabled by default. To enable the traefik dashboard, SSH to the kubernetes node that is the control plane node. Make sure you are the root user. sudo su - Edit the file: /var/lib/rancher/k3s/server/manifests/traefik.yaml Add the following config to the file under spec->valuesContent. After you save the file, traefik will be redeployed and port 9000 will be exposed. dashboard: enabled: true ports: traefik: expose: true Example config:...

November 17, 2023 · 2 min · Jahnin Rajamoni