简体   繁体   中英

Unable to access Ingress service using hostname

I created an Ingress Service as below and I am able to get response using the IP (retrieved using the kubectl get ingress command).

Deployment File

 apiVersion: apps/v1 kind: Deployment metadata: name: app1-nginx-deployment labels: app: app1-nginx spec: replicas: 1 selector: matchLabels: app: app1-nginx template: metadata: labels: app: app1-nginx spec: containers: - name: app1-nginx image: msanajyv/k8s_api ports: - containerPort: 80

Service File

 apiVersion: v1 kind: Service metadata: name: app1-nginx-clusterip-service labels: app: app1-nginx spec: type: ClusterIP selector: app: app1-nginx ports: - port: 80 targetPort: 80

Ingress File

 apiVersion: extensions/v1beta1 kind: Ingress metadata: name: nginxapp1-ingress-service annotations: kubernetes.io/ingress.class: nginx spec: rules: - http: paths: - path: / backend: serviceName: app1-nginx-clusterip-service servicePort: 80

With above YAML file I am able to access the service using the ip address ie, http://xx.xx.xx.xx/weatherforecast .

But I thought of accessing the service using a Domain name instead of IP. So I created a DNS in my azure portal and added a Record set as below.

在此处输入图像描述

在此处输入图像描述

Also I changed my Ingress file as below.

 ... rules: - host: app1.msvcloud.io http: paths: - path: / backend: serviceName: app1-nginx-clusterip-service servicePort: 80

When I access using the host name ( http://app1.msvcloud.io/weatherforecast ), the host is not getting resolved. kindly let me know what I am missing.

By create a record in your private DNS zone, you can only resolve the name (app1.msvcloud.io) within your virtual network. This means it will work if you remote into a VM within the VNET and access from there. But it will not work if you try the same outside the VNET. If you want the name to be resolvable on the world wide web, you need to buy the domain name and register in Azure DNS.

The records contained in a private DNS zone aren't resolvable from the Internet. DNS resolution against a private DNS zone works only from virtual networks that are linked to it.

~What is a private Azure DNS zone .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM