In GKE clsuter, I can't call with hostname in internal http loadbalancer config. This is generated ingress yaml file.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
ingress.kubernetes.io/backends: '{"k8s1-d21262da-default-hellorest-backend-service-80-698951b3":"HEALTHY","k8s1-d21262da-kube-system-default-http-backend-80-43d0837a":"HEALTHY"}'
ingress.kubernetes.io/forwarding-rule: k8s2-fr-h23zc63d-default-hellorest-ingress-i-jxaunyik
ingress.kubernetes.io/target-proxy: k8s2-tp-h23zc63d-default-hellorest-ingress-i-jxaunyik
ingress.kubernetes.io/url-map: k8s2-um-h23zc63d-default-hellorest-ingress-i-jxaunyik
kubernetes.io/ingress.class: gce-internal
creationTimestamp: "2021-04-08T09:29:50Z"
finalizers:
- networking.gke.io/ingress-finalizer-V2
generation: 1
managedFields:
- apiVersion: extensions/v1beta1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.: {}
f:kubernetes.io/ingress.class: {}
f:spec:
f:rules: {}
manager: GoogleCloudConsole
operation: Update
time: "2021-04-08T09:29:50Z"
- apiVersion: networking.k8s.io/v1beta1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
f:ingress.kubernetes.io/backends: {}
f:ingress.kubernetes.io/forwarding-rule: {}
f:ingress.kubernetes.io/target-proxy: {}
f:ingress.kubernetes.io/url-map: {}
f:finalizers:
.: {}
v:"networking.gke.io/ingress-finalizer-V2": {}
f:status:
f:loadBalancer:
f:ingress: {}
manager: glbc
operation: Update
time: "2021-04-08T09:30:44Z"
name: hellorest-ingress-i
namespace: default
resourceVersion: "39841"
selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/hellorest-ingress-i
uid: 728a4e1b-8435-4b1e-a378-82665e7a8a6c
spec:
rules:
- host: hello
http:
paths:
- backend:
serviceName: hellorest-backend-service
servicePort: 80
pathType: ImplementationSpecific
status:
loadBalancer:
ingress:
- ip: 10.178.100.7
In one of cluster node, service is successfully called with load balncer IP address. But call with hostname does not work.
# success with ip
$ curl http://10.224.13.150/hello
I am hellorest-backend-67fddc48f9-5hnmg(10.220.0.7)
# cannot resolve host
$ curl http://hello/hello
curl: (6) Couldn't resolve host 'hello'
More about test environments.
GKE Cluster
: zonal / private cluster / 1.18.16-gke.302 / 2 nodes / control plane 172.16.0.0/28, global access disabled / http load balancing enabled deployed service
: hellorest-backend-service / 3 pods / 80 to 8080 tcp forwarding / default namespace / NodePort ingress service
: hellorest-ingress-i / internal http(s) lb / default namespace / 10.178.100.7 / no problem in health check As already mentioned in the comments, in order to make it work you need to have a DNS private zone with a record A: hello
. That can be done by using a cloud console. Google Cloud Private DNS Zones explains that in more detail:
Google Cloud DNS can now provide:
Create private DNS zones to provide DNS name resolution to your private network resources (VMs, load balancers, etc.).
Connect a private zone to a single network or multiple networks, giving you flexibility when designing your internal network architectures.
Create split-horizon DNS architectures where identical or overlapping zones can coexist between public and private zones in Cloud DNS, or across different GCP networks.
Utilize IAM-based, DNS-specific roles to delegate administrative or editor access to manage or view managed private zones.
All the necessary info and examples can be found in the linked article.
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.