Communicating with Other Pods in Kubernetes
2023-10-07 09:46 (2 years ago)
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
Please rate this article
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.