How to change cluster IP in a replication controller run time

9/23/2018

I am using Kubernetes 1.0.3 where a master and 5 minion nodes deployed. I have an Elasricsearch application that is deployed on 3 nodes using a replication controller and service is defined. Now i have added a new minion node to the cluster and wanted to run the container elasticsearch on the new node. I am scaling my replication controller to 4 so that based on the node label the elasticsearch container is deployed on new node.Below is my issue and please let me k ow if there is any solution ?

The cluster IP defined in the RC is wrong as it is not the same in service.yaml file.Now when I scale the RC new node is installed with the ES container pointing to the wrong Cluster IP due to which the new node is not joining the ES cluster.Is there any way that I can modify the cluster IP of deployed RC so that when I scale the RC the image is deployed on new node with the correct cluster IP ?

Since I am using old version I don't see kubectl edit command and I tried changing using kubectl patch command but the IP didn't change.

The problem is that I need to do this on a production cluster so I can't delete the existing pods but only option is to change the cluster IP of deployed RC and then scale so that it will take the new IP and image is started accordingly.

Please let me know if any way I can do this ?

-- Kamesh
elasticsearch
kubernetes

1 Answer

9/24/2018

Kubernetes creates that (virtual) ClusterIP for every service.
Whatever you defined in your service definition (which you should have posted along with your question) is being ignored by Kubernetes, if I recall correctly.

I don't quite understand the issue with scaling, but basically, you want to point at the service name (resolved by Kubernetes's internal DNS) rather than the ClusterIP.
E.g., http://myelasticsearchservice instead of http://1.2.3.4

-- samhain1138
Source: StackOverflow