Can I use ServiceEntry to create an alias for an external service?

Hi,

I am still learning how to use the ServiceEntry object. I created a simple entry like below.

apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: external-svc-https
spec:
  hosts:
  - "*.google.com"
  - "g.com"
  location: MESH_EXTERNAL
  ports:
  - number: 443
    name: https
    protocol: TLS
  resolution: STATIC
  endpoints:
  - address: 142.250.204.4

Then I started a pod in the same namespace for debugging.

kubectl -n istio-test run curlpod -it --image=radial/busyboxplus:curl --restart=Never --command – /bin/sh

Inside the pod, I can curl https://www.google.com, but I got DNS error when trying to curl:

So, ServiceEntry does not create a DNS entry for the hosts. If so, is there any other tool I can use to give an alias to an external service? I know I still need to deal with the host name and certificate issue.

Thans.

I think maybe can add host inform in kubedns

Can you try:

apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: prod
spec:
  type: ExternalName
  externalName: my.database.example.com