0

I'm doing some tests with minikube + calico plugin to see if I can set the pod IP on pod creation.

I've open the minikube proxy and sent:

{
    "apiVersion": "v1",
    "kind": "Pod",
    "metadata": {
        "name": "pod2",
        "annotations": {
            "cni.projectcalico.org/ipAddrs": "[\"172.18.0.50\"]"
        }
    },
    "spec": {
        "containers": [
            {
                "name": "hello-node",
                "image": "k8s.gcr.io/echoserver:1.4",
                "ports": [
                    {
                        "containerPort": 8081
                    }
                ]
            }
        ]
    }
}

But it seems the annotation was ignored. The pod was created using another IP:

NAME                              READY   STATUS    RESTARTS   AGE     IP           NODE   
pod1                              1/1     Running   0          36s     172.18.0.8   minikube
pod2                              1/1     Running   0          6s      172.18.0.9   minikube

I've checked the 10-calico.conflist file, the plugin is set to use calico-ipam.

What am I missing?


Edit: Calico version:

Client Version:    v3.14.0
Git commit:        c97876ba
Cluster Version:   v3.14.0
Cluster Type:      k8s,kdd,bgp,kubeadm

Output of kubectl get po --all-namespaces -o wide:

NAMESPACE              NAME                                         READY   STATUS    RESTARTS   AGE    IP           NODE       NOMINATED NODE   READINESS GATES
default                hello-minikube-64b64df8c9-fd5vz              1/1     Running   1          70m    172.18.0.7   minikube   <none>           <none>
default                pod1                                         1/1     Running   0          67m    172.18.0.8   minikube   <none>           <none>
default                pod2                                         1/1     Running   0          66m    172.18.0.9   minikube   <none>           <none>
kube-system            calico-kube-controllers-789f6df884-msvzm     1/1     Running   2          152m   172.18.0.6   minikube   <none>           <none>
kube-system            calico-node-5l2vm                            1/1     Running   1          152m   172.17.0.2   minikube   <none>           <none>
kube-system            calicoctl                                    1/1     Running   1          121m   172.17.0.2   minikube   <none>           <none>
kube-system            coredns-66bff467f8-8hmpv                     1/1     Running   3          28h    172.18.0.5   minikube   <none>           <none>
kube-system            coredns-66bff467f8-xwrpj                     1/1     Running   3          28h    172.18.0.3   minikube   <none>           <none>
kube-system            etcd-minikube                                1/1     Running   2          27h    172.17.0.2   minikube   <none>           <none>
kube-system            kube-apiserver-minikube                      1/1     Running   2          27h    172.17.0.2   minikube   <none>           <none>
kube-system            kube-controller-manager-minikube             1/1     Running   3          28h    172.17.0.2   minikube   <none>           <none>
kube-system            kube-proxy-wq29b                             1/1     Running   3          28h    172.17.0.2   minikube   <none>           <none>
kube-system            kube-scheduler-minikube                      1/1     Running   3          28h    172.17.0.2   minikube   <none>           <none>
kube-system            storage-provisioner                          1/1     Running   5          28h    172.17.0.2   minikube   <none>           <none>
kubernetes-dashboard   dashboard-metrics-scraper-84bfdf55ff-kj4t2   1/1     Running   3          28h    172.18.0.4   minikube   <none>           <none>
kubernetes-dashboard   kubernetes-dashboard-696dbcc666-qxc78        1/1     Running   5          28h    172.18.0.2   minikube   <none>           <none>
Jonas
  • 121,568
  • 97
  • 310
  • 388
AFMeirelles
  • 409
  • 3
  • 8
  • 25
  • could you please share the result of `kubectl get po --all-namespaces -o wide` and calico version? – hariK May 27 '20 at 17:17
  • sure @hariK I'll edit the question as the output is too long for a comment – AFMeirelles May 27 '20 at 17:44
  • can you try `cni.projectcalico.org/ipAddrs": "[\"172.18.0.10\"]` with this annotation or IP address between `172.18.0.0 - 172.18.0.10`? Also please share `calicoctl get ipppool -o wide` – hariK May 27 '20 at 17:48
  • pod3 was successfully created with IP 172.18.0.10 `pod3 1/1 Running 0 13s 172.18.0.10 minikube ` – AFMeirelles May 27 '20 at 17:53
  • output of get ippool: `NAME CIDR NAT IPIPMODE VXLANMODE DISABLED SELECTOR default-ipv4-ippool 10.244.0.0/16 true Always Never false all()` – AFMeirelles May 27 '20 at 17:53
  • how did you start minikube or what's the command you used? – hariK May 27 '20 at 18:05
  • I started it with `minikube start --driver=docker` – AFMeirelles May 27 '20 at 18:14
  • Why do you want to do this? Usually the pod IP addresses are a very hidden implementation detail; the only place where you use them even indirectly is via a headless service, and then typically only for StatefulSets. – David Maze May 27 '20 at 21:40
  • I know in most contexts it would be considered an anti-pattern, but I'm trying to meet a very specific requirement. – AFMeirelles May 27 '20 at 21:45
  • @AFMeirelles Follow below steps `minikube start --network-plugin=cni --host-only-cidr=192.168.0.0/16` `kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml` `kubectl create -f pod.json` – hariK May 28 '20 at 07:57

0 Answers0