Install Kubernetes on Rocky Linux
Would you like to get a Kubernetes cluster up and running in Rocky Linux? This guide shows you how using the Rancher Kubernetes Engine, abbreviated as RKE2.
Pre-requisites
- You’ll need three Rocky Linux machines. For a three-node cluster, each one can be a server node and run the control-plane and etcd.
- These machines need to be able to communicate with each other.
- The Firewall
See the RKE2 Requirements section for the various ports that need to be open.
This is highly dependent on your own systems and beyond the scope of this article. For now, you can set your zone to trusted with the following
command. Note this isn’t recommended for production-based systems.
# firewall-cmd --set-default trusted
and# firewall-cmd --reload
- It’s a good idea for each machine to have a resolvable hostname. If the result of
$ hostname
islocalhost.localdomain
or some variation, consider setting a hostname that resolves to that machine.
Install the First Server Node
The very first server generates a server token. All the others will use this token. This guide assumes you’d like to install the latest stable version.
- Run the installer:
# curl -sfL https://get.rke2.io | sh -
- Start the service:
$ sudo systemctl enable --now rke2-server
- Copy the token from the server-node:
$ cat /var/lib/rancher/rke2/server/node-token
you’ll need this for the next step It will look something like this:K107cf38c65d1e518f3ea48b3ba773d657ad301d90723cbd084f97dee2f6bd7bd23::server:4fb391fb0c743ea5d90f5bb2e15dd751
To access your cluster using kubectl
, copy the rke2.yaml
from the /etc/rancher/rke2
. Be sure to change the server: https://127.0.0.1:6443
section to the resolvable name or ip of the machine.
Install the Other Server Nodes
You’ll need at least three machines to reliably run Kubernetes.
- Run the installer:
# curl -sfL https://get.rke2.io | sh -
- Add the directory for the config file
mkdir -p /etc/rancher/rke2/
if it doesn’t exist already. - Create the config file
vim /etc/rancher/rke2/config.yaml
server: https://s01.devopsofficehours.com:9345
token: K107cf38c65d1e518f3ea48b3ba773d657ad301d90723cbd084f97dee2f6bd7bd23::server:4fb391fb0c743ea5d90f5bb2e15dd751
- Start the service
$ sudo systemctl enable --now rke2-agent
Do you need help beyond this guide? Get in Touch and we can talk about how we can help.