Ubuntu 20.04 安装k8s
1、配置源
修改Sources.list
可以打开 /etc/apt/sources.list 文件,添加一行
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
或者在/etc/apt/sources.list.d下添加一个文件
kubernetes.list
文件内容
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
2、执行apt-get update,如果出现
The following signatures couldn’t be verified because the public key is not available
需要添加key
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add
3、开始安装
apt-get install -y kubelet kubeadm kubectl --allow-unauthenticated
4、执行kubeadm init
提示资源不足,修改cpu,Ram,disable swap
5、swapoff -a
6、从新执行
kubeadm init
后面一直卡着,新建一个sh 文件,内容如下
#!/bin/bash docker pull mirrorgooglecontainers/kube-apiserver:v1.13.3 docker pull mirrorgooglecontainers/kube-controller-manager:v1.13.3 docker pull mirrorgooglecontainers/kube-scheduler:v1.13.3 docker pull mirrorgooglecontainers/kube-proxy:v1.13.3 docker pull mirrorgooglecontainers/pause:3.1 docker pull mirrorgooglecontainers/etcd:3.2.24 docker pull coredns/coredns:1.2.6 docker tag mirrorgooglecontainers/kube-proxy:v1.13.3 k8s.gcr.io/kube-proxy:v1.13.3 docker tag mirrorgooglecontainers/kube-scheduler:v1.13.3 k8s.gcr.io/kube-scheduler:v1.13.3 docker tag mirrorgooglecontainers/kube-apiserver:v1.13.3 k8s.gcr.io/kube-apiserver:v1.13.3 docker tag mirrorgooglecontainers/kube-controller-manager:v1.13.3 k8s.gcr.io/kube-controller-manager:v1.13.3 docker tag mirrorgooglecontainers/etcd:3.2.24 k8s.gcr.io/etcd:3.2.24 docker tag coredns/coredns:1.2.6 k8s.gcr.io/coredns:1.2.6 docker tag mirrorgooglecontainers/pause:3.1 k8s.gcr.io/pause:3.1 docker rmi mirrorgooglecontainers/kube-apiserver:v1.13.3 docker rmi mirrorgooglecontainers/kube-controller-manager:v1.13.3 docker rmi mirrorgooglecontainers/kube-scheduler:v1.13.3 docker rmi mirrorgooglecontainers/kube-proxy:v1.13.3 docker rmi mirrorgooglecontainers/pause:3.1 docker rmi mirrorgooglecontainers/etcd:3.2.24 docker rmi coredns/coredns:1.2.6:q
执行
7、初始化镜像
kubeadm init --kubernetes-version=v1.13.3 --pod-network-cidr=10.244.0.0/16
无法执行,卸载kubeadm等
apt-get remove -y kubelet kubeadm kubectl
8、再安装
apt-get install -y kubernetes-cni=0.6.0-00 --allow-downgrades
apt-get install -y kubectl=1.13.3-00 --allow-downgrades --allow-unauthenticated
apt-get install -y kubelet=1.13.3-00 kubeadm=1.13.3-00 --allow-unauthenticated
9、从新执行第7步操作
kubeadm init --kubernetes-version=v1.13.3 --pod-network-cidr=10.244.0.0/16
10、如果在使用过程中出现
The connection to the server localhost:xxx was refused - did you specify the right host or port?
export KUBECONFIG=/etc/kubernetes/admin.conf
本博客是个人工作中记录,更深层次的问题可以提供有偿技术支持。
另外建了几个QQ技术群:
2、全栈技术群:616945527
2、硬件嵌入式开发: 75764412
3、Go语言交流群:9924600
闲置域名WWW.EXAI.CN (超级人工智能)出售。
另外建了几个QQ技术群:
2、全栈技术群:616945527
2、硬件嵌入式开发: 75764412
3、Go语言交流群:9924600
闲置域名WWW.EXAI.CN (超级人工智能)出售。