Ali Tou
Ali Tou

Reputation: 2195

Change Kubernetes Service Name Without Removing It

Suppose in my microservice architecture, I have a microservice that receives API calls, and sends the required RPCs to other microservices in order to respond the calls. Let's call it server.

In order to be exposed to outside world, I have a NodePort Service for this microservice named after its name (server). Currently I am using RabbitMQ for my inter-service communications, and server is talking to other microservices via RMQ queues.

Now I want to deploy a service mesh and use gRPC for inter-service communications. So I need to create K8s Service for gRPC port for all of my microservices with their microservice name (including server). However, the K8s Service with name server already exists and I need to change the name of that NodePort in order to be able to create its gRPC Service, but K8s doesn't let me change the Service name. If I delete the NodePort and create another one with a new name, my application would be down for that couple of seconds.

Final question is, how can I achieve renaming this NodePort while having my application available to users?

Upvotes: 2

Views: 4978

Answers (1)

Adam
Adam

Reputation: 797

You can do the following:

  1. Create a brand new NodePort service "server-renamed" (with the same selectors and everything as "server")

  2. Change your microservices config to use it and check all is OK

  3. Remove the "server" service and recreate it with the new required specs.

Upvotes: 3

Related Questions