This guide is to setup a Kubernetes cluster based on k3s.
For windows, follow the instructions in "windows"
-
Access master node with ip: 192.168.1.61
- Option 1: Access directly using virtualbox.
Login: packer Password: packer
- Option 2: using ssh
ssh 192.168.1.61 -l packer
-
Install k3s on master
###### on master node ############################### curl -sfL https://get.k3s.io | K3S_TOKEN=mynodetoken sh -s - --no-deploy traefik # prepare config file distribution sudo cp --no-preserve=mode /etc/rancher/k3s/k3s.yaml k3s.yaml
-
Access worker node with ip: 192.168.1.62
ssh 192.168.1.62 -l packer
-
Install k3s on worker node
###### on worker node ############################### curl -sfL https://get.k3s.io | K3S_URL=https://192.168.1.61:6443 K3S_TOKEN=mynodetoken sh -
-
Repeat step 3 and 4 for ip 192.168.1.63
-
Verifing by going back to master node and run command
sudo kubectl get node # successful output packer@kubemaster:~$ sudo kubectl get node NAME STATUS ROLES AGE VERSION kubenode2 Ready <none> 34h v1.20.7+k3s1 kubemaster Ready control-plane,master 34h v1.20.7+k3s1 kubenode1 Ready <none> 34h v1.20.7+k3s1
- Download k3s configuration file
USER=packer MASTER_IP=192.168.1.61 scp $USER@$MASTER_IP:/home/$USER/k3s.yaml k3s.yaml # supply a password
- Copy config to kubectl default folder
sed -i "" "s/127.0.0.1/$MASTER_IP/g" k3s.yaml mkdir -p ~/.kube touch ~/.kube/config cp ~/.kube/config ~/.kube/config.bak KUBECONFIG=k3s.yaml:~/.kube/config kubectl config view --flatten > config mv config ~/.kube/config rm ~/.kube/config.bak
- Install kubectl
# install kubectl (https://kubernetes.io/docs/tasks/tools/) curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl" chmod +x ./kubectl sudo mv ./kubectl /usr/local/bin/kubectl sudo chown root: /usr/local/bin/kubectl kubectl version --client
- Install helm
# install helm3 curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash helm version