开始前准备

确定calico数据存储

 Calico同时支持kubernetes api和etcd数据存储。官方给出的建议是在本地部署中使用K8S API,仅支持Kubernetes模式。而官方给出的etcd则是混合部署(Calico作为Kubernetes和OpenStack的网络插件运行)的最佳数据存储。

使用etcd作为calico数据存储的好处:

  • 允许多平台混用calico,如Kubernetes OpenStack上运行Calico
  • Kubernetes资源与Calico资源分离
  • 一个Calico群集,该群集不仅仅包含一个Kubernetes群集,如可与多个kubernetes集群互通。

坏处:

  • 安装步骤繁琐
  • 无法使用Kubernetes RBAC对calico资源的控制
  • 无法使用Kubernetes资源对calico进行管理

下载calico部署清单

curl https://docs.projectcalico.org/manifests/calico-etcd.yaml -o calico.yaml

修改Pod CIDR

 Calico默认的Pod CIDR使用的是192.168.0.0/16,这里一般使用与controller-manager中的--cluster-cidr 保持一,取消资源清单内的 CALICO_IPV4POOL_CIDR变量的注释,并将其设置为与所选Pod CIDR相同的值。

calico的IP分配范围

 Calico IPAM从ipPool分配IP地址。修改Pod的默认IP范围则修改清单calico.yaml中的CALICO_IPV4POOL_CIDR

配置Calico的 IP in IP

默认情况下,Calico中的IPIP已经禁用,这里使用的v3.17.2 低版本默认会使用IPIP

要开启IPIP mode则需要修改配置清单内的 CALICO_IPV4POOL_IPIP 环境变量改为 always

修改secret

  # 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的ca
etcd-ca: # 填写上面命令编码后的值
# etcd客户端key
etcd-key: # 填写上面命令编码后的值
# etcd客户端访问证书
etcd-cert: # 填写上面命令编码后的值

修改configMap

  etcd_endpoints: "https://10.0.0.6:2379"
# If you're using TLS enabled etcd uncomment the following.
# You must also populate the Secret below with these files.
etcd_ca: "/calico-secrets/etcd-ca"
etcd_cert: "/calico-secrets/etcd-cert"
etcd_key: "/calico-secrets/etcd-key"

开始安装

kubectl apply -f calico.yaml

安装出错

/calico-secrets/etcd-cert: permission denied

2021-02-08 02:15:10.485 [INFO][1] main.go 88: Loaded configuration from environment config=&config.Config{LogLevel:"info", WorkloadEndpointWorkers:1, ProfileWorkers:1, PolicyWorkers:1, NodeWorkers:1, Kubeconfig:"", DatastoreType:"etcdv3"}
2021-02-08 02:15:10.485 [FATAL][1] main.go 101: Failed to start error=failed to build Calico client: could not initialize etcdv3 client: open /calico-secrets/etcd-cert: permission denied

找到资源清单内的对应容器(calico-kube-controllers)的配置。在卷装载中设置440将解决此问题

volumes:
# Mount in the etcd TLS secrets with mode 400.
# See https://kubernetes.io/docs/concepts/configuration/secret/
- name: etcd-certs
secret:
secretName: calico-etcd-secrets
defaultMode: 0400 # 改为0440

修改calicoctl的数据源

 使用单独的etcd作为calico数据存储还需要修改calicoctl数据存储访问配置

 calicoctl 在默认情况下,查找配置文件的路径为/etc/calico/calicoctl.cfg上。可以使用--config覆盖此选项默认配置(使用中测试不成功,官方给出有这个方法)。

 如果calicoctl无法获得配置文件,将检查环境变量。

apiVersion: projectcalico.org/v3
kind: CalicoAPIConfig
metadata:
spec:
datastoreType: etcdv3
etcdEndpoints: "https://10.0.0.6:2379"
etcdCACert: |
# 这里填写etcd ca证书文件的内容,无需转码base64
etcdCert: |
# 这里填写etcd client证书文件的内容,无需转码base64
etcdKey: |
# 这里填写etcd client秘钥文件的内容,无需转码base64

reference:

Secret permission denied

configuration calicoctl

calico installation

最新文章

  1. node.js里npm install --save 与 npm install --save-dev 的区别
  2. Office2013插件开发Outlook篇(1)-- 第一个office2013插件
  3. oracle删除数据库中的所有数据的拼接语句
  4. 关于SQL表联接
  5. MVC dropdownlist使用
  6. 模仿qq音乐播放字母效果
  7. 使用Inno Setup 打包jdk、mysql、tomcat、webapp等为一个exe安装包
  8. 基于手机传感器数据使用 CNN 识别用户行为的 Tensroflow 实现
  9. 使用IntelliJ IDEA开发SpringMVC网站(一)开发环境
  10. arcgis api 3.x for js 入门开发系列三地图工具栏(附源码下载)
  11. Jeecg
  12. C++ Primer 笔记——基本内置类型
  13. CDQ分治学习笔记
  14. leetcode [34] Find First and Last Position of Element in Sorted Array
  15. PHP ueditor编辑器使用(TP5)
  16. codeforces水题100道 第十一题 Codeforces Round #143 (Div. 2) A. Team (brute force)
  17. webstorm 使用svn
  18. 洛谷 P1337 [JSOI2004]平衡点 / 吊打XXX
  19. Revit二次开发示例:ChangesMonitor
  20. 点击导航栏tableView回到顶部

热门文章

  1. Jaeger Client Go 链路追踪|入门详解
  2. Java学习之浅析高内聚低耦合
  3. MySQL5.7和MySQL8.0通用配置文件
  4. 快速排序(QuickSort)Java版
  5. python进阶(一)变量与数据类型、python之禅
  6. 【算法学习笔记】组合数与 Lucas 定理
  7. NLP入门学习中关于分词库HanLP导入使用教程
  8. Android平台OpenGL ES/Assimp/OpenCV/GLM集成说明
  9. 深入剖析共识性算法 Raft
  10. SimpleDateFormat一定是线程不安全吗?