K8s的安装
Kubernetes安装 版本1.17.4
1、Kubernetes安装**
实验步骤:
1:实验设备
虚拟机 名 enp0s3 enp0s8
Ubuntu18.04 Kube-master 192.168.1.33 192.168.10.6
Ubuntu18.04 Kube-slave 192.168.1.34 192.168.10.5
master的IP配置如下:
sudo vi /etc/network/interfaces
master的域名配置如下:
2:换源
以master为例(所有节点都要换源):
将/etc/apt/sources.list文件替换为以下内容:
更新源 apt-get update
3:安装docker-ce
卸载旧的docker
sudo apt-get remove docker docker-engine docker.io containerd runc
安装依赖包
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
添加GPG key:
curl -fsSL https:/ mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add –
添加docker源:
安装docker
sudo apt-get install docker-ce docker-ce-cli containerd.io
4:kebeadm安装
sudo apt-get install kubelet=1.17.4-00 kubeadm=1.17.4-00 kubectl=1.17.4-00 --allow-unauthenticated
确保文件里有以下红色标记镜像包:
master导入包:
查看镜像:sudo docker images | grep k8s.gcr
slave导入三个包:
kubeadm初始化pod
sudo swapoff -a
sudo kubeadm init --image-repository=registry.aliyuncs.com/google_containers --kubernetes-version=v1.17.4 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.10.6
按照提示,输入以下内容:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown
(
i
d
−
u
)
:
(id -u):
(id−u):(id -g) $HOME/.kube/config
kubeadm join 192.168.10.6:6443 --token 686g4p.vchz2d3o1xkm6m58
–discovery-token-ca-cert-hash sha256:a9102fb47d741a64d9c10d5a49430c7fbec9b75e0801ec6ef72771a7d9a5b240
查看节点:
FAQ:
1:update出现GPG错误
W: GPG error: https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY FEEA9169307EA071 NO_PUBKEY 8B57C5C2836F4BEB
解决方法:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FEEA9169307EA071(这个是错误提示里的key)
2:sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.10.6
出错:
解决办法:
新建/etc/docker/daemon.json
{
“exec-opts”: [“native.cgroupdriver=systemd”]
}
重启docker和ku8s
systemctl restart docker
sudo kubeadm reset
4. kubeadm初始化出错
解决:
rm -rf /var/lib/etcd
5:sudo kubeadm join 192.168.10.6:6443 --token 686g4p.vchz2d3o1xkm6m58 --discovery-token-ca-cert-hash sha256:a9102fb47d741a64d9c10d5a49430c7fbec9b75e0801ec6ef72771a7d9a5b240出错:
[ERROR FileAvailable–etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists
[ERROR FileAvailable–etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists
[preflight] If you know what you are doing, you can make a check non-fatal with --ignore-preflight-errors=...
解决:
sudo rm -rf /etc/kubernetes/kubelet.conf
6:sudo docker pull calico/cni:v3.17.6出错
dial tcp 104.18.124.25:443: i/o timeout
解决:
vim /etc/docker/daemon.json
添加以下内容:
service docker restart 重启
更多推荐
所有评论(0)