In this post we will learn how we can build kubernetes cluster using RKE.
What is RKE? RKE, or Rancher Kubernetes Engine, is a software tool that helps users install, manage, and upgrade Kubernetes clusters. RKE is a CNCF-certified product that runs within Docker containers and can be used on virtualized or bare-metal servers.
Things to do before build cluster in your vm / machine /server:
# change to sudo
sudo su
# 1. Disable Firewall
ufw disable
# 2. Disable Swap
swapoff -a; sed -i '/swap/d' /etc/fstab
# 3. Update sysctl settings for Kubernetes networking
cat >>/etc/sysctl.d/kubernetes.conf<<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
# 4. Install Docker Engine
apt update
apt install -y docker.io
usermod -aG docker $USER &&
usermod -aG docker linux &&
newgrp docker
systemctl enable docker
systemctl start docker
systemctl status docker
docker version
Install RKE
Now, we need to install RKE in our machine. Here we are use linux OS. You can copy paste below section and running it inside your terminal.
#!/bin/bash
# Download RKE
echo "Downloading RKE..."
sudo curl -L https://github.com/rancher/rke/releases/download/v1.6.2/rke_linux-amd64 -o /usr/local/bin/rke
# Set executable permission
echo "Setting executable permission for RKE..."
sudo chmod +x /usr/local/bin/rke
# Check installed version
echo "Checking RKE version..."
rke --version
cluster.yml
Create a new file and named it with cluster.yml
nodes:
- address: 192.158.59.42
port: "22"
internal_address: 192.158.59.42
role:
- controlplane
- worker
- etcd
hostname_override: dev-k8s-node1
user: linux
docker_socket: /var/run/docker.sock
ssh_key: ""
ssh_key_path: /root/.ssh/id_rsa
ssh_cert: ""
ssh_cert_path: ""
taints: []
- address: 192.158.59.43
port: "22"
internal_address: 192.158.59.43
role:
- controlplane
- worker
- etcd
hostname_override: dev-k8s-node2
user: linux
docker_socket: /var/run/docker.sock
ssh_key: ""
ssh_key_path: /root/.ssh/id_rsa
ssh_cert: ""
ssh_cert_path: ""
taints: []
- address: 192.158.59.44
port: "22"
internal_address: 192.158.59.44
role:
- controlplane
- worker
- etcd
hostname_override: dev-k8s-node3
user: linux
docker_socket: /var/run/docker.sock
ssh_key: ""
ssh_key_path: /root/.ssh/id_rsa
ssh_cert: ""
ssh_cert_path: ""
taints: []
network:
mtu: 0
options:
flannel_backend_type: vxlan
plugin: calico
rotate_encryption_key: false
dns:
provider: coredns
upstreamnameservers:
- 1.1.1.1
- 8.8.8.8
options:
coredns_autoscaler_priority_class_name: system-cluster-critical
coredns_priority_class_name: system-cluster-critical
ingress:
provider: nginx
options:
use-forwarded-headers: "true"
update_strategy:
strategy: RollingUpdate
rollingUpdate:
maxUnavailable: 1
services:
etcd:
snapshot: true
creation: 6h
retention: 24h
extra_args:
election-timeout: 5000
heartbeat-interval: 500
quota-backend-bytes: 5368709120
kubernetes_version: v1.30.4-rancher1-1
cluster_name: "k8s-dev"
monitoring:
provider: "metrics-server"
options: {}
node_selector: {}
update_strategy:
strategy: RollingUpdate
rollingUpdate:
maxUnavailable: 1
replicas: 3
tolerations:
- key: "node.kubernetes.io/unreachable"
operator: "Exists"
effect: "NoExecute"
tolerationseconds: 300
- key: "node.kubernetes.io/not-ready"
operator: "Exists"
effect: "NoExecute"
tolerationseconds: 300
metrics_server_priority_class_name: "system-cluster-critical"
Build Cluster
Its time to build our kubernetes cluster. Just run rke up on your terminal
rke up
