You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

261 lines
8.7 KiB

  1. # Calico
  2. Check if the calico-node container is running
  3. ```ShellSession
  4. docker ps | grep calico
  5. ```
  6. The **calicoctl.sh** is wrap script with configured access credentials for command calicoctl allows to check the status of the network workloads.
  7. * Check the status of Calico nodes
  8. ```ShellSession
  9. calicoctl.sh node status
  10. ```
  11. * Show the configured network subnet for containers
  12. ```ShellSession
  13. calicoctl.sh get ippool -o wide
  14. ```
  15. * Show the workloads (ip addresses of containers and their location)
  16. ```ShellSession
  17. calicoctl.sh get workloadEndpoint -o wide
  18. ```
  19. and
  20. ```ShellSession
  21. calicoctl.sh get hostEndpoint -o wide
  22. ```
  23. ## Configuration
  24. ### Optional : Define datastore type
  25. The default datastore, Kubernetes API datastore is recommended for on-premises deployments, and supports only Kubernetes workloads; etcd is the best datastore for hybrid deployments.
  26. Allowed values are `kdd` (default) and `etcd`.
  27. Note: using kdd and more than 50 nodes, consider using the `typha` daemon to provide scaling.
  28. To re-define you need to edit the inventory and add a group variable `calico_datastore`
  29. ```yml
  30. calico_datastore: kdd
  31. ```
  32. ### Optional : Define network backend
  33. In some cases you may want to define Calico network backend. Allowed values are `bird`, `vxlan` or `none`. Bird is a default value.
  34. To re-define you need to edit the inventory and add a group variable `calico_network_backend`
  35. ```yml
  36. calico_network_backend: none
  37. ```
  38. ### Optional : Define the default pool CIDR
  39. By default, `kube_pods_subnet` is used as the IP range CIDR for the default IP Pool.
  40. In some cases you may want to add several pools and not have them considered by Kubernetes as external (which means that they must be within or equal to the range defined in `kube_pods_subnet`), it starts with the default IP Pool of which IP range CIDR can by defined in group_vars (k8s-cluster/k8s-net-calico.yml):
  41. ```ShellSession
  42. calico_pool_cidr: 10.233.64.0/20
  43. ```
  44. ### Optional : BGP Peering with border routers
  45. In some cases you may want to route the pods subnet and so NAT is not needed on the nodes.
  46. For instance if you have a cluster spread on different locations and you want your pods to talk each other no matter where they are located.
  47. The following variables need to be set:
  48. `peer_with_router` to enable the peering with the datacenter's border router (default value: false).
  49. you'll need to edit the inventory and add a hostvar `local_as` by node.
  50. ```ShellSession
  51. node1 ansible_ssh_host=95.54.0.12 local_as=xxxxxx
  52. ```
  53. ### Optional : Defining BGP peers
  54. Peers can be defined using the `peers` variable (see docs/calico_peer_example examples).
  55. In order to define global peers, the `peers` variable can be defined in group_vars with the "scope" attribute of each global peer set to "global".
  56. In order to define peers on a per node basis, the `peers` variable must be defined in hostvars.
  57. NB: Ansible's `hash_behaviour` is by default set to "replace", thus defining both global and per node peers would end up with having only per node peers. If having both global and per node peers defined was meant to happen, global peers would have to be defined in hostvars for each host (as well as per node peers)
  58. Since calico 3.4, Calico supports advertising Kubernetes service cluster IPs over BGP, just as it advertises pod IPs.
  59. This can be enabled by setting the following variable as follow in group_vars (k8s-cluster/k8s-net-calico.yml)
  60. ```yml
  61. calico_advertise_cluster_ips: true
  62. ```
  63. Since calico 3.10, Calico supports advertising Kubernetes service ExternalIPs over BGP in addition to cluster IPs advertising.
  64. This can be enabled by setting the following variable in group_vars (k8s-cluster/k8s-net-calico.yml)
  65. ```yml
  66. calico_advertise_service_external_ips:
  67. - x.x.x.x/24
  68. - y.y.y.y/32
  69. ```
  70. ### Optional : Define global AS number
  71. Optional parameter `global_as_num` defines Calico global AS number (`/calico/bgp/v1/global/as_num` etcd key).
  72. It defaults to "64512".
  73. ### Optional : BGP Peering with route reflectors
  74. At large scale you may want to disable full node-to-node mesh in order to
  75. optimize your BGP topology and improve `calico-node` containers' start times.
  76. To do so you can deploy BGP route reflectors and peer `calico-node` with them as
  77. recommended here:
  78. * <https://hub.docker.com/r/calico/routereflector/>
  79. * <https://docs.projectcalico.org/v3.1/reference/private-cloud/l3-interconnect-fabric>
  80. You need to edit your inventory and add:
  81. * `calico-rr` group with nodes in it. `calico-rr` can be combined with
  82. `kube-node` and/or `kube-master`. `calico-rr` group also must be a child
  83. group of `k8s-cluster` group.
  84. * `cluster_id` by route reflector node/group (see details
  85. [here](https://hub.docker.com/r/calico/routereflector/))
  86. Here's an example of Kubespray inventory with standalone route reflectors:
  87. ```ini
  88. [all]
  89. rr0 ansible_ssh_host=10.210.1.10 ip=10.210.1.10
  90. rr1 ansible_ssh_host=10.210.1.11 ip=10.210.1.11
  91. node2 ansible_ssh_host=10.210.1.12 ip=10.210.1.12
  92. node3 ansible_ssh_host=10.210.1.13 ip=10.210.1.13
  93. node4 ansible_ssh_host=10.210.1.14 ip=10.210.1.14
  94. node5 ansible_ssh_host=10.210.1.15 ip=10.210.1.15
  95. [kube-master]
  96. node2
  97. node3
  98. [etcd]
  99. node2
  100. node3
  101. node4
  102. [kube-node]
  103. node2
  104. node3
  105. node4
  106. node5
  107. [k8s-cluster:children]
  108. kube-node
  109. kube-master
  110. calico-rr
  111. [calico-rr]
  112. rr0
  113. rr1
  114. [rack0]
  115. rr0
  116. rr1
  117. node2
  118. node3
  119. node4
  120. node5
  121. [rack0:vars]
  122. cluster_id="1.0.0.1"
  123. ```
  124. The inventory above will deploy the following topology assuming that calico's
  125. `global_as_num` is set to `65400`:
  126. ![Image](figures/kubespray-calico-rr.png?raw=true)
  127. ### Optional : Define default endpoint to host action
  128. By default Calico blocks traffic from endpoints to the host itself by using an iptables DROP action. When using it in kubernetes the action has to be changed to RETURN (default in kubespray) or ACCEPT (see <https://github.com/projectcalico/felix/issues/660> and <https://github.com/projectcalico/calicoctl/issues/1389).> Otherwise all network packets from pods (with hostNetwork=False) to services endpoints (with hostNetwork=True) within the same node are dropped.
  129. To re-define default action please set the following variable in your inventory:
  130. ```yml
  131. calico_endpoint_to_host_action: "ACCEPT"
  132. ```
  133. ## Optional : Define address on which Felix will respond to health requests
  134. Since Calico 3.2.0, HealthCheck default behavior changed from listening on all interfaces to just listening on localhost.
  135. To re-define health host please set the following variable in your inventory:
  136. ```yml
  137. calico_healthhost: "0.0.0.0"
  138. ```
  139. ## Config encapsulation for cross server traffic
  140. Calico supports two types of encapsulation: [VXLAN and IP in IP](https://docs.projectcalico.org/v3.11/networking/vxlan-ipip). VXLAN is supported in some environments where IP in IP is not (for example, Azure).
  141. *IP in IP* and *VXLAN* is mutualy exclusive modes.
  142. Configure Ip in Ip mode. Possible values is `Always`, `CrossSubnet`, `Never`.
  143. ```yml
  144. calico_ipip_mode: 'Always'
  145. ```
  146. Configure VXLAN mode. Possible values is `Always`, `CrossSubnet`, `Never`.
  147. ```yml
  148. calico_vxlan_mode: 'Never'
  149. ```
  150. If you use VXLAN mode, BGP networking is not required. You can disable BGP to reduce the moving parts in your cluster by `calico_network_backend: vxlan`
  151. ## Cloud providers configuration
  152. Please refer to the official documentation, for example [GCE configuration](http://docs.projectcalico.org/v1.5/getting-started/docker/installation/gce) requires a security rule for calico ip-ip tunnels. Note, calico is always configured with ``calico_ipip_mode: Always`` if the cloud provider was defined.
  153. ### Optional : Ignore kernel's RPF check setting
  154. By default the felix agent(calico-node) will abort if the Kernel RPF setting is not 'strict'. If you want Calico to ignore the Kernel setting:
  155. ```yml
  156. calico_node_ignorelooserpf: true
  157. ```
  158. Note that in OpenStack you must allow `ipip` traffic in your security groups,
  159. otherwise you will experience timeouts.
  160. To do this you must add a rule which allows it, for example:
  161. ### Optional : Felix configuration via extraenvs of calico node
  162. Possible environment variable parameters for [configuring Felix](https://docs.projectcalico.org/reference/felix/configuration)
  163. ```yml
  164. calico_node_extra_envs:
  165. FELIX_DEVICEROUTESOURCEADDRESS: 172.17.0.1
  166. ```
  167. ```ShellSession
  168. neutron security-group-rule-create --protocol 4 --direction egress k8s-a0tp4t
  169. neutron security-group-rule-create --protocol 4 --direction igress k8s-a0tp4t
  170. ```
  171. ### Optional : Use Calico CNI host-local IPAM plugin
  172. Calico currently supports two types of CNI IPAM plugins, `host-local` and `calico-ipam` (default).
  173. To allow Calico to determine the subnet to use from the Kubernetes API based on the `Node.podCIDR` field, enable the following setting.
  174. ```yml
  175. calico_ipam_host_local: true
  176. ```
  177. Refer to Project Calico section [Using host-local IPAM](https://docs.projectcalico.org/reference/cni-plugin/configuration#using-host-local-ipam) for further information.