码迷,mamicode.com
首页 > 其他好文 > 详细

k8s master init and add node

时间:2018-07-18 17:14:42      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:admin   pad   precise   add   hostname   check   cert   node   rop   

k8s tutorial series main reference

1. add google apt-key

reference kubernetes添加不了google apt-key

k8s repository (中科大源)

deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
deb http://ppa.launchpad.net/tbfr/zabbix/ubuntu precise main
deb-src http://ppa.launchpad.net/tbfr/zabbix/ubuntu precise main
deb [arch=amd64] https://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial main
deb [arch=amd64] https://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial main

ali repository

deb http://mirrors.aliyuncs.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial-backports main restricted universe multiverse

2. k8s master init

reference kubeadm 搭建 kubernetes 集群

change hostname

echo "192-168-43-134.master" > /etc/hostname
echo "127.0.0.1   192-168-43-134.master" >> /etc/hosts
sysctl kernel.hostname=192-168-43-134.master

pull images

images=(kube-proxy-amd64:v1.11.0 coredns:1.1.3 pause:3.1 kubedns-amd64:1.7 kube-scheduler-amd64:v1.11.0 kube-controller-manager-amd64:v1.11.0 kube-apiserver-amd64:v1.11.0 etcd-amd64:3.2.18 pause-amd64:3.1)
for imageName in ${images[@]} ; do
  docker pull vickeywu/$imageName
  docker tag vickeywu/$imageName k8s.gcr.io/$imageName
  docker rmi vickeywu/$imageName
done

shutdown swap and start kubelet

kubeadm reset
sudo swapoff -a
systemctl stop kubelet
systemctl enable kubelet
systemctl start kubelet

update kube* (just one time)

apt-get update
apt-get install -y kubelet kubeadm kubectl

kubeadm init

kubeadm init --kubernetes-version=v1.11.0 --apiserver-advertise-address 192.168.43.131 --pod-network-cidr=10.244.0.0/16 --skip-preflight-checks

copy token from init output(use fork8s nodes join master cluster)

  kubeadm join 192.168.43.131:6443 --token yepdrb.7le3m7v0lrzuqkbj --discovery-token-ca-cert-hash sha256:6594be2785a7e216fda80ccf5560924aa0c802f08afdc187006a711fb75b40eb

run the following as a regular user and root

su vickey/root
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
echo "source <(kubectl completion bash)" >> ~/.bashrc

apply network solution

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

3. k8s node add to master cluster(use this command when you wanna add node)

 kubeadm join 192.168.43.131:6443 --token yepdrb.7le3m7v0lrzuqkbj --discovery-token-ca-cert-hash sha256:6594be2785a7e216fda80ccf5560924aa0c802f08afdc187006a711fb75b40eb

manually pull flannel network image

reference blog

docker pull vickeywu/flannel:v0.10.0-amd64
docker tag vickeywu/flannel:v0.10.0-amd64 quay.io/coreos/flannel:v0.10.0-amd64
docker rmi vickeywu/flannel:v0.10.0-amd64

k8s master init and add node

标签:admin   pad   precise   add   hostname   check   cert   node   rop   

原文地址:https://www.cnblogs.com/vickey-wu/p/9329135.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!