Pada halaman kali ini kita akan mensetup kubernetes cluster non-Ha dengan K3s. K3s adalah versi lightweight dari Kubernetes. Mudah untuk di deploy dan membutuhkan lebih sedikik resource yang memang dirancang untuk berjalan pada perangkat dengan sumber daya terbatas.
Dalam sebuah Kubernetes cluster, terdapat dua peran utama:
Di halaman ini kita akan mensetup cluster Non-HA (High Availability) yang hanya memiliki satu Control Plane (Master Node) yang mengelola seluruh cluster. Dalam production cluster High Availability lebih sering dipakai, di mana terdapat beberapa Control Plane yang bekerja secara redundant untuk memastikan cluster tetap beroperasi meskipun ada satu atau lebih node Control Plane yang gagal.
Saya telah menyiapkan beberapa vm ubuntu 24.04 dengan
k3s-master (Master Nodes)
k3s-worker-1 (Worker Nodes)
k3s-worker-2 (Worker Nodes)
k3s-worker-3 (Worker Nodes)
Pada master node instal k3s dengan:
curl -sfL https://get.k3s.io | sh -
ilyasa@k3s-master:~$ curl -sfL https://get.k3s.io | sh -
[INFO] Finding release for channel stable
[INFO] Using v1.30.3+k3s1 as release
[INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.30.3+k3s1/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.30.3+k3s1/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO] Host iptables-save/iptables-restore tools not found
[INFO] Host ip6tables-save/ip6tables-restore tools not found
[INFO] systemd: Starting k3s
Untuk installasi k3s pada worker ada beberapa parameter yang harus dikonfigurasi K3S_URL
Url dari master node dan K3S_TOKEN
token ini terletak pada /var/lib/rancher/k3s/server/node-token
di master node
ilyasa@k3s-master:~$ sudo cat /var/lib/rancher/k3s/server/node-token
K1018a369b490cad5c936d377a555a76293b2d2532deb544fd1a05e30b004196cc3::server:41c361d05e560b6b20f4a17fbb557d1c
Untuk installasi:
curl -sfL https://get.k3s.io | K3S_URL=https://192.168.100.30:6443 K3S_TOKEN=K1018a369b490cad5c93
6d377a555a76293b2d2532deb544fd1a05e30b004196cc3::server:41c361d05e560b6b20f4a17fbb557d1c sh -
ilyasa@k3s-worker-1:~$ curl -sfL https://get.k3s.io | K3S_URL=https://192.168.100.30:6443 K3S_TOKEN=K1018a369b490cad5c93
6d377a555a76293b2d2532deb544fd1a05e30b004196cc3::server:41c361d05e560b6b20f4a17fbb557d1c sh -
[INFO] Finding release for channel stable
[INFO] Using v1.30.3+k3s1 as release
[INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.30.3+k3s1/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.30.3+k3s1/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-agent-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s-agent.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s-agent.service
[INFO] systemd: Enabling k3s-agent unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s-agent.service → /etc/systemd/system/k3s-agent.service.
[INFO] Host iptables-save/iptables-restore tools not found
[INFO] Host ip6tables-save/ip6tables-restore tools not found
[INFO] systemd: Starting k3s-agent
ilyasa@k3s-master:~$ sudo kubectl get nodes
NAME STATUS ROLES AGE VERSION
k3s-master Ready control-plane,master 63m v1.30.3+k3s1
k3s-worker-1 Ready <none> 36m v1.30.3+k3s1
k3s-worker-2 Ready <none> 9m13s v1.30.3+k3s1
k3s-worker-3 Ready <none> 60s v1.30.3+k3s1