Install Kubernetes in Fedora

Install Kubernetes in Fedora

My environment:

  • VirtualBox 7.0 (Version 7.0.6 r155176 (Qt5.15.2))
  • Fedora 38
             .',;::::;,'.                hperez@fedora 
         .';:cccccccccccc:;,.            ------------- 
      .;cccccccccccccccccccccc;.         OS: Fedora Linux 38 (Workstation Edition) x86_64 
    .:cccccccccccccccccccccccccc:.       Host: VirtualBox 1.2 
  .;ccccccccccccc;.:dddl:.;ccccccc;.     Kernel: 6.4.15-200.fc38.x86_64 
 .:ccccccccccccc;OWMKOOXMWd;ccccccc:.    Uptime: 3 days, 6 hours, 57 mins 
.:ccccccccccccc;KMMc;cc;xMMc:ccccccc:.   Packages: 2735 (rpm), 4 (flatpak), 14 (snap) 
,cccccccccccccc;MMM.;cc;;WW::cccccccc,   Shell: bash 5.2.15 
:cccccccccccccc;MMM.;cccccccccccccccc:   Resolution: 1920x1080 
:ccccccc;oxOOOo;MMM0OOk.;cccccccccccc:   DE: GNOME 44.5 
cccccc:0MMKxdd:;MMMkddc.;cccccccccccc;   WM: Mutter 
ccccc:XM0';cccc;MMM.;cccccccccccccccc'   WM Theme: Adwaita 
ccccc;MMo;ccccc;MMW.;ccccccccccccccc;    Theme: Adwaita-dark [GTK2/3] 
ccccc;0MNc.ccc.xMMd:ccccccccccccccc;     Icons: Adwaita [GTK2/3] 
cccccc;dNMWXXXWM0::cccccccccccccc:,      Terminal: gnome-terminal 
cccccccc;.:odl:.;cccccccccccccc:,.       CPU: 11th Gen Intel i5-1145G7 (3) @ 1.497GHz 
:cccccccccccccccccccccccccccc:'.         GPU: 00:02.0 VMware SVGA II Adapter 
.:cccccccccccccccccccccc:;,..            Memory: 8896MiB / 13866MiB 
  '::cccccccccccccc::;,.
                                                                 
                                                                 



Method 1 (didn't work for me):

Here is the command:

sudo dnf install kubernetes etcd

The console output should be similar to this:

[terminator@skynet ~]$ sudo dnf install kubernetes etcd
[sudo] password for terminator: 
Last metadata expiration check: 0:01:47 ago on Tue 26 Sep 2023 04:58:28 PM CEST.
Dependencies resolved.
======================================================================================================================
 Package                              Architecture         Version                        Repository             Size
======================================================================================================================
Installing:
 etcd                                 x86_64               3.5.5-2.fc38                   fedora                 17 M
 kubernetes                           x86_64               1.26.9-2.fc38                  updates                11 k
Installing dependencies:
 conntrack-tools                      x86_64               1.4.7-1.fc38                   updates               228 k
 kubernetes-client                    x86_64               1.26.9-2.fc38                  updates                11 M
 kubernetes-master                    x86_64               1.26.9-2.fc38                  updates                56 M
 kubernetes-node                      x86_64               1.26.9-2.fc38                  updates                32 M
 libnetfilter_cthelper                x86_64               1.0.0-23.fc38                  fedora                 22 k
 libnetfilter_cttimeout               x86_64               1.0.0-21.fc38                  fedora                 23 k
 libnetfilter_queue                   x86_64               1.0.5-4.fc38                   fedora                 28 k
 socat                                x86_64               1.7.4.4-2.fc38                 fedora                314 k

Transaction Summary
======================================================================================================================
Install  10 Packages

Total download size: 116 M
Installed size: 561 M
Is this ok [y/N]: y
Downloading Packages:
(1/10): libnetfilter_cthelper-1.0.0-23.fc38.x86_64.rpm                                                                      42 kB/s |  22 kB     00:00    
(2/10): libnetfilter_cttimeout-1.0.0-21.fc38.x86_64.rpm                                                                     35 kB/s |  23 kB     00:00    
(3/10): kubernetes-1.26.9-2.fc38.x86_64.rpm                                                                                 17 kB/s |  11 kB     00:00    
(4/10): libnetfilter_queue-1.0.5-4.fc38.x86_64.rpm                                                                          37 kB/s |  28 kB     00:00    
(5/10): conntrack-tools-1.4.7-1.fc38.x86_64.rpm                                                                            187 kB/s | 228 kB     00:01    
(6/10): socat-1.7.4.4-2.fc38.x86_64.rpm                                                                                    257 kB/s | 314 kB     00:01    
(7/10): kubernetes-client-1.26.9-2.fc38.x86_64.rpm                                                                         1.8 MB/s |  11 MB     00:06    
(8/10): etcd-3.5.5-2.fc38.x86_64.rpm                                                                                       2.2 MB/s |  17 MB     00:07    
(9/10): kubernetes-node-1.26.9-2.fc38.x86_64.rpm                                                                           1.6 MB/s |  32 MB     00:19    
(10/10): kubernetes-master-1.26.9-2.fc38.x86_64.rpm                                                                        1.5 MB/s |  56 MB     00:36    
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                      3.2 MB/s | 116 MB     00:36     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                   1/1 
  Installing       : kubernetes-client-1.26.9-2.fc38.x86_64                                                                                           1/10 
  Running scriptlet: kubernetes-master-1.26.9-2.fc38.x86_64                                                                                           2/10 
  Installing       : kubernetes-master-1.26.9-2.fc38.x86_64                                                                                           2/10 
  Running scriptlet: kubernetes-master-1.26.9-2.fc38.x86_64                                                                                           2/10 
  Installing       : socat-1.7.4.4-2.fc38.x86_64                                                                                                      3/10 
  Installing       : libnetfilter_queue-1.0.5-4.fc38.x86_64                                                                                           4/10 
  Installing       : libnetfilter_cttimeout-1.0.0-21.fc38.x86_64                                                                                      5/10 
  Installing       : libnetfilter_cthelper-1.0.0-23.fc38.x86_64                                                                                       6/10 
  Installing       : conntrack-tools-1.4.7-1.fc38.x86_64                                                                                              7/10 
  Running scriptlet: conntrack-tools-1.4.7-1.fc38.x86_64                                                                                              7/10 
  Running scriptlet: kubernetes-node-1.26.9-2.fc38.x86_64                                                                                             8/10 
  Installing       : kubernetes-node-1.26.9-2.fc38.x86_64                                                                                             8/10 
  Running scriptlet: kubernetes-node-1.26.9-2.fc38.x86_64                                                                                             8/10 
  Installing       : kubernetes-1.26.9-2.fc38.x86_64                                                                                                  9/10 
  Running scriptlet: etcd-3.5.5-2.fc38.x86_64                                                                                                        10/10 
  Installing       : etcd-3.5.5-2.fc38.x86_64                                                                                                        10/10 
  Running scriptlet: etcd-3.5.5-2.fc38.x86_64                                                                                                        10/10 
  Verifying        : etcd-3.5.5-2.fc38.x86_64                                                                                                         1/10 
  Verifying        : libnetfilter_cthelper-1.0.0-23.fc38.x86_64                                                                                       2/10 
  Verifying        : libnetfilter_cttimeout-1.0.0-21.fc38.x86_64                                                                                      3/10 
  Verifying        : libnetfilter_queue-1.0.5-4.fc38.x86_64                                                                                           4/10 
  Verifying        : socat-1.7.4.4-2.fc38.x86_64                                                                                                      5/10 
  Verifying        : conntrack-tools-1.4.7-1.fc38.x86_64                                                                                              6/10 
  Verifying        : kubernetes-1.26.9-2.fc38.x86_64                                                                                                  7/10 
  Verifying        : kubernetes-client-1.26.9-2.fc38.x86_64                                                                                           8/10 
  Verifying        : kubernetes-master-1.26.9-2.fc38.x86_64                                                                                           9/10 
  Verifying        : kubernetes-node-1.26.9-2.fc38.x86_64                                                                                            10/10 

Installed:
  conntrack-tools-1.4.7-1.fc38.x86_64                 etcd-3.5.5-2.fc38.x86_64                             kubernetes-1.26.9-2.fc38.x86_64                
  kubernetes-client-1.26.9-2.fc38.x86_64              kubernetes-master-1.26.9-2.fc38.x86_64               kubernetes-node-1.26.9-2.fc38.x86_64           
  libnetfilter_cthelper-1.0.0-23.fc38.x86_64          libnetfilter_cttimeout-1.0.0-21.fc38.x86_64          libnetfilter_queue-1.0.5-4.fc38.x86_64         
  socat-1.7.4.4-2.fc38.x86_64                        

Complete!

Here are the services that need to be enabled:

sudo systemctl enable --now etcd
sudo systemctl enable --now kube-apiserver
sudo systemctl enable --now kube-controller-manager
sudo systemctl enable --now kube-scheduler
sudo systemctl enable --now kubelet
sudo systemctl enable --now kube-proxy
sudo systemctl enable --now docker

Check status:

sudo systemctl status etcd
sudo systemctl status kube-apiserver
sudo systemctl status kube-controller-manager
sudo systemctl status kube-scheduler
sudo systemctl status kubelet
sudo systemctl status kube-proxy
sudo systemctl status docker

For me two things did not work after all this "easy" installation process:

  • kube-apiserver
  • kubelet

Of course, life is not easy. While others install it flawlessly I am always chosen to go through suffering and pain in order to learn and become stronger.

I decided to uninstall the shit by running sudo dnf uninstall kubernetes etcd and try another method.

Sources:

Method 2 (didn't work for me):

I created Kubernetes repo inside YUM repos directory:

sudo nano /etc/yum.repos.d/kubernetes.repo

I added the following content, then saved and exited.

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=0 #NOTE: This was originally 1 but I set it to 0 to avoid yet another stupid error! It only skips the GPG check, no big deal.
gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

I then ran sudo yum install -y kubectl to install Kubernetes (apparently).

The thing worked (apparently):

Kubernetes                                                                                                                                                     115 kB/s | 182 kB     00:01    
Dependencies resolved.
===============================================================================================================================================================================================
 Package                                      Architecture                                Version                                        Repository                                       Size
===============================================================================================================================================================================================
Installing:
 kubectl                                      x86_64                                      1.28.2-0                                       kubernetes                                       11 M

Transaction Summary
===============================================================================================================================================================================================
Install  1 Package

Total download size: 11 M
Installed size: 48 M
Downloading Packages:
a24e42254b5a14b67b58c4633d29c27370c28ed6796a80c455a65acc813ff374-kubectl-1.28.2-0.x86_64.rpm                                                                   2.2 MB/s |  11 MB     00:05    
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                          2.2 MB/s |  11 MB     00:05     
Kubernetes                                                                                                                                                     2.4 kB/s | 975  B     00:00    
Importing GPG key 0x3E1BA8D5:
 Userid     : "Google Cloud Packages RPM Signing Key <gc-team@google.com>"
 Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
 From       : https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                       1/1 
  Installing       : kubectl-1.28.2-0.x86_64                                                                                                                                               1/1 
  Verifying        : kubectl-1.28.2-0.x86_64                                                                                                                                               1/1 

Installed:
  kubectl-1.28.2-0.x86_64                                                                                                                                                                      

Complete!

However of course it had to be wrong!

[terminator@skynet yum.repos.d]$ kubectl cluster-info
E0927 17:19:22.391116   70151 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0927 17:19:22.392277   70151 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0927 17:19:22.392636   70151 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0927 17:19:22.394451   70151 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0927 17:19:22.396595   70151 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server localhost:8080 was refused - did you specify the right host or port?

So again I ran sudo yum remove kubectl to get out of the shit! (again).

Method 3 (worked for me):

So becuase luck seemed to never be on my side I decided to try both methods at the same time Method 1 and Method 2.

The result was the same, nothing was running well (as far as my understanding went) but this time I tried something different. After a lot of reading on the Internet and several minutes of reflection I realized that mayvbe everything was installed but not configured, I had a strong suspicion that something else was left to install/configure.

I decided to install minikube by running:

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

sudo install minikube-linux-amd64 /usr/local/bin/minikube

This made a big difference becuase it configured kubectl to work with
minikube cluster and the default namespace by default.

Here's the output:

[terminator@skynet ~]$ minikube start
πŸ˜„  minikube v1.31.2 on Fedora 38 (vbox/amd64)
✨  Automatically selected the qemu2 driver. Other choices: none, ssh
🌐  Automatically selected the builtin network
❗  You are using the QEMU driver without a dedicated network, which doesn't support `minikube service` & `minikube tunnel` commands.
πŸ’Ώ  Downloading VM boot image ...
E0928 16:48:56.540837  100566 iso.go:90] Unable to download https://storage.googleapis.com/minikube-builds/iso/16971/minikube-v1.31.0-amd64.iso: getter: &{Ctx:context.Background Src:https://storage.googleapis.com/minikube-builds/iso/16971/minikube-v1.31.0-amd64.iso?checksum=file:https://storage.googleapis.com/minikube-builds/iso/16971/minikube-v1.31.0-amd64.iso.sha256 Dst:/home/hperez/.minikube/cache/iso/amd64/minikube-v1.31.0-amd64.iso.download Pwd: Mode:2 Umask:---------- Detectors:[0x3f9c8a8 0x3f9c8a8 0x3f9c8a8 0x3f9c8a8 0x3f9c8a8 0x3f9c8a8 0x3f9c8a8] Decompressors:map[bz2:0xc000056a60 gz:0xc000056a68 tar:0xc0000569f0 tar.bz2:0xc000056a10 tar.gz:0xc000056a20 tar.xz:0xc000056a30 tar.zst:0xc000056a40 tbz2:0xc000056a10 tgz:0xc000056a20 txz:0xc000056a30 tzst:0xc000056a40 xz:0xc000056a70 zip:0xc000056a80 zst:0xc000056a78] Getters:map[file:0xc0014dcb50 http:0xc00096ee60 https:0xc00096eeb0] Dir:false ProgressListener:0x3f579a0 Insecure:false DisableSymlinks:false Options:[0x12d0880]}: invalid checksum: Error downloading checksum file: bad response code: 404
πŸ’Ώ  Downloading VM boot image ...
    > minikube-v1.31.0-amd64.iso....:  65 B / 65 B [---------] 100.00% ? p/s 0s
    > minikube-v1.31.0-amd64.iso:  289.20 MiB / 289.20 MiB  100.00% 2.35 MiB p/
πŸ‘  Starting control plane node minikube in cluster minikube
πŸ’Ύ  Downloading Kubernetes v1.27.4 preload ...
    > preloaded-images-k8s-v18-v1...:  393.21 MiB / 393.21 MiB  100.00% 2.14 Mi
πŸ”₯  Creating qemu2 VM (CPUs=2, Memory=3400MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.27.4 on Docker 24.0.4 ...
    β–ͺ Generating certificates and keys ...
    β–ͺ Booting up control plane ...
    β–ͺ Configuring RBAC rules ...
πŸ”—  Configuring bridge CNI (Container Networking Interface) ...
    β–ͺ Using image gcr.io/k8s-minikube/storage-provisioner:v5
πŸ”Ž  Verifying Kubernetes components...
 🌟  Enabled addons: default-storageclass, storage-provisioner
πŸ„  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

Then I installed K9S by running curl -sS https://webinstall.dev/k9s | bash and this was the output:

[terminator@skynet ~]$ curl -sS https://webinstall.dev/k9s | bash

Thanks for using webi to install 'k9s@stable' on 'Linux/6.4.15-200.fc38.x86_64/x86_64'.
Have a problem? Experience a bug? Please let us know:
        https://github.com/webinstall/webi-installers/issues

Lovin' it? Say thanks with a Star on GitHub:
        https://github.com/webinstall/webi-installers

Downloading k9s from
https://github.com/derailed/k9s/releases/download/v0.27.4/k9s_Linux_amd64.tar.gz

Saved as /home/terminator/Downloads/webi/k9s/0.27.4/k9s_Linux_amd64.tar.gz
Extracting /home/terminator/Downloads/webi/k9s/0.27.4/k9s_Linux_amd64.tar.gz
Installing to /home/terminator/.local/opt/k9s-v0.27.4/bin/k9s
Installed 'k9s v0.27.4' as /home/terminator/.local/bin/k9s

Now everything is OK!!

Sources: