1

I'm currently using 10.222.0.0/16 network for my pods on a single node cluster test environment.

When I reboot the machine or redeploy pods they get the first ip address which has not been used previously. I want to prevent this from happening by assigning static ips for pods with calico.

How can I achieve this?

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
Nyquillus
  • 179
  • 1
  • 5
  • 23
  • 1
    You can't. Maybe multus, though it's not meant to replace your SDN. Better figure out how to configure your application not to suffer from IP changes -- let us know what's your use case. – SYN Jun 15 '21 at 11:21

1 Answers1

0

Generally that approach would be against the dynamic nature of Kubernetes' IP layer. However, there is a solution found in the Project Calico docs:

Choose the IP address for a pod instead of allowing Calico to choose automatically.

Bear in mind that:

You must be using the Calico IPAM.

If you are not sure, ssh to one of your Kubernetes nodes and examine the CNI configuration.

cat /etc/cni/net.d/10-calico.conflist

Look for the entry:

 "ipam": {
      "type": "calico-ipam"
  },

If it is present, you are using the Calico IPAM. If the IPAM is set to something else, or the 10-calico.conflist file does not exist, you cannot use these features in your cluster.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37