skip to Main Content

What is the way to configure nodeIP for Kubernetes nodes?
I have two node Kubernetes cluster. Every node has two network interfaces. eht0 where external IP is bound and eth1 with local IP. After cluster initialization and joining the worker node external IP address is used for InternalIP

$ k get nodes -o wide
NAME        STATUS   ROLES           AGE   VERSION   INTERNAL-IP      EXTERNAL-IP   OS-IMAGE                         KERNEL-VERSION    CONTAINER-RUNTIME
do-k8s-01   Ready    control-plane   18h   v1.26.2   209.XX.XX.XX   <none>        Debian GNU/Linux 11 (bullseye)   5.10.0-23-amd64   containerd://1.7.1
do-k8s-02   Ready    <none>          16h   v1.26.2   68.XX.XX.XX   <none>        Debian GNU/Linux 11 (bullseye)   5.10.0-23-amd64   containerd://1.7.1

I would prefer to use local IP address for this purpose, but I can’t change nodeIP value.
I have deployed Kubernetes via kubeadm and kubelet is running as a service and configured by /var/lib/kubelet/config.yaml file.
I see in documentation that there is an option --node-ip which is used as an argument to run kubelet in kubelete.service file. As I understand, all parameters from service file is moved to config file now and I should use it as nodeIP (or nodeIp, not sure, because I haven’t found in documentation explicit definition for yaml file).
So, I edited my /var/lib/kubelet/cinfig.yaml file like this (I have tried both variants nodeIP and nodeIp):

...
cgroupDriver: systemd
clusterDNS:
- 10.96.0.10
clusterDomain: cluster.local
nodeIP: 10.114.0.2
cpuManagerReconcilePeriod: 0s
evictionPressureTransitionPeriod: 0s
...

After restarting of kubelete service I still have my external IP address as InternalIP instead of needed 10.114.0.2.

So, I wonder what is the way to change nodeIP.
I’ll appreciate to any help in this question.

2

Answers


  1. Chosen as BEST ANSWER

    I have solved this issue. As I understand, not all flags from /lib/systemd/system/kubelet.service file moved to /var/lib/kubelet/conf.yaml file. Unsupported flags can be defined in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf file in $KUBELET_KUBECONFIG_ARGS env var. So, I added Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=10.114.0.2" line and node ip address has been changed.


  2. You may refer on kube-static-egress-ip. However, this project is in alpha stage. which is deployed as Custom Resource Definition (CRD).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search