<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Ham</title>
    <description>The latest articles on Forem by Ham (@hatr0).</description>
    <link>https://forem.com/hatr0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1207273%2Faa317d9e-25d9-4b46-b3c2-3b368bd92b60.png</url>
      <title>Forem: Ham</title>
      <link>https://forem.com/hatr0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hatr0"/>
    <language>en</language>
    <item>
      <title>Getting Cilium to work on Ubuntu Cloud Image</title>
      <dc:creator>Ham</dc:creator>
      <pubDate>Fri, 03 Jan 2025 08:07:56 +0000</pubDate>
      <link>https://forem.com/hatr0/getting-cilium-to-work-on-ubuntu-cloud-image-3843</link>
      <guid>https://forem.com/hatr0/getting-cilium-to-work-on-ubuntu-cloud-image-3843</guid>
      <description>&lt;p&gt;How to get Cilium working on Ubuntu Cloud Images Focal (20.04) or Jammy (22.04). &lt;/p&gt;

&lt;p&gt;If you are running one of the Ubuntu Cloud Images and you are trying to install Cilium as your CNI network plugin on your Kubernetes cluster. You might have noticed that you get CrashLoopBackOff from your cilium pods when issuing a &lt;code&gt;kubectl get pods -n kube-system&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzvg27jf7brg2ti2ktn8r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzvg27jf7brg2ti2ktn8r.png" alt="kubectl get pods output" width="800" height="171"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon further troubleshooting on the problem pod with a &lt;code&gt;kubectl logs cilium-jgcdm -n kube-system&lt;/code&gt; you might see the below messages.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm9rbdwivnnhovfviy3nv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm9rbdwivnnhovfviy3nv.png" alt="cilium pod logs display" width="800" height="34"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs1tv334m2wroi6f519im.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs1tv334m2wroi6f519im.png" alt="cilium pod logs daemon qdisk" width="800" height="32"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is a very good chance you are missing some kernel configuration options. Have a look at &lt;a href="https://docs.cilium.io/en/stable/operations/system_requirements/#linux-kernel" rel="noopener noreferrer"&gt;https://docs.cilium.io/en/stable/operations/system_requirements/#linux-kernel&lt;/a&gt; for more information. &lt;/p&gt;

&lt;p&gt;The base requirements are:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9us5gkt3ni8yf68nvjhc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9us5gkt3ni8yf68nvjhc.png" alt="cilium required kernel options" width="468" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On a Ubuntu system running 20.04, you can check your kernel configurations with:&lt;br&gt;
&lt;code&gt;cat /lib/modules/$(uname -r)/build/.config&lt;/code&gt; - Note: if you are not running as root, prepend &lt;code&gt;sudo&lt;/code&gt; before  the command. &lt;/p&gt;

&lt;p&gt;You can look for specific config options by prepending a pipe to grep:&lt;br&gt;
&lt;code&gt;cat /lib/modules/$(uname -r)/build/.config | grep -i config_bpf_jit&lt;/code&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Fix
&lt;/h2&gt;

&lt;p&gt;After checking, you will noticed that certain options are not enabled. To solve, let's replace our kernel variant with the 'generic' version. If not running as root, prepend &lt;code&gt;sudo&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;apt update &amp;amp;&amp;amp; apt install linux-generic&lt;/code&gt; or &lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt install linux-generic -y&lt;/code&gt; if not running as root. &lt;/p&gt;

&lt;p&gt;Now let's build initramfs for the kernel. You will want to use the generic kernel version that was installed, you should see the version from the install screen. You can also check under '/boot' directory with the command &lt;code&gt;ls /boot&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;Note: at the time of this writing, '5.4.0-204-generic' is the installed kernel version. &lt;br&gt;
&lt;code&gt;update-initramfs -u -k 5.4.0-204-generic&lt;/code&gt; or &lt;code&gt;sudo update-initramfs -u -k 5.4.0-204-generic&lt;/code&gt; for non-root user. &lt;/p&gt;

&lt;p&gt;Note: If you want to remove 'linux-kvm' variant, issue&lt;br&gt;
&lt;code&gt;sudo apt purge linux-kvm&lt;/code&gt;&lt;br&gt;
If you plan to keep the 'linux-kvm' kernel around, don't issue the apt purge command and move any files ending in '-kvm' in the /boot directory to a different folder.&lt;br&gt;
&lt;code&gt;mkdir /boot/kvm-kernel&lt;/code&gt;&lt;br&gt;
&lt;code&gt;mv /boot/*-kvm /boot/kvm-kernel/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, let's update grub&lt;br&gt;
&lt;code&gt;update-grub&lt;/code&gt; or &lt;code&gt;sudo update-grub&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Reboot the system&lt;br&gt;
&lt;code&gt;reboot&lt;/code&gt; or &lt;code&gt;sudo reboot&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Repeat the above steps for each of the nodes you have in the cluster. &lt;/p&gt;

&lt;p&gt;After installing 'generic' kernel and rebooting, check your cilium pods again and they all should be running. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl get pods -n kube-system -owide&lt;/code&gt; - the '-owide' option will show which node the pods are running on. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4d0adb8ckdz157mz824.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4d0adb8ckdz157mz824.png" alt="kubectl info with cilium pod running state" width="800" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cilium</category>
      <category>ubuntu</category>
      <category>cloud</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Fixing Expired Certificates In Kubernetes</title>
      <dc:creator>Ham</dc:creator>
      <pubDate>Fri, 03 Jan 2025 06:20:32 +0000</pubDate>
      <link>https://forem.com/hatr0/fixing-expired-certificates-in-kubernetes-1oe2</link>
      <guid>https://forem.com/hatr0/fixing-expired-certificates-in-kubernetes-1oe2</guid>
      <description>&lt;p&gt;By default, when you setup your Kubernetes cluster, the certificates expires after one year. &lt;/p&gt;

&lt;p&gt;If it's been a while since you started up your Kubernetes cluster and you try to issue kubectl commands and notice connection refused errors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frwluxgnetlc2tgm1fdyz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frwluxgnetlc2tgm1fdyz.png" alt="kubectl connection refused" width="800" height="83"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The commands used requires 'root' privileged, so if you are login as non-root, you will need to prepend &lt;code&gt;sudo&lt;/code&gt; before the commands. &lt;/p&gt;

&lt;p&gt;Troubleshooting further, you noticed that your kubelet service is failing to start (&lt;code&gt;systemctl status kubelet&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Upon checking logs related with kubelet (&lt;code&gt;journalctl | grep kubelet&lt;/code&gt;), you noticed the belong error messages. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhsqer7i1zyou0monp1dl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhsqer7i1zyou0monp1dl.png" alt="journalctl kubelet errors" width="800" height="37"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To verify, issue &lt;code&gt;kubeadm certs check-expiration&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvhfhm4xbtel0x098gbm8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvhfhm4xbtel0x098gbm8.png" alt="kubeadm certs check" width="800" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bingo! &lt;/p&gt;

&lt;p&gt;Let's manually renew certificates to fix our issues. &lt;/p&gt;

&lt;p&gt;If your cluster has more than one control-plane node, be sure to run the following commands on all control-plane nodes in the cluster.&lt;/p&gt;

&lt;p&gt;First, let's backup our certificates just in case we need them.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;cp -R /etc/kubernetes/pki  /etc/kubernetes/pki.backup&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let's renew our certificates with&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;kubeadm certs renew all&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Verify new certificate installed correctly. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;kubeadm certs check-expiration&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Restart &lt;code&gt;kubelet service&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;systemctl restart kubelet&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the renew process is complete, we will need to restart all the control plane pods. One way to restart is moving it's manifest file out and wait for for about 20 seconds before moving the file back in to the 'pki' folder. This will will recreate the Pod to use the new certificates. &lt;/p&gt;

&lt;p&gt;Copy the administrator certificates &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This should get your cluster running again. You can verify with 'kubectl get pods' and not get an error.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Things To Do If The Steps Above Doesn't Work
&lt;/h2&gt;

&lt;p&gt;If for some reason the above doesn't work, you will need to do the following. Make a backup of /etc/kubernetes/pki/&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;cp -R /etc/kubernetes/pki /etc/kubernetes/pki-backup&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Delete the following files from /etc/kubernetes/pki&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;rm apiserver.crt \ 
apiserver-etcd-client.key\ 
apiserver-kubelet-client.crt\ 
front-proxy-ca.crt\ 
front-proxy-client.crt\ 
front-proxy-client.key\ 
front-proxy-ca.key\ 
apiserver-kubelet-client.key\ 
apiserver.key\ 
apiserver-etcd-client.crt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remove the following all .crt and .key files from /etc/kubernetes/pki/etcd&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;rm /etc/kubernetes/pki/etcd/*.crt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rm /etc/kubernetes/pki/etcd/*.key&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then create certs with&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;kubeadm init phase certs all --apiserver-advertise-address &amp;lt;IP&amp;gt;&lt;/code&gt; -- substitute your cluster IP.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Backup\Move conf files from /etc/kubernetes&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;mkdir conf-backup&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;mv admin.conf\
  controller-manager.conf\
  kubelet.conf\
  scheduler.conf /etc/kubernetes/conf-backup/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create new conf files&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;kubeadm init phase kubeconfig all&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, restart kubelet service or reboot system.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;systemctl restart kubelet&lt;/code&gt; or &lt;code&gt;reboot&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>kubernetes</category>
      <category>certificates</category>
    </item>
  </channel>
</rss>
