I've a Service my-service of type ClusterIP in namespace A which can load balance to a few pods. I want to create another Service of type ExternalName in namespace B that points to my-service in namespace A.
I create the following YAML:
apiVersion: v1
kind: Service
metadata:
name: my-service
namespace: B
spec:
type: ExternalName
externalName: my-service.A
and if I exec into a pod running in namespace B and do:
# ping my-service
ping: my-service: Name or service not known
But if I change the externalName in the above YAML to below:
apiVersion: v1
kind: Service
metadata:
name: my-service
namespace: B
spec:
type: ExternalName
externalName: my-service.A.svc.cluster.local <--- full FQDN here
things work as expected. Also, if I ping my-service directly from a pod in namespace B it is being resolved:
# ping my-service.A
PING my-service.A.svc.cluster.local (10.0.80.133) 56(84) bytes of data.
Why my-service.A is not resolved to my-service.A.svc.cluster.local in ExternalName Service?
My K8s version is 1.14.8 and uses CoreDNS.