<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cilium &#8211; Blog of Kliment Andreev &#8211; A place so I won&#039;t forget things</title>
	<atom:link href="https://blog.andreev.it/tag/cilium/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.andreev.it</link>
	<description></description>
	<lastBuildDate>Sun, 22 Oct 2023 13:21:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Install Kubernetes with CRI-O and Cilium on Rocky Linux 9 / VMware / Bare Metal</title>
		<link>https://blog.andreev.it/2023/10/install-kubernetes-with-cri-o-and-cilium-on-rocky-linux-9/</link>
					<comments>https://blog.andreev.it/2023/10/install-kubernetes-with-cri-o-and-cilium-on-rocky-linux-9/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Mon, 09 Oct 2023 16:18:16 +0000</pubDate>
				<category><![CDATA[Containers]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[ESX/ESXi]]></category>
		<category><![CDATA[Rocky Linux]]></category>
		<category><![CDATA[Cilium]]></category>
		<category><![CDATA[CRI-O]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[MetalLB]]></category>
		<category><![CDATA[rocky linux]]></category>
		<category><![CDATA[VMware]]></category>
		<guid isPermaLink="false">https://blog.andreev.it/?p=9532</guid>

					<description><![CDATA[In this post, I&#8217;ll build a Kubernetes cluster with one master and two nodes&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p>In this post, I&#8217;ll build a Kubernetes cluster with one master and two nodes using CRI-O and Cilium. I have DNS in my environment but you can use the hosts files if needed.<br />
The OS will be Rocky Linux 9 running on ESXi 8.x but this should work on any other bare metal server too. The config for the nodes is:</p>
<p>&#8211; Master: 2 CPUs, 4GB RAM<br />
&#8211; Workers: 2 CPUs, 8GB RAM.</p>
<p>First, we&#8217;ll have to disable swap and put SELinux in permissive mode.<br />
<strong>Do this on all nodes (master + workers).</strong></p>
<pre class="brush: bash; title: ; notranslate">
sudo swapoff -a
sudo sed -i &#039;/ swap / s/^\(.*\)$/#\1/g&#039; /etc/fstab
sudo setenforce 0
sudo sed -i &#039;s/^SELINUX=enforcing$/SELINUX=permissive/&#039; /etc/selinux/config
</pre>
<p>Now, we have to open some firewall ports for Kubernetes..<br />
<strong>Do this on the master node only.</strong></p>
<pre class="brush: bash; title: ; notranslate">
sudo firewall-cmd --permanent --add-port=6443/tcp
sudo firewall-cmd --permanent --add-port=2379-2380/tcp
sudo firewall-cmd --permanent --add-port=10250/tcp
sudo firewall-cmd --permanent --add-port=10259/tcp
sudo firewall-cmd --permanent --add-port=10257/tcp
sudo firewall-cmd --reload
</pre>
<p><strong>Do this on the workers only.</strong></p>
<pre class="brush: bash; title: ; notranslate">
sudo firewall-cmd --permanent --add-port=10250/tcp
sudo firewall-cmd --permanent --add-port=30000-32767/tcp   
sudo firewall-cmd --reload
</pre>
<p>In addition, we&#8217;ll have to open the firewall ports for Cilium.<br />
<strong>Do this on all nodes</strong>.</p>
<pre class="brush: bash; title: ; notranslate">
sudo firewall-cmd --permanent --add-port=4240/tcp 
sudo firewall-cmd --permanent --add-port=8472/udp 
sudo firewall-cmd --reload
</pre>
<p>Now, we have to make some changes that are also required. Some necessary modules and IPtables change.<br />
<strong>Do this on all nodes.</strong></p>
<pre class="brush: bash; title: ; notranslate">
cat &lt;&lt;EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF

sudo modprobe overlay
sudo modprobe br_netfilter

# sysctl params required by setup, params persist across reboots
cat &lt;&lt;EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1
EOF

# Apply sysctl params without reboot
sudo sysctl --system
</pre>
<p>We have to install CRI-O container runtime.<br />
<strong>Do this on all nodes.</strong></p>
<pre class="brush: bash; title: ; notranslate">
VERSION=1.22
sudo curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/CentOS_8/devel:kubic:libcontainers:stable.repo
sudo curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable:cri-o:${VERSION}.repo https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:${VERSION}/CentOS_8/devel:kubic:libcontainers:stable:cri-o:${VERSION}.repo
sudo dnf -y install cri-o cri-tools
sudo systemctl enable --now crio
sudo systemctl status crio
</pre>
<p>Then, we have to install Kubernetes.<br />
<strong>Do this on all nodes.</strong></p>
<pre class="brush: bash; title: ; notranslate">
cat &lt;&lt;EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
&#x5B;kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kubelet kubeadm kubectl
EOF
sudo dnf install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
sudo systemctl enable --now kubelet
</pre>
<p><strong>On the master node only</strong>, initialize the cluster. Replace <strong>master.homelab.com</strong> with your master IP if you don&#8217;t use DNS.</p>
<pre class="brush: bash; title: ; notranslate">
sudo kubeadm init --control-plane-endpoint master.homelab.local:6443
</pre>
<p>You&#8217;ll get an output that says how to join the nodes, something like kubeadm join master&#8230; + a token<br />
<strong>On the master node</strong>, add these lines.</p>
<pre class="brush: bash; title: ; notranslate">
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
</pre>
<p>Join the nodes to the cluster.<br />
<strong>Do this on workers only.</strong></p>
<pre class="brush: bash; title: ; notranslate">
sudo kubeadm join master.homelab.local:6443 --token t2yir0.7n49rn6r57msy4j4 \
        --discovery-token-ca-cert-hash sha256:563360fcf60c49be91cdcf6486a4954c579a80c54503127ee0682ab8f86ec840
</pre>
<p>Check the nodes.<br />
<strong>Do this on the master node.</strong></p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
kubectl get nodes
NAME                   STATUS   ROLES           AGE    VERSION
master.homelab.local   Ready    control-plane   116s   v1.28.2
node1.homelab.local    Ready    &lt;none&gt;          89s    v1.28.2
node2.homelab.local    Ready    &lt;none&gt;          85s    v1.28.2
</pre>
<p>&#8230;then check all the pods.<br />
<strong>Do this on the master node.</strong></p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
kubectl get pods --all-namespaces
NAMESPACE     NAME                                           READY   STATUS    RESTARTS   AGE
kube-system   coredns-5dd5756b68-5ljgg                       1/1     Running   0          2m
kube-system   coredns-5dd5756b68-jp8tq                       1/1     Running   0          2m
kube-system   etcd-master.homelab.local                      1/1     Running   0          2m6s
kube-system   kube-apiserver-master.homelab.local            1/1     Running   0          2m6s
kube-system   kube-controller-manager-master.homelab.local   1/1     Running   0          2m6s
kube-system   kube-proxy-2z64r                               1/1     Running   0          2m
kube-system   kube-proxy-mrwjv                               1/1     Running   0          96s
kube-system   kube-proxy-nj5q4                               1/1     Running   0          100s
kube-system   kube-scheduler-master.homelab.local            1/1     Running   0          2m6s
</pre>
<p>Install Cilium<strong> on the master node only.</strong></p>
<pre class="brush: bash; title: ; notranslate">
CILIUM_CLI_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt)
CLI_ARCH=amd64
if &#x5B; &quot;$(uname -m)&quot; = &quot;aarch64&quot; ]; then CLI_ARCH=arm64; fi
curl -L --fail --remote-name-all https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum}
sha256sum --check cilium-linux-${CLI_ARCH}.tar.gz.sha256sum
sudo tar xzvfC cilium-linux-${CLI_ARCH}.tar.gz /usr/local/bin
rm cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum}
cilium install --version 1.14.2
</pre>
<p>Check the status.</p>
<pre class="brush: bash; title: ; notranslate">
cilium status --wait
</pre>
<p>You should see something like this. </p>
<pre class="brush: bash; title: ; notranslate">
    /¯¯\
 /¯¯\__/¯¯\    Cilium:             OK
 \__/¯¯\__/    Operator:           OK
 /¯¯\__/¯¯\    Envoy DaemonSet:    disabled (using embedded mode)
 \__/¯¯\__/    Hubble Relay:       disabled
    \__/       ClusterMesh:        disabled

DaemonSet              cilium             Desired: 3, Ready: 3/3, Available: 3/3
Deployment             cilium-operator    Desired: 1, Ready: 1/1, Available: 1/1
Containers:            cilium             Running: 3
                       cilium-operator    Running: 1
Cluster Pods:          2/2 managed by Cilium
Helm chart version:    1.14.2
Image versions         cilium             quay.io/cilium/cilium:v1.14.2@sha256:6263f3a3d5d63b267b538298dbeb5ae87da3efacf09a2c620446c873ba807d35: 3
                       cilium-operator    quay.io/cilium/operator-generic:v1.14.2@sha256:52f70250dea22e506959439a7c4ea31b10fe8375db62f5c27ab746e3a2af866d: 1
</pre>
<p>Then you can run the connectivity test. Some of the egress test will fail because we don&#8217;t have a public IP on the cluster.</p>
<pre class="brush: bash; title: ; notranslate">
cilium connectivity test
</pre>
<p>You should be able to run your deployments now. If you need to access the pods using URL use something like NodePort or port-forwarding. It&#8217;s very cumbersome and inefficient, but you can use a load balancer with MetalLB. Read <a href="https://blog.andreev.it/2023/10/install-metallb-on-kubernetes-cluster-running-on-vmware-vms-or-bare-metal-server/" rel="noopener" target="_blank">this</a> post to see how to do that. It&#8217;s separated from this post, because it&#8217;s a separate topic than just k8s, container runtime and CNI.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2023/10/install-kubernetes-with-cri-o-and-cilium-on-rocky-linux-9/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
