In a kubernetes deployment I specify a port like so:
containers:
- name: nginx
image: nginx:latest
ports:
- name: nginx-port
containerPort: 80
protocol: TCP
Now in a service I can reference that port like so (allows me to only specify the external port in the service):
spec:
type: ClusterIP
ports:
- name: nginx-port
port: 80
targetPort: nginx-port
protocol: TCP
Now the question, can I reference service and port elsewhere using the following syntax nginx-service.default.svc.cluster.local:nginx-port
? You know I can make reference to services using this special names, but I find myself hardcoding the port number like so nginx-service.default.svc.cluster.local:80
.
$(NGINX_SERVICE_PORT)
. Still curious to know if something like dns names such asnginx-service.default.svc.cluster.local
also exists for ports. – Burson