ubuntu 安装k8s 1.18.1

4 篇文章 0 订阅
3 篇文章 0 订阅

ubuntu 安装k8s 1.18.1

1.禁用swap

swapoff -a

/etc/fstab里包含swap那一行注释掉

2.修改ubuntu系统镜像源:

把/etc/apt/sources.list文件修改成如下

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

然后执行

sudo apt-get update

sudo apt-get upgrade

 

3.安装docker

apt-get install -y docker.io

apt-get install -y vim

 

vim  /etc/docker/daemon.json

{

   "registry-mirrors": ["https://alzgoonw.mirror.aliyuncs.com"],

   "live-restore": true

}

systemctl daemon-reload

systemctl restart docker

systemctl enable docker

 

# vim /etc/apt/sources.list.d/kubernetes.list

deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main

apt install curl

apt update && apt upgrade

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

 

这里经常过不去,还需要安装

apt install -y gnupg2

 

4,安装kubeadm,kubeadm,kubeadm

apt-get install -y kubeadm=1.18.1-00 kubelet=1.18.1-00 kubeadm=1.18.1-00

apt-mark hold kubelet kubeadm kubectl

wget https://docs.projectcalico.org/manifests/calico.yaml 

 

如果 使用BGP,就一定修改 CALICO_IPV$POOL_IPIP为Never

image.png

 

root@node121:~# cat  /etc/hosts

127.0.0.1       localhost

127.0.1.1       ubuntu

# The following lines are desirable for IPv6 capable hosts

::1     localhost ip6-localhost ip6-loopback

10.10.10.120 node120

10.10.10.121 node121

 

vim kubeadm-config.yaml

 

apiVersion: kubeadm.k8s.io/v1beta2

kind: ClusterConfiguration

kubernetesVersion: 1.18.1 #<-- Use the word stable for newest version

controlPlaneEndpoint: "node120:6443" #<-- Use the node alias not the IP

networking:

 podSubnet: 192.168.0.0/16

 

我还因为 copy 过来多了字符,导致后面 不能执行

 

5. 拉镜像

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.18.1

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.18.1

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.18.1

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.2

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.4.3-0

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.6.7

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.18.1

docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.18.1 k8s.gcr.io/kube-controller-manager:v1.18.1

docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.18.1 k8s.gcr.io/kube-scheduler:v1.18.1

docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.18.1 k8s.gcr.io/kube-proxy:v1.18.1

docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.2 k8s.gcr.io/pause:3.2

docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.4.3-0 k8s.gcr.io/etcd:3.4.3-0

docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.6.7 k8s.gcr.io/coredns:1.6.7

docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.18.1 k8s.gcr.io/kube-apiserver:v1.18.1

 

6.初始化集群

kubeadm init --config=kubeadm-config.yaml --upload-certs | tee kubeadm-init.out  

 

kubectl get nodes

cp /etc/kubernetes/admin.conf  /root/.kube/config

 

kubectl apply -f calico.yaml  

中间还因为 注释了192.168.0.0/16 两行 而出错,修正后继续

 

 

7.worknode同样步骤 (1-4步)

cat  /etc/hosts

127.0.0.1       localhost

127.0.1.1       ubuntu

# The following lines are desirable for IPv6 capable hosts

::1     localhost ip6-localhost ip6-loopback

10.10.10.120 node120

10.10.10.121 node121

ff02::1 ip6-allnodes

 

kubeadm join node120:6443 --token 6qivdr.y5sgkmf4mqbvjrjp     --discovery-token-ca-cert-hash sha256:63bd8dc167040a8211e9e3e9c86e9e98b8b5e73783c9b90519dfc0745442c9af

 

8,其它

curl -O -L https://github.com/projectcalico/calicoctl/releases/download/v1.6.4/calicoctl (验证了这个比较坑,应该现在最新版本)

https://github.com/projectcalico/calicoctl/releases/download/v3.17.0/calicoctl-linux-amd64

或者看 https://github.com/projectcalico/calicoctl/releases

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值