Kubernetes(K8s) and Docker notes (1.1)

5/28, start reading <The Kubernetes Book>.

用了幾乎一天的時間研究install k8s with kubeadm and configure master node of k8s cluster,踩過不少坑,這裏記錄下來備查,也希望能幫助到有需要的同學。

(1)  install prerequisites (i'm using xubuntu 20.04)

$sudo apt install apt-transport-https ca-certificates curl software-properties-common

(2) install two repos keys

$curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -

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

(3) install k8s, latest version is v1.18.3

$sudo vim /etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main 

$sudo apt update && sudo apt install kubelet kubeadm kubectl
(21:59 dabs@CNU1343VF8 ~) > kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.3", GitCommit:"2e7996e3e2712684bc73f0dec0200d64eec7fe40", GitTreeState:"clean", BuildDate:"2020-05-20T12:49:29Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

(4) install Docker, latest version is v19.03.9

$sudo apt-key fingerprint 0EBFCD88

$sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

$sudo apt install docker-ce
(23:51 dabs@CNU1343VF8 ~) > sudo docker version
[sudo] password for dabs: 
Client: Docker Engine - Community
 Version:           19.03.9
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        9d988398e7
 Built:             Fri May 15 00:25:20 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.9
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       9d988398e7
  Built:            Fri May 15 00:23:53 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

(5) initialize a k8s cluster

15:07 dabs@CNU1343VF8 ~) > sudo kubeadm init
[sudo] password for dabs: 
W0528 15:07:17.068330   29276 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
[init] Using Kubernetes version: v1.18.3
[preflight] Running pre-flight checks
	[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR Swap]: running with swap on is not supported. Please disable swap
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

Here are two warnings and 1 fatal error:

Warning#1: 

W0528 15:07:17.068330   29276 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io

One can ignore this warning.

Warning#2:

[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/

(15:22 dabs@CNU1343VF8 docker) > sudo vim /etc/docker/daemon.json
{
 "exec-opts":["native.cgroupdriver=systemd"]
}

(15:22 dabs@CNU1343VF8 docker) > sudo systemctl restart docker && sudo systemctl status docker

Fatal Error#1:

[ERROR Swap]: running with swap on is not supported. Please disable swap
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

One need to turn off swap:

(15:10 dabs@CNU1343VF8 ~) > sudo swapoff -a

(to be continued)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章