Hyper-v

Simple RKE2, Rancher and Longhorn Install



Learn how to install RKE2 (Kubernetes), and I will also demo how to install Rancher, Longhorn and other packages using Helm. Install Rancher Server, your central control plane, and create RKE2 clusters with ease using its user-friendly web interface.

Pre-Req For RKE2 Server
1) Stop firewall
systemctl disable –now ufw

2) Run updates and upgrade and install packages
apt update
apt install nfs-common open-iscsi -y
apt upgrade -y

3) Automatic removal of unnecessary packages.
apt autoremove -y

RKE2 Server Installation
1) Install RKE2 server
curl -sfL | INSTALL_RKE2_TYPE=server sh –
For specific RKE2 Server version
curl -sfL | INSTALL_RKE2_CHANNEL=v1.26 INSTALL_RKE2_TYPE=server sh –

2) Enable and start RKE2 Server service
systemctl enable rke2-server.service
systemctl start rke2-server.service
Alternatively, you can do this, which does the same thing
systemctl enable –now rke2-server.service

3) Check is RKE2 Server is running
systemctl status rke2-server.service

Setup Kubectl (on RKE2 Server)
1) Simlink all the things – kubectl
ln -s $(find /var/lib/rancher/rke2/data/ -name kubectl) /usr/local/bin/kubectl
Alternatively, you can do this, which download the binary rather than using simlink. But note that you are downloading specific version of kubectl. Getting it from the RKE2 Server is a better option (aka simlink)
curl -L# -o /usr/local/bin/kubectl
chomd 755 /usr/local/bin/kubectl
2) Add kubectl conf
export KUBECONFIG=/etc/rancher/rke2/rke2.yaml
Permanent
nano .bashrc
export PATH=$PATH:/etc/rancher/rke2/rke2.yaml
3) Check if kubectl works
kubectl get node -o wide
To watch as you start the RKE2 agent use this command.
kubectl get node -o wide -w

Get RKE2 Server IP address And Token (on RKE2 Server)
1) Get server IP address and copy it somewhere
ip addr | grep inet
2) Get server token and copy it somewhere
cat /var/lib/rancher/rke2/server/node-token

Pre-Req For RKE2 Agents
1) Stop the software firewall
systemctl disable –now ufw
2) Run updates and upgrade and install nfs
apt update
apt install nfs-common -y open-iscsi
apt upgrade -y
This is require for Longhorn
iscsiadm –version
3) Remove downloaded update
apt autoremove -y

RKE2 Agent Installation
1) Install RKE2 agent
curl -sfL | INSTALL_RKE2_TYPE=agent sh –
For specific RKE2 Server version
curl -sfL | INSTALL_RKE2_CHANNEL=v1.26 INSTALL_RKE2_TYPE=agent sh –
2) Create config directory
mkdir -p /etc/rancher/rke2/
3) Create config.yaml file for RKE2 agent
nano /etc/rancher/rke2/config.yaml
Enter text shown below.
server:
token: #TOKEN_FROM_RKE2_SERVER#
The #RANCHER_SERVER_IP_ADDRESS# is the ip address of RKE2 Server Install – Step 5
The #TOKEN_FROM_RANCHER_SERVER# is the ip address of RKE2 Server Install – Step 6
4) Enable and start RKE2 Agent service
systemctl enable rke2-agent.service
systemctl start rke2-agent.service
Alternatively, you can do this, which does the same thing
systemctl enable –now rke2-agent.service
systemctl status rke2-agent.service
5) Check is RKE2 Agent is running
systemctl status rke2-agent.service
Run this command in RKE2 Server to check if RKE2 Agents are communicating with the RKE2 Server.
kubectl get node -o wide
Run this command in RKE2 Server to check all pods status.
kubectl get pod -A

*** NOTE ***
Repeat “RKE2 Agent Installation”, if you have multiple RKE2 agents.

Get/Change FQDN
1) Get/Change Current hostname
nano /etc/hostname
2) Add FQDN here
nano /etc/hosts
Add following line
#RANCHER_SERVER_IP_ADDRESS# rancher.xynet.local

Rancher Install Using Helm (on RKE2 Server)
1) Install Helm
curl -#L | bash
2) Add Rancher to repo
helm repo add rancher-latest
3) Add Jetstack (cert mgr) to repo
helm repo add jetstack
4) Create cert-manager CRD
kubectl apply -f
5) Helm install Jetstack
helm upgrade -i cert-manager jetstack/cert-manager –namespace cert-manager –create-namespace
6) Helm install Rancher
helm upgrade -i rancher rancher-latest/rancher –create-namespace –namespace cattle-system –set hostname=rancher.xynet.local –set bootstrapPassword=rabi123 –set replicas=1 –set global.cattle.psp.enabled=false
7) Check if Rancher and Jetstack (CertManager) containers are running
kubectl get pod -A
curl -k

Lognhorn Install Using Helm (on RKE2 Server)
1) Add Longhorn to repo
helm repo add longhorn
2) Update
helm repo update
3) Helm install Longhorn chart
helm upgrade -i longhorn longhorn/longhorn –namespace longhorn-system –create-namespace
4) Check if Longhorn container is running
kubectl get pod -A

#linux #rancher #kubernetes #helm

[ad_2]

source

Related Articles

21 Comments

  1. Great Video great instructions but your links are truncated and I cannot copy them from your instructions. Is there anyway you can make those available in get hub or a textfile where it doesn't get truncated. Thank you Great work by the way.

  2. Great video, naturally I stuffed up the rancher hostname – what a process cleaning that up is! A reinstall installs broken rancher that you can't log into you have to use the rancher resource cleanup scripts to fix it

  3. finally got my cluster working. Had so much issues with creating it from rancher dashboard. I have a ubuntu cluster and I see a lot of context deadline exceeded error until the cluster eventually comes up. Not sure if this is of concern.

  4. I spun up a new AWS EC2 RHEL 8 instance and started through your procedure but RKE2 would not "start" / I noticed that containerd and kubectl were NOT installed and I don't have a Redhat account to get these. Does that sound right? Did ubuntu include these? Can I use an alternative library/repository setup vs the Redhat ("paid") subscription to get these installed?

  5. Thanks!
    But there are a few inaccuracies in text annotation:
    1. Permanent add KUBECONFIG in environment:

    echo "export KUBECONFIG=/etc/rancher/rke2/rke2.yaml" >> .bashrc
    or
    mkdir ~/.kube && cp /etc/rancher/rke2/rke2.yaml ~/.kube/config.
    ~/.kube/config – is default place config for kubectl.
    2. In Debian 12 no packet iptables.
    apt install iptables -y
    3. By default RKE2 install CNI canal. I have was problem with this. I wrote config.yaml for install RKE2:
    cat <<EOF > /root/config.yaml

    write-kubeconfig-mode: "0644"

    cluster-domain: "k8s.local"

    cni: calico

    EOF

    https://docs.rke2.io/reference/server_config – for more info.

  6. Thank you! One of the misconceptions I had is that the Rancher UI would be available after the RKE2-SERVER service had started, but I wasn't completing the rancher/latest helm chart installation. Much appreciated!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button