Kubernetes multiple pipeline services postgres

Hi ,

I am using runner-kube and having in my pipeline multiple services of postgres, and its not working becasue Address already in Use do I need to map each service to different port?
services:
- name: xx-xx-xxx-db
pull: if-not-exists
image: postgres:9.5.10
ports:
- 5432
environment:
POSTGRES_DB: xzxxx
POSTGRES_USER: xxxxx

- name: xx-xxx-xxxx-db2
  pull: if-not-exists
  image: postgres:9.5.10
  ports:
    - 5432
  environment:
    POSTGRES_DB: xxxx
    POSTGRES_USER: xxxxx

@ihakimi when you have a kubernetes pipeline, all pipeline steps share the same pod and therefore share the same localhost network. If you want multiple postgres services on the same network, you need to configure postgres to use different ports.

This can typically be done by changing the postgres entrypoint and command, and specifying the appropriate command line argument to change port. For example:

services:
- name: pg1
  image: postgres.         # use default 5432 port

- name: pg2
  image: postgres
  command: [ -p, 5433 ]    # override port

@ashwilliams1 thanks, I would add this to the documentation so it will be clear

Hi @ashwilliams1/@bradrydzewski
I saw this post Contributing to Drone for Kubernetes
And we running services and able to connect using service name instead of localhost, so why can’t run multiple services with the same port? does it able to configure network for each step? or running services only on different pods and it will solve this issue.
@bradrydzewski, you mention on the post each services is running on its own pods does it up2date and also the current builds act like this or you change the architecture, this is very common use case for developers to test without changing now the code to fit to new port/desigin and configuration.

All pipeline steps, including services (which are just pipeline steps with some syntactic sugar), are containers that execute in the same Pod. All containers in the Pod use the same network, and you cannot have multiple processes try to open the same port on the same network. The reason you can refer to the services using localhost or the service name is because we merged this patch that creates a host alias, mapping each service name to the localhost address.

This is no longer the case. An early version of kubernetes pipelines executed each pipeline step in a separate Pod, however, the approach was flawed. The problem was that you could not have multiple services of the same hostname running at the same time in the same namespace, which prevented multiple pipelines from running concurrently. We initially tried to workaround this by creating per-pipeline namespaces, however, we received overwhelming feedback that per-pipeline namespaces were not desirable.