Using nodePort service with ingress, I success expose the service to the out world.
--- service
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP
default postgres ClusterIP 10.106.182.170 <none> 5432/TCP
default user-api NodePort 10.99.12.136 <none> 3000:32099/TCP
ingress-nginx ingress-nginx NodePort 10.110.104.0 <none> 80:31691/TCP,443:30593/TCP
--- ingress
NAME HOSTS ADDRESS PORTS AGE
app-ingress example.com 10.110.104.0 80 3h27m
The rule of ingress show below.
Host Path Backends
---- ---- --------
example.com
/user-api user-api:3000 (172.16.117.201:3000)
If my user-api have a restful api /v1/health
interface, how to access this api inside and outside server?
From the inside, http://user-api.default:3000/user-api. From the outside, use any node external IP (see kubectl get node -o wide
for a list of them).