Assign FQDN to GCLB

In this section you will assign an FQDN to your Google Cloud Load Balancer (GCLB).

Procedure

  1. Go to your GitOps repository, inside your rok-tools management environment:

    root@rok-toos:~/# cd ~/ops/deployments
  2. Decide 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.com

    Specify the name for your FQDN:

    root@rok-tools:~# export FQDN=<FQDN_SUBDOMAIN>.endpoints.${PROJECT_ID?}.cloud.goog

    Replace <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.goog

    Specify 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.com
  3. Obtain 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.42
  4. Create 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.

    1. 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.yaml
    2. Commit 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"
    3. 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

  1. 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.42

    Ensure that /etc/hosts is up-to-date:

    $ getent hosts ${FQDN?} 10.42.42.42 arrikto-cluster.example.com

    Ensure that your DNS configuration sees /etc/hosts:

    $ host ${FQDN?} arrikto-cluster.example.com has address 10.42.42.42

Summary

You have successfully assigned an FQDN to your Load Balancer.

What’s Next

The next step is to configure and install cert-manager.