Sign inSign up

zappi/calico-route-reflector-init

By zappi

•Updated almost 7 years ago

An init container that configures a Kubernetes node to act as a Calico BGP route reflector.

Image
0

1.2K

zappi/calico-route-reflector-init repository overview

⁠Calico Route Reflector Init

CircleCI

An init container⁠ that configures a Kubernetes node to act as a Calico BGP route reflector⁠.

⁠Overview

The container performs two tasks that automates the configuration of a node for route reflection:

  1. Applies a label⁠ to the node which should be used in BGPPeer⁠ resources to indicate which nodes should (or should not) peer with this node.
  2. Applies an annotation⁠ to the node specifying a cluster identifier, indicating that this node is a route reflector.

For a detailed explanation of how route reflectors are configured, see configuring in-cluster route reflectors⁠.

⁠Usage

This should be used as an init container⁠ for the calico-node daemonset that will be acting as both a calico-node and a route reflector, thus we recommend two sepearate daemonsets of calico-node:

  • One that targets nodes intended to be route reflectors (i.e. masters).
  • One that targets the rest of the nodes (i.e. workers).
⁠Example

In this example, we're configuring the masters to be our route reflectors, as part of the choose and labels nodes⁠ section of Calico the hard way⁠.

kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: calico-node-master
  namespace: kube-system
spec:
  ...
  template:
    ...
    spec:
      ...
      nodeSelector:
        # Run calico-node-master on masters only.
        node-role.kubernetes.io/master: ""
      tolerations:
        - key: node-role.kubernetes.io/master
          effect: NoSchedule
      initContainers:
        - name: configure-route-reflector
          image: zappi/calico-route-reflector-init:0.1.0
          env:
            # Use the Downward API set the node name.
            - name: KUBERNETES_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: CALICO_ROUTE_REFLECTOR_LABEL_NAME
              value: "calico-route-reflector"
            - name: CALICO_ROUTE_REFLECTOR_CLUSTER_ID
              value: "1.1.1.1"

Since our masters are already running their own calico-node, we must ensure that our second daemonset only runs on worker nodes.

kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: calico-node
  namespace: kube-system
  ...
spec:
  ...
  template:
    ...
    spec:
      ...
      nodeSelector:
        # Run calico-node on workers only.
        node-role.kubernetes.io/node: ""

Once the two daemonsets are up and running, you can move on to the next step, configuring your peering⁠.

⁠Environment Variables

NameDescriptionExampleRequired
KUBERNETES_NODE_NAMEThe name of the node to be labelled and annotated.ip-10-24-101-78.ec2.internalYes
CALICO_ROUTE_REFLECTOR_LABEL_NAMEThe name of the label to be used for peering configuration.calico-route-reflectorYes
CALICO_ROUTE_REFLECTOR_LABEL_VALUEThe value of the label to be used for peering configuration.trueNo
CALICO_ROUTE_REFLECTOR_CLUSTER_IDThe cluster identifier to use when annotating the node as a route reflector.224.0.0.1Yes

⁠Compatibility

We should be able to support Calico 3.3.0⁠ and later.

Tag summary

Content type

Image

Digest

Size

16.5 MB

Last updated

almost 7 years ago

docker pull zappi/calico-route-reflector-init