How to change CLUSTER-IP

My ip address is:

root@debian:~# ip a show dev enp0s31f6 
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 54:e1:ad:62:7f:b6 brd ff:ff:ff:ff:ff:ff
    altname enx54e1ad627fb6
    inet 192.168.1.106/24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s31f6
       valid_lft 77800sec preferred_lft 77800sec
    inet6 fe80::56e1:adff:fe62:7fb6/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

And I didn’t specific IP at init time.
And my cluster-ip is such as:

root@debian:~# kubectl get all
NAME             READY   STATUS    RESTARTS   AGE
pod/client-pod   0/2     Pending   0          24m
pod/nginx        0/1     Pending   0          38m

NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   6d

I want to change cluster-ip to 192.168.1.106 (current ip). How to I do it?

Cluster information:

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 443/TCP 5d23h

Kubernetes version:

1.31.3-1.1

Installation method:

kubeadm

Host OS:

Debian

CNI and version:

1.5.1-1.1

Pod IPs, Node IPs, and Service IPs are all very different things. You can’t interchange them. Unless I misunderstood your question, I suggest you do some reading about networking in k8s.

1 Like

As @thockin mentioned, it seems there might be a misunderstanding of how Kubernetes networking works
Short answer is you can’t.
What you see in ip addr is your host machine’s IP address, and the other is the IP address of the Kubernetes service, which is of type ClusterIP [1].

When you create a cluster, it initializes a network within the cluster, and that network is used by Kubernetes objects like pods, endpoints, services, nodes etc[2].

You can opt to choose the same network as your host, but you need to specify that when you create a cluster and pick a CNI that fits your needs [3].

[1] Service | Kubernetes
[2] Kubernetes Components | Kubernetes
[3] Cluster Networking | Kubernetes

2 Likes