Kubernetes service type ExternalName on minikube

service
minikube

#1

I am using minikube and have created a simple nginx pod with one LoadBalancer service which is working fine. I have tried curl <my_minikube_ip>:Port and it shows me correctly

Welcome to nginx! body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; }

My problem starts when I m making externalName service for this pod with externalName lets say abc.com. When I curl abc.com I believe it divert me to real abc.com

my pod yaml:
kind: Pod
apiVersion: v1
metadata:
name: myapp
labels:
app: myapp
spec:
containers:

  • name: myapp
    image: nginx
    ports:
    • containerPort: 80
      imagePullPolicy: IfNotPresent

my LoadBalancer Service YAML
apiVersion: v1
kind: Service
metadata:
labels:
app: myapp
name: my-svc-lb
spec:
ports:

  • port: 9000
    targetPort: 80
    selector:
    app: myapp
    type: LoadBalancer

my externalName service yaml
apiVersion: v1
kind: Service
metadata:
name: my-svc-externalname
spec:
ports:

  • port: 8200
    targetPort: 80
    protocol: TCP
    type: ExternalName
    externalName: abc.com

nslookup my-svc-externalname.default.svc.cluster.local
Server: 127.0.0.53
Address: 127.0.0.53#53

** server can’t find my-svc-externalname.default.svc.cluster.local: SERVFAIL

Can anyone help explain me what I am doing wrong and how to resolve this issue so that this externalName divert curl request to nginx pod


#2

Ahhh! Now I got that external service is to redirect local service to some externally located endpoint.

You configured your web app to access a DB using URL test-service , but on your prod cluster DB is on AWS RDS and it has the following URL test.database.example.com . After you created ExternalName service and your web pod tries to access a DB on test-service , Kubernetes DNS server will return a CNAME record with the value test.database.example.com . Problem solved

above para is from following article and it is must read article on externalName service type