If you are using Macbook, start from here:
https://www.virtualbox.org/wiki/Downloads
https://releases.ubuntu.com/20.04/
- properties->vboxnet0->192.168.34.1/24
- If the subnet is different, you can edit and update it
- Do not enable dhcp
- Click new button
- Choose OS as ubuntu 64bit and 30G disk, make sure your #CPU>=2
- Start VM, choose the downloaded ubuntu ISO and follow the installation wizard
- Specify username/password like
cadmin/cadmin
- Install ssh server
- Do not install built-in kubenernetes
- Wait enough long for the os installation complete
- Go to VM->settings->network->adapter 2
- Enable the adapter and select host only adapter, and choose vboxnet0,
vboxnet0
the host network name configured above
vi /etc/netplan/00-installer-config.yaml
network:
ethernets:
enp0s3:
dhcp4: true
enp0s8:
dhcp4: no
addresses:
- 192.168.34.2/24
version: 2
netplan apply
Now your VM has two adapters:
- One is NAT which will get an IP automatically, generally it's 10.0.2.15, this interface is for external access from your VM
- One is host adapter which need create extra ip, which is configured as 192.168.34.2 the reason we need the host adapter and static IP is then we can set this static IP as k8s advertise IP and you can move your VM in different everywhere.(otherwise your VM IP would be changed in different environment)
%sudo ALL=(ALL:ALL) NOPASSWD:ALL
If you are not using Macbook, prepare a Linux OS and follow below instructure.
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
https://docs.docker.com/engine/install/ubuntu/
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
$ sudo apt-get update
$ sudo apt-get install -y docker-ce docker-ce-cli containerd.io
$ cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
EOF
$ curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add
$ sudo apt-get update
$ sudo apt-get install -y kubelet=1.19.15-00 kubeadm=1.19.15-00 kubectl=1.19.15-00
$ sudo apt-mark hold kubelet kubeadm kubectl
$ sudo kubeadm init \
--image-repository registry.aliyuncs.com/google_containers \
--kubernetes-version v1.19.15 \
--apiserver-advertise-address=192.168.34.2
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
$ kubectl taint nodes --all node-role.kubernetes.io/master-
$ kubeadm join 192.168.2.116:6443 --token oig5z4.hofxyadrsfwhzxa9 \
--discovery-token-ca-cert-hash sha256:98172da8c89c09a176eb9e543e7decbc3a0dedf2c1a5ed16d83d16cb04e22513
$ helm install cilium cilium/cilium --version 1.9.1 \
--namespace kube-system \
--set kubeProxyReplacement=strict \
--set k8sServiceHost=192.168.34.2 \
--set k8sServicePort=6443
https://docs.projectcalico.org/getting-started/kubernetes/quickstart
$ kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml
$ kubectl create -f https://docs.projectcalico.org/manifests/custom-resources.yaml
$ for i in `kubectl api-resources | grep true | awk '{print \$1}'`; do echo $i;kubectl get $i -n rook-ceph; done