How to change calico listening default port?

Viewed 1143

I am a begginer on kubernetes and I can see on the latest calico.yaml file (Install Calico on nodes) the configuration for the listening default 9099 port.

I am deploying on a few nodes and that port (9099) is taken as other services are running in the background.

From the logs I can see:

2020-08-28 12:15:15.107 [ERROR][59] felix/health.go 246: Health endpoint failed, trying to restart it... error=listen tcp 127.0.0.1:9099: bind: address already in use
2020-08-28 12:15:16.108 [ERROR][59] felix/health.go 246: Health endpoint failed, trying to restart it... error=listen tcp 127.0.0.1:9099: bind: address already in use
2020-08-28 12:15:17.108 [ERROR][59] felix/health.go 246: Health endpoint failed, trying to restart it... error=listen tcp 127.0.0.1:9099: bind: address already in use
2020-08-28 12:15:18.109 [ERROR][59] felix/health.go 246: Health endpoint failed, trying to restart it... error=listen tcp 127.0.0.1:9099: bind: address already in use

The logs are coming from the pod:

kube-system              calico-node-d4ntt                               1/1     Running   0          9m41s
kube-system              calico-node-mjh4z                               0/1     Running   3          3m31s
kube-system              calico-node-p5lgf                               0/1     Running   2          3m34s
kube-system              calico-node-t4vmd                               0/1     Running   2          3m30s

How can we update this port? On the yml file I can not see the port.

I can see on the yml file the configuration:

listenPort:
                description: ListenPort is the port where BGP protocol should listen.
                  Defaults to 179
                maximum: 65535
                minimum: 1

But this is not the port that is blocking my deployment.

2 Answers

In short, you have to add containerPort parameter to calico-node container part of calico.yaml:

First download calico.yaml file:

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

There is a DaemonSet in this yaml file, which has a container named calico-node, add DaemonSet.spec.template.spec.containers.ports.containerPort parameter to yaml file and change its value to something you want (any port you want). Something like this:

containers:
        # Runs calico-node container on each Kubernetes node. This
        # container programs network policy and routes on each
        # host.
        - name: calico-node
          image: calico/node:v3.16.1
          ports:
          - containerPort: 9090

Ensure that your hosts and firewalls allow the necessary traffic based on your configuration - calico-kubernetes-requirements.

Set the TYPHA_HEALTHHOST or checked on what localhost is resolving to. Similar solution: felix-calico.

Also you can try to change livenessProve and readinessProbe:

livenessProbe:
  httpGet:
     path: /liveness
     port: 9099 #here you can change port

If above solutions will not work kill process on port 9099 and then reinstall Calico.

See more: projectcalico-issue.

Also take a look: calico-incubator, calico-felix.

Related