1.禁用iptables


每台机器禁用iptables 避免和docker 的iptables冲突:

systemctl stop firewalld

systemctl disable firewalld

禁用selinux:

vim /etc/selinux/config

#SELINUX=enforcing

SELINUX=disabled


2.安装docker (master node)国外的源

 cat > /etc/yum.repos.d/docker.repo <<-EOF

[dockerrepo]

name=Docker Repository

baseurl=https://yum.dockerproject.org/repo/experimental/centos/7/

enabled=1

gpgcheck=1

gpgkey=https://yum.dockerproject.org/gpg

EOF

yum -y install docker-engine

systemctl enable docker && systemctl start docker


3.安装k8s (master node)国外的源

cat < /etc/yum.repos.d/kubernetes.repo

[kubernetes]

name=Kubernetes

baseurl=http://yum.kubernetes.io/repos/kubernetes-el7-x86_64

enabled=1

gpgcheck=1

repo_gpgcheck=1

gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg

       https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

EOF


yum install -y kubelet kubeadm kubectl kubernetes-cni  &&    systemctl enable kubelet && systemctl start kubelet


4.初始化master

kubeadm init   --token=b1f4c5.94d2933fea71f20b

修改配制文件  /etc/kubernetes/manifests/

etcd.json 

--listen-client-urls=http://0.0.0.0:2379

--advertise-client-urls=http://172.22.0.4:2379(本机ip)

kube-apiserver.json

--insecure-bind-address=0.0.0.0

5.增加node

kubeadm join --token b1f4c5.94d2933fea71f20b 172.22.0.4(master ip)

修改配制文件

/etc/systemd/system/kubelet.service.d/10-kubeadm.conf 

在ExecStart=/usr/bin/kubelet 这个后面增加

--hostname-override=172.22.0.6(node自己的ip)

systemctl daemon-reload && systemctl restart kubelet

6.安装calico(在master执行)

下载 http://docs.projectcalico.org/v1.5/getting-started/kubernetes/installation/hosted/kubeadm/calico.yaml

修改  etcd_endpoints: "http://172.22.0.4:2379"(master ip)

删除关于etcd DaemonSet Service内容


kubectl create -f calico.yaml


测试是使用的阿里去国外的服务器,如果使用国内的有一个镜像是pull 不下来的.