Two services for the same Pod on GKE

5/9/2019

Question

Is it problematic to create two Services for the same pod, one for internal access and the other for external access?

Context

I have a simple app running on GKE.

There are two pods, each with one container:

  1. flask-pod, which runs a containerized flask app
  2. postgres-pod, which runs a containerized postgres DB

The flask app accesses the postgres DB through a ClusterIP Service around the postgres DB.

Concern

I also have connected a client app, TablePlus (running on my machine), to the postgres DB through a LoadBalancer Service. Now I have 2 separate services to access my postgres DB. Is this redundant, or can this cause problems?

Thanks for your help.

-- Nico Cernek
kubernetes

2 Answers

5/10/2019

This approach is absolutely valid, there is nothing wrong with it. You can create as many Services per Pod as you like.

-- Vasily Angapov
Source: StackOverflow

5/10/2019

It is perfectly fine. If you look at StatefulSets, you define one headless service that is used for internal purpose and another service to allow access from clients.

-- P Ekambaram
Source: StackOverflow