Jump to content

Microk8s: setup awal

From Haidhi Wiki
Revision as of 08:14, 26 May 2025 by SanzSkuy (talk | contribs) (SanzSkuy moved page Microk8s to Microk8s: setup awal without leaving a redirect)

Setup microk8s

Install di semua server atau node

sudo snap install microk8s --classic
sudo usermod -a -G microk8s $USER
mkdir -p ~/.kube
chmod 0700 ~/.kube
echo "alias kubectl='microk8s kubectl'" >> .bashrc

Tambah node, jalankan command dengan flag --worker di node lain

microk8s add-node

# Output
From the node you wish to join to this cluster, run the following:
microk8s join 192.168.1.120:25000/45d9f42aed4574d7324deea887f8f3cd/c12b4518f7c7

Use the '--worker' flag to join a node as a worker not running the control plane, eg:
microk8s join 192.168.1.120:25000/45d9f42aed4574d7324deea887f8f3cd/c12b4518f7c7 --worker

If the node you are adding is not reachable through the default interface you can use one of the following:
microk8s join 192.168.1.120:25000/45d9f42aed4574d7324deea887f8f3cd/c12b4518f7c7
microk8s join 172.17.0.1:25000/45d9f42aed4574d7324deea887f8f3cd/c12b4518f7c7

Cek

kubectl get nodes
kubectl get services

Testing run nginx

kubectl create deployment nginx --image=nginx
kubectl get pods