k8s-1.9.1-步骤六(安装calico)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_35494719/article/details/79967438
----------------------------------------------------------------------------------------------------------------------------
执行主机: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
----------------------------------------------------------------------------------------------------------------------------
执行主机: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
chmod 755 calicoctl
mkdir /etc/calico

cat > /etc/calico/calicoctl.cfg<<EOF
> 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



阅读更多
博主设置当前文章不允许评论。

没有更多推荐了,返回首页