ExternalName and custom domain in Managed K8S

Hi everyone, As in above image , I have a managed k8s v 1.28 running on a Ubuntu PC. I have some web api available in another machine. This is a intranet network. Typicaly i modify /etc/hosts file and api are able to connect to IIS via custom domain.

In this senario, I created below external service

apiVersion: v1
kind: Service
metadata:
  name: nodea-dev-external-api
  namespace: demo
spec:
  type: ExternalName
  externalName: nodea.dev

I also created a ConfigMap,

apiVersion: v1
kind: ConfigMap
metadata:
  name: custom-dns-config
  namespace: demo
data:
  Corefile: |
    .:53 {
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          upstream /etc/resolv.conf
          fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
        hosts {
            nodea.dev 10.12.0.1
            fallthrough
        }
    }

still when in do kubectl exec -it poda -- nslookup nodea.dev It is not able to resolve. Since this is a managed K8s, do i need to modify coredns directly, but how can i automate later ?

Since external IP and domain name are dynamic depends on env, I want to convert this total solution to a helm chart eventualy and read the external ip and custom domain from values.yaml file.

Thank you for time and consideration. Any comments are helpfull. Thank you

I don’t think that CoreDNS will see your configmap, since its default configmap is mounted into CoreDNS as a volume. So there’s no way for nodea.dev to resolve.

You might be able to do this if the database will let you connect to it via the IP address, doing something like this

apiVersion: v1
kind: Service
metadata:
  name: nodea-db
spec:
  clusterIP: None
  ports:
  - port: 25060

---
apiVersion: v1
kind: Endpoints
metadata:
  name: nodea-db
subsets:
  - addresses:
        - ip: 10.12.0.1
    ports:
      - port: 25060

where 25060 is whatever port you intend to use for the DB.