----------------------------------------------------------------------------------------------------------------------------
执行主机:192.168.1.15and16and18
下载基础镜像
docker pull gcr.io/google_containers/pause-amd64
下载calico所需的镜像
docker pull quay.io/calico/node
docker pull quay.io/calico/kube-controllers
docker pull quay.io/calico/cni
更改kubelet二进制服务文件,执行network插件为cni
systemctl daemon-reload
systemctl restart kubelet
----------------------------------------------------------------------------------------------------------------------------
执行主机:192.168.1.15or16or18
下载calico官方的yaml文件
mkdir /root/calico
cd /root/calico
wget
https://docs.projectcalico.org/v3.0/getting-started/kubernetes/installation/rbac.yaml
wget
https://docs.projectcalico.org/v3.0/getting-started/kubernetes/installation/hosted/calico.yaml
----------------------------------------------------------------------------------------------------------------------------
执行主机:192.168.1.15or16or18
更改calico.yaml文件
替换 Etcd 地址
sed -i 's@.*etcd_endpoints:.*@\ \ etcd_endpoints:\ \"https://192.168.1.8:2379,https://192.168.1.9:2379,https://192.168.1.10:2379\"@gi' calico.yaml
替换 Etcd 证书
export ETCD_CERT=`cat /etc/kubernetes/ssl/kubernetes.pem | base64 | tr -d '\n'`
export ETCD_KEY=`cat /etc/kubernetes/ssl/kubernetes-key.pem | base64 | tr -d '\n'`
export ETCD_CA=`cat /etc/kubernetes/ssl/k8s-root-ca.pem | base64 | tr -d '\n'`
sed -i "s@.*etcd-cert:.*@\ \ etcd-cert:\ ${ETCD_CERT}@gi" calico.yaml
sed -i "s@.*etcd-key:.*@\ \ etcd-key:\ ${ETCD_KEY}@gi" calico.yaml
sed -i "s@.*etcd-ca:.*@\ \ etcd-ca:\ ${ETCD_CA}@gi" calico.yaml
增加卷挂载目录
sed -i 's@.*etcd_ca:.*@\ \ etcd_ca:\ "/calico-secrets/etcd-ca"@gi' calico.yaml
sed -i 's@.*etcd_cert:.*@\ \ etcd_cert:\ "/calico-secrets/etcd-cert"@gi' calico.yaml
sed -i 's@.*etcd_key:.*@\ \ etcd_key:\ "/calico-secrets/etcd-key"@gi' calico.yaml
更改pod网络范围
sed -i s/192.168.0.0/172.16.0.0/g calico.yaml
创建calico
kubectl create -f calico.yaml -n kube-system
kubectl create -f rbac.yaml -n kube-system
kubectl get pod -n kube-system -o wide
----------------------------------------------------------------------------------------------------------------------------
执行主机:192.168.1.15and16and18
宿主机安装
calicoctl
cd /usr/local/bin
wget
https://github.com/projectcalico/calicoctl/releases/download/v2.0.0/calicoctl
chmod 755
calicoctl
mkdir /etc/calico
cat > /etc/calico/calicoctl.cfg<
> apiVersion: v1
> kind: calicoApiConfig
> metadata:
> spec:
> datastoreType: "etcdv2"
> etcdEndpoints: "https://192.168.1.15:2379,https://192.168.1.16:2379,https://192.168.1.18:2379"
> etcdKeyFile: "/etc/kubernetes/ssl/kubernetes-key.pem"
> etcdCertFile: "/etc/kubernetes/ssl/kubernetes.pem"
> etcdCACertFile: "/etc/kubernetes/ssl/k8s-root-ca.pem"
> EOF
calicoctl node status