Communicating with Other Pods in Kubernetes

2023-10-07 18:46 (1 years ago) ytyng

If it is within the same namespace, name resolution can be done using the metadata.name of the Service.

Service

apiVersion: v1
kind: Service
metadata:
  name: redis
  namespace: airflow
spec:
  ports:
    - name: "6379"
      port: 6379
      targetPort: 6379

With this configuration, you can resolve the name redis from other Pods.

redis://:@redis:6379/0

Similarly,

apiVersion: v1
kind: Service
metadata:
  name: postgres
  namespace: airflow
spec:
  ports:
    - name: "5432"
      port: 5432
      targetPort: 5432

With this setup, you can resolve the name postgres as follows:

db+postgresql://username:password@postgres/airflow
postgresql+psycopg2://username:password@postgres/airflow
Currently unrated

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011