Skip to main content

1、精简kubeadm安装

一、配置hostname

vi /etc/hosts 192.168.111.111 ubuntu1

192.168.111.112 ubuntu2

192.168.111.113 ubuntu3

二、配置安装源

vi /etc/apt/sources.list

系统安装源

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

kubeadm及kubernetes组件安装源

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

三、安装docker和kubeadm,kubectl,kubelet软件包

apt-get -y install docker.io

apt-get install -y kubelet kubeadm kubectl --allow-unauthenticated

四、使用kubeadmin初始化master节点

kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.111.111

五、执行如下命令来配置kubect

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown $(id -u):$(id -g) $HOME/.kube/config

六、Slave节点加入集群

kubeadm join 192.168.111.111:6443 --token tlizx5.2twn790d3x9jbryt --discovery-token-ca-cert-hash sha256:13828f66b212e2968f76b94d943478aa671a59b40721712fce583155a605be23

查看集群的节点状态

kubectl get node

kubectl get pod -n kube-system -o wide

七、安装网络插件canal

配置canal的RBAC权限

kubectl apply -f https://docs.projectcalico.org/v3.0/getting-started/kubernetes/installation/hosted/canal/rbac.yaml

部署canal的DaemonSet

kubectl apply -f https://docs.projectcalico.org/v3.0/getting-started/kubernetes/installation/hosted/canal/canal.yaml

查看canal的安装状态。

kubectl get pod -n kube-system -o wide

可以看到canal和kube-dns都已经运行正常,一个基本功能正常的测试环境就部署完毕了。

让master也运行pod(默认master不运行pod),这样在测试环境做是可以的,不建议在生产环境如此操作。

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

docker tag k8s.gcr.io/kube-proxy:v1.12.1 k8s.gcr.io/kube-proxy:v1.12.2

docker tag k8s.gcr.io/kube-scheduler:v1.12.1 k8s.gcr.io/kube-scheduler:v1.12.2

docker tag k8s.gcr.io/kube-apiserver:v1.12.1 k8s.gcr.io/kube-apiserver:v1.12.2

docker tag k8s.gcr.io/kube-controller-manager:v1.12.1 k8s.gcr.io/kube-controller-manager:v1.12.2

docker rmi tag k8s.gcr.io/kube-proxy:v1.12.1

docker rmi tag k8s.gcr.io/kube-scheduler:v1.12.1

docker rmi tag k8s.gcr.io/kube-apiserver:v1.12.1

docker rmi tag k8s.gcr.io/kube-controller-manager:v1.12.1