文章

安装K8s(七)-安装Calico网络

安装K8s(七)-安装Calico网络

1.安装 Calico 网络驱动:

  1. 下载并修改 Calico 安装文件:calico-etcd.yaml

    使用 kubeadm 生成的证书配置 etcd 的证书值,注意是使用命令的值而不是直接使用命令本身!

1
2
3
4
5
6
7
8
9
data:
  # Populate the following with etcd TLS configuration if desired, but leave blank if
  # not using TLS for etcd.
  # The keys below should be uncommented and the values populated with the base64
  # encoded contents of each file that would be associated with the TLS data.
  # Example command for encoding a file contents: cat <file> | base64 -w 0
  etcd-key: #cat /etc/kubernetes/pki/etcd/server.key | base64 -w 0
  etcd-cert: #cat /etc/kubernetes/pki/etcd/server.crt | base64 -w 0
  etcd-ca: #cat /etc/kubernetes/pki/etcd/ca.crt | base64 -w 0

2.修改 etcd 的访问 URL,这里可以是多值:

1
etcd_endpoints: #"https://192.168.199.10:2379"

3.修改证书位置为以下值:

1
2
3
etcd_ca: "/calico-secrets/etcd-ca"
etcd_cert: "/calico-secrets/etcd-cert"
etcd_key: "/calico-secrets/etcd-key"

4.将网络模式由 IPIP 改为 BGP 模式:

1
2
- name: CALICO_IPV4POOL_IPIP
  value: "Never"

5.修改 K8s 网段:(根据 kubeadm init –pod-network-cidr=10.244.0.0/16 一致)

1
2
- name: CALICO_IPV4POOL_CIDR
  value: #"10.244.0.0/16"

6.安装 Calico:

1
kubectl apply -f calico-etcd.yaml
本文由作者按照 CC BY 4.0 进行授权