Communicating with Other Pods in Kubernetes
2023-10-07 09:46 (3 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 (No signup or login required)
Currently unrated
Related posts
I reinstalled the DNS plugin because name resolution stopped working in Kubernetes (Microk8s)
Writing Host Aliases in Kubernetes Manifests
Starting Elasticsearch and Kibana on Kubernetes with analysis-icu Installation
Install Ingress Nginx as an Ingress Controller in K3s and Retrieve the Source IP Address as a Request Header
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.