Assign FQDN to GCLB¶
In this section you will assign an FQDN to your Google Cloud Load Balancer (GCLB).
Overview
What You’ll Need¶
- A configured management environment.
- Your clone of the Arrikto GitOps repository.
- An existing GKE cluster.
- A working NGINX Ingress Controller deployment.
- A working ExternalDNS deployment (if you are using Cloud DNS).
Procedure¶
Go to your GitOps repository, inside your
rok-tools
management environment:root@rok-toos:~/# cd ~/ops/deploymentsDecide on the desired FQDN for your Google Cloud Load Balancer and print its value. Choose one of the following options based on your DNS method.
Specify the name for your FQDN:
root@rok-tools:~# export FQDN=<FQDN_SUBDOMAIN>.${DOMAIN?}Replace
<FQDN_SUBDOMAIN>
with your desired subdomain. For example:root@rok-tools:~# export FQDN=${GKE_CLUSTER?}.${DOMAIN?} && echo ${FQDN?} arrikto-cluster.apps.example.comSpecify the name for your FQDN:
root@rok-tools:~# export FQDN=<FQDN_SUBDOMAIN>.endpoints.${PROJECT_ID?}.cloud.googReplace
<FQDN_SUBDOMAIN>
with your desired subdomain. For example:root@rok-tools:~# export FQDN=${GKE_CLUSTER?}.endpoints.${PROJECT_ID?}.cloud.goog && echo ${FQDN?} arrikto-cluster.endpoints.myproject.cloud.googSpecify the name for your FQDN:
root@rok-tools:~# export FQDN=<FQDN>Replace
<FQDN>
with your desired FQDN name. For example:root@rok-tools:~# export FQDN=${GKE_CLUSTER?}.example.com && echo ${FQDN?} arrikto-cluster.example.comObtain the IP address of your Load Balancer and print its value:
root@rok-tools:~# export ADDRESS=$(kubectl get services -n ingress-nginx ingress-nginx \ > -o jsonpath={.status.loadBalancer.ingress[].ip}) && echo ${ADDRESS?} 10.42.42.42Create the DNS record. Choose one of the following options based on your DNS method.
ExternalDNS will create the DNS record automatically once you create the Ingress resource. You will find instructions to create the Ingress resource in the guides that follow.
Render the OpenAPI template to use your FQDN and ADDRESS:
root@rok-tools:~/ops/deployments# j2 rok/gcp/openapi.yaml.j2 -o rok/gcp/openapi.yamlCommit the generated YAML:
root@rok-tools:~/ops/deployments# git add rok/gcp/openapi.yaml root@rok-tools:~/ops/deployments# git commit -am "Generate OpenAPI for Cloud Endpoints"Deploy the service configuration:
root@rok-tools:~/ops/deployments# gcloud endpoints services deploy rok/gcp/openapi.yaml --verbosity debug
In your machine, edit
/etc/hosts
and add an entry for your Load Balancer IP and FQDN:$ grep -q "^${ADDRESS?}" /etc/hosts || \ > echo -e "\n${ADDRESS?} ${FQDN?}" | \ > sudo tee -a /etc/hosts $ sudo sed -i "/^${ADDRESS?}/c ${ADDRESS?} ${FQDN?}" /etc/hosts
Verify¶
Ensure that your desired FQDN resolves to the IP of the Load Balancer. Choose one of the following options based on your DNS method.
ExternalDNS will create the DNS record automatically once you create the Ingress resource. For the time being, it should not resolve to anything.
root@rok-tools:~# host ${FQDN?} arrikto-cluster.endpoints.myproject.cloud.goog has address 10.42.42.42Ensure that
/etc/hosts
is up-to-date:$ getent hosts ${FQDN?} 10.42.42.42 arrikto-cluster.example.comEnsure that your DNS configuration sees
/etc/hosts
:$ host ${FQDN?} arrikto-cluster.example.com has address 10.42.42.42