Skip to content

Latest commit

 

History

History
194 lines (137 loc) · 4.72 KB

1.1.kubeadmin-setup.md

File metadata and controls

194 lines (137 loc) · 4.72 KB

If you are using Macbook, start from here:

Download images and tools

Install virtualbox

https://www.virtualbox.org/wiki/Downloads

Install ubuntu iso from below link

https://releases.ubuntu.com/20.04/

Installation and configuration

Install virtualbox

Open virtualbox manager console

Ensure you have correct host network manager settings

  • properties->vboxnet0->192.168.34.1/24
  • If the subnet is different, you can edit and update it
  • Do not enable dhcp

Boot new VM

  • 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

Shutdown the OS, and set 2nd network adapter

  • 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

Login to the system and set ip for second adapter

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

Network configuration

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)

Set no password for sudo

%sudo ALL=(ALL:ALL) NOPASSWD:ALL

SSH to your virtual machine. and follow below instructure.

If you are not using Macbook, prepare a Linux OS and follow below instructure.

Install kubernetes by kubeadm

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/

Installing runtime

https://docs.docker.com/engine/install/ubuntu/

Update the apt package index and install packages to allow apt to use a repository over HTTPS:

$ sudo apt-get update
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

Add Docker’s official GPG key:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Add Docker repository

$ 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

Install kubernetes

Installing kubeadm, kubelet and kubectl

$ 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

kubeadm init

$ sudo kubeadm init \
 --image-repository registry.aliyuncs.com/google_containers \
 --kubernetes-version v1.19.15 \
 --apiserver-advertise-address=192.168.34.2

Copy kubeconfig

$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config

Untaint master

$ kubectl taint nodes --all node-role.kubernetes.io/master-

Join other node

$ kubeadm join 192.168.2.116:6443 --token oig5z4.hofxyadrsfwhzxa9 \
    --discovery-token-ca-cert-hash sha256:98172da8c89c09a176eb9e543e7decbc3a0dedf2c1a5ed16d83d16cb04e22513

Install cilium

$ helm install cilium cilium/cilium --version 1.9.1 \
    --namespace kube-system \
    --set kubeProxyReplacement=strict \
    --set k8sServiceHost=192.168.34.2 \
    --set k8sServicePort=6443

Install calico cni plugin

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