|
| 1 | +--- |
| 2 | +title: Setting Up Cilium on a Kubernetes Cluster with Talos in Proxmox |
| 3 | +date: 2025-03-12 21:00:00 +0100 |
| 4 | +categories: [DevOps, Kubernetes] |
| 5 | +tags: [kubernetes, talos, cilium, homelab] # TAG names should always be lowercase |
| 6 | +description: Switching from Flannel to Cilium for enhanced networking |
| 7 | +author: sofianlak |
| 8 | +image: |
| 9 | + path: /assets/img/headers/flannel-to-cilium.png |
| 10 | +--- |
| 11 | + |
| 12 | +> This article is for the setup of a new Kubernetes cluster with Talos. I am not here coverring how to cleanup your existing cluster for removing Flannel. |
| 13 | +{: .prompt-info } |
| 14 | + |
| 15 | +## **Introduction** |
| 16 | + |
| 17 | +If you clicked on this article, it’s probably because you’re familiar with at least one of the four key technologies: Cilium, Kubernetes, Talos, or Proxmox. But for those who are curious or need a bit more context, let’s break it down. |
| 18 | + |
| 19 | +- **`Kubernetes`** is a container orchestrator designed to scale and manage containerized applications efficiently. It provides a rich set of APIs to handle deployments, networking, and more. |
| 20 | +- **`Talos`** is a lightweight, immutable Linux OS specifically built for running Kubernetes clusters. It simplifies cluster deployment by eliminating the need to manually install and configure Kubernetes components (which is usually done with kubeadm). |
| 21 | +- **`Proxmox`** is a powerful open-source virtualization platform that allows us to create and manage virtual machines. |
| 22 | + |
| 23 | +Now, how do these pieces fit together? We’ll use Proxmox to create virtual machines, install Talos as the OS, and deploy a Kubernetes cluster on top of it. |
| 24 | + |
| 25 | +**Wait, but what about Cilium?** |
| 26 | + |
| 27 | +By default, Talos uses Flannel as the CNI (Container Network Interface) along with kube-proxy to handle networking. However, if you want more control, security, and observability in your Kubernetes networking, Cilium is the way to go. Cilium replaces kube-proxy and brings advanced networking features like eBPF-based security policies, high-performance networking, and deep observability. |
| 28 | + |
| 29 | + |
| 30 | +## **Install Proxmox & Talos** |
| 31 | + |
| 32 | +- **Ensure Proxmox is installed and configured** |
| 33 | + |
| 34 | +I am assuming that you already have a Proxmox server ready. If not, you can get started by following the [Proxmox Getting Started Guide](https://www.proxmox.com/en/products/proxmox-virtual-environment/get-started){:target="\_blank"}. |
| 35 | + |
| 36 | +- **Install talosctl on your local machine** |
| 37 | + |
| 38 | +You can download talosctl on macOS and Linux via: |
| 39 | + |
| 40 | +```shell |
| 41 | +brew install siderolabs/tap/talosctl |
| 42 | +``` |
| 43 | + |
| 44 | +or if you prefer this way: |
| 45 | + |
| 46 | +```shell |
| 47 | +curl -sL https://talos.dev/install | sh |
| 48 | +``` |
| 49 | + |
| 50 | +- **Download the Talos ISO from the Talos Image Factory** |
| 51 | + |
| 52 | +Get the Talos ISO from the [Talos Image Factory](https://factory.talos.dev){:target="\_blank"} Ensure that during the system extensions selection, you choose the QEMU agent to enable communication between Proxmox and your cluster. |
| 53 | + |
| 54 | +- **Upload the ISO to Proxmox and create VMs as per the standard Talos installation guide** |
| 55 | + |
| 56 | +Upload the Talos ISO to Proxmox and create virtual machines as per the standard Talos installation guide. |
| 57 | + |
| 58 | +Follow the steps up [here](https://www.talos.dev/v1.9/talos-guides/install/virtualized-platforms/proxmox/?utm_source=chatgpt.com#upload-iso){:target="\_blank"} to “Upload ISO,” “Create VMs,” and “Start Control Plane Node,” then return here to continue with the core subject. |
| 59 | + |
| 60 | + |
| 61 | +## **Remove Default CNI (Flannel) via patch.yaml** |
| 62 | + |
| 63 | +As mentioned earlier, Talos installs Flannel by default for networking. |
| 64 | + |
| 65 | +To disable it and configure Talos to operate without any CNI initially, create a patch.yaml file with the following content: |
| 66 | + |
| 67 | + |
| 68 | +```shell |
| 69 | +cluster: |
| 70 | + network: |
| 71 | + cni: |
| 72 | + name: none |
| 73 | + proxy: |
| 74 | + disabled: true |
| 75 | +``` |
| 76 | +{: file="patch.yaml" } |
| 77 | + |
| 78 | + |
| 79 | +## **Generate Machine Configurations** |
| 80 | + |
| 81 | + |
| 82 | +Okay now we will tackle the Talos configuration. |
| 83 | + |
| 84 | +When your controlplane and worker node are ready just start them in Promox, it will boot and generate your ip address (*if you have a DHCP if you don't follow the documentation for static IP [here](https://www.talos.dev/v1.9/talos-guides/install/virtualized-platforms/proxmox/?utm_source=chatgpt.com#without-dhcp-server){:target="\_blank"})* |
| 85 | + |
| 86 | +- **Identify the IPs of your nodes and store them in environment variables** |
| 87 | +```shell |
| 88 | +export $CONTROL_PLANE_IP=*** |
| 89 | +export $WORKER_IP=*** |
| 90 | +``` |
| 91 | +- **Now, generate the Talos configuration files** |
| 92 | +```shell |
| 93 | +talosctl gen config talos-proxmox-cluster https://$CONTROL_PLANE_IP:6443 --output-dir _out --config-patch @patch.yaml |
| 94 | +``` |
| 95 | +This will create the necessary YAML configurations in the _out/ directory and use our patch to not generate the CNI config. |
| 96 | + |
| 97 | +- **Apply configuration for the control plane** |
| 98 | +```shell |
| 99 | +talosctl apply-config --insecure --nodes $CONTROL_PLANE_IP --file _out/controlplane.yaml |
| 100 | +``` |
| 101 | + |
| 102 | +- **Apply configuration for the worker node** |
| 103 | +```shell |
| 104 | +talosctl apply-config --insecure --nodes $WORKER_IP --file _out/worker.yaml |
| 105 | +``` |
| 106 | + |
| 107 | +- **Now, set up talosctl to interact with the cluster** |
| 108 | +```shell |
| 109 | +export TALOSCONFIG="_out/talosconfig" |
| 110 | +talosctl config endpoint $CONTROL_PLANE_IP |
| 111 | +talosctl config node $CONTROL_PLANE_IP |
| 112 | +``` |
| 113 | + |
| 114 | +- **Run the bootstrap command to initialize the Talos Kubernetes control plane** |
| 115 | +```shell |
| 116 | +talosctl bootstrap |
| 117 | +``` |
| 118 | + |
| 119 | +- **Finally, retrieve the Kubernetes configuration** |
| 120 | +```shell |
| 121 | +talosctl kubeconfig . |
| 122 | +``` |
| 123 | + |
| 124 | +- **If you had already a KUBECONFIG file you can use this command** |
| 125 | +```shell |
| 126 | +export KUBECONFIG=$(pwd)/kubeconfig |
| 127 | +``` |
| 128 | + |
| 129 | +<br> |
| 130 | +Now, your machines will automatically reboot, and you just need to wait a few minutes for the Kubernetes components to be up and running. |
| 131 | + |
| 132 | +## **Install Cilium** |
| 133 | +Now you have a Kubernetes cluster running, but with no networking. Let’s install Cilium for networking! |
| 134 | + |
| 135 | +You can install Cilium using either the Cilium CLI or Helm. |
| 136 | + |
| 137 | + |
| 138 | +### **Using Cilium CLI** |
| 139 | + |
| 140 | +```shell |
| 141 | +cilium install \ |
| 142 | + --set ipam.mode=kubernetes \ |
| 143 | + --set kubeProxyReplacement=true \ |
| 144 | + --set securityContext.capabilities.ciliumAgent="{CHOWN,KILL,NET_ADMIN,NET_RAW,IPC_LOCK,SYS_ADMIN,SYS_RESOURCE,DAC_OVERRIDE,FOWNER,SETGID,SETUID}" \ |
| 145 | + --set securityContext.capabilities.cleanCiliumState="{NET_ADMIN,SYS_ADMIN,SYS_RESOURCE}" \ |
| 146 | + --set cgroup.autoMount.enabled=false \ |
| 147 | + --set cgroup.hostRoot=/sys/fs/cgroup \ |
| 148 | + --set k8sServiceHost=localhost \ |
| 149 | + --set k8sServicePort=7445 |
| 150 | +``` |
| 151 | + |
| 152 | +### **Using Helm** |
| 153 | + |
| 154 | + |
| 155 | +```shell |
| 156 | +helm repo add cilium https://helm.cilium.io/ |
| 157 | +helm repo update |
| 158 | + |
| 159 | +helm install \ |
| 160 | + cilium \ |
| 161 | + cilium/cilium \ |
| 162 | + --version 1.15.6 \ |
| 163 | + --namespace kube-system \ |
| 164 | + --set ipam.mode=kubernetes \ |
| 165 | + --set kubeProxyReplacement=true \ |
| 166 | + --set securityContext.capabilities.ciliumAgent="{CHOWN,KILL,NET_ADMIN,NET_RAW,IPC_LOCK,SYS_ADMIN,SYS_RESOURCE,DAC_OVERRIDE,FOWNER,SETGID,SETUID}" \ |
| 167 | + --set securityContext.capabilities.cleanCiliumState="{NET_ADMIN,SYS_ADMIN,SYS_RESOURCE}" \ |
| 168 | + --set cgroup.autoMount.enabled=false \ |
| 169 | + --set cgroup.hostRoot=/sys/fs/cgroup \ |
| 170 | + --set k8sServiceHost=localhost \ |
| 171 | + --set k8sServicePort=7445 |
| 172 | +``` |
| 173 | + |
| 174 | + |
| 175 | +After the installation, you can check if the Cilium components are up and running. |
| 176 | + |
| 177 | +Now, you can explore Cilium! By following these steps, you’ve set up a Kubernetes cluster on Talos within Proxmox, using Cilium as your CNI to enable enhanced networking capabilities. |
| 178 | + |
| 179 | +For more detailed information, refer to the [Talos Guide on Deploying Cilium CNI](https://www.talos.dev/v1.9/kubernetes-guides/network/deploying-cilium/){:target="\_blank"}. |
0 commit comments