calico安装
配置 NetworkManager
Vim /etc/NetworkManager/conf.d/calico.conf
[keyfile]
unmanaged-devices=interface-name:cali*;interface-name:tunl*;interface-name:vxlan.calico;interface-name:vxlan-v6.calico;interface-name:wireguard.cali;interface-name:wg-v6.cali
libseccomp版本高于2.4,否则安装网络插件会报错
yum -y install https://mirrors.tuna.tsinghua.edu.cn/centos/8-stream/BaseOS/x86_64/os/Packages/libseccomp-2.5.1-1.el8.x86_64.rpm
下载operator资源清多文件
wget https://docs.projectcalico.org/manifests/tigera-operator.yaml
应用资源清多文件,创建operator
kubectl create -f tigera-operator.yaml
通过自定义资源方式安装
wget https://docs.projectcalico.org/manifests/custom-resources.yaml
关键!!
修改文件第13行,修改为使用kubeadm init ----pod-network-cidr对应的IP地址段,
networking:
dnsDomain: cluster.local
podSubnet: 10.224.0.0/16
serviceSubnet: 10.96.0.0/12
vim custom-resources.yaml
...... 11 ipPools: 12 - blockSize: 26 13 cidr: 10.244.0.0/16 14 encapsulation: VXLANCrossSubnet ......
应用资源清多文件
kubectl apply -f custom-resources.yaml
监视calico-sysem命名空间中pod运行情况
watch kubectl get pods -n calico-system
Wait until each pod has the STATUS of Running.
删除 master 上的 taint
kubectl taint nodes --all node-role.kubernetes.io/master-
kubectl taint nodes node node-role.kubernetes.io/control-plane:NoSchedule-
已经全部运行
kubectl get pods -n calico-system
NAME READY STATUS RESTARTS AGE calico-kube-controllers-666bb9949-dzp68 1/1 Running 0 11m calico-node-jhcf4 1/1 Running 4 11m calico-typha-68b96d8d9c-7qfq7 1/1 Running 2 11m
查看kube-system命名空间中coredns状态,处于Running状态表明联网成功。
kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE coredns-558bd4d5db-4jbdv 1/1 Running 0 113m coredns-558bd4d5db-pw5x5 1/1 Running 0 113m etcd-master01 1/1 Running 0 113m kube-apiserver-master01 1/1 Running 0 113m kube-controller-manager-master01 1/1 Running 4 113m kube-proxy-kbx4z 1/1 Running 0 113m kube-scheduler-master01 1/1 Running 3 113m
方法二 使用helm 安装
https://docs.tigera.io/calico/latest/getting-started/kubernetes/helm
helm repo add projectcalico https://docs.tigera.io/calico/charts
helm pull projectcalico/tigera-operator
tar xvf tigera-operator-*.tgz
编辑value cidr
installation:
kubernetesProvider: ""
cni:
type: Calico
calicoNetwork:
bgp: Disabled
ipPools:
- cidr: 10.244.0.0/16
encapsulation: VXLAN
apiServer:
enabled: true
kubeletVolumePluginPath: /var/lib/kubelet
helm install calico projectcalico/tigera-operator --version v3.27.3 -f values.yaml --namespace tigera-operator
5.8.2 calico客户端安装
下载二进制文件
curl -L https://github.com/projectcalico/calico/releases/download/v3.21.4/calicoctl-linux-amd64 -o calicoctl
安装calicoctl
mv calicoctl /usr/bin/
为calicoctl添加可执行权限
chmod +x /usr/bin/calicoctl
查看添加权限后文件
ls /usr/bin/calicoctl
/usr/bin/calicoctl
查看calicoctl版本
calicoctl version
Client Version: v3.21.4 Git commit: 220d04c94 Cluster Version: v3.21.4 Cluster Type: typha,kdd,k8s,operator,bgp,kubeadm
通过~/.kube/config连接kubernetes集群,查看已运行节点
DATASTORE_TYPE=kubernetes KUBECONFIG=~/.kube/config calicoctl get nodes
NAME master01