Reputation: 2316
Let's say we have a frontend and a backend pods running in a kubernetes cluster.
Both pods have corresponding services exposing them on the host (type: NodePort
). In the end, the frontend uses <Host IP>:<Port 1>
, and the backend runs on <Host IP>:<Port 2>
.
How to find out the host IP so that it could be used in the frontend pod (to be defined as a value of a variable)? Tried with setting localhost
, but it didn't work, so probably the exact IP has to be defined.
Upvotes: 2
Views: 3023
Reputation: 31183
Use the downward API:
spec:
image: ...
env:
- name: REACT_APP_BACKEND_URL
valueFrom:
fieldRef:
fieldPath: status.hostIP
Upvotes: 8