--http-port is the quickest way to attach an ALB to a workload: it declares the port your container serves HTTP on and creates an HTTPProxy for the workload. Datum terminates TLS at the ALB, sends each request to the nearest location with a healthy Instance, and connects to your Instances over plain HTTP on your private network.
Compute is in preview, and the
v1alpha API can change.Before you begin
- Select a project, install the
computeplugin, and get access to Compute. For more information, see Set up your project. - Make sure that you have permission to create networking resources in the project, in addition to compute resources. The Network Admin role includes the permissions that publishing needs. The Gateway Admin role alone isn’t enough.
- Make sure that your app serves plain HTTP, not HTTPS, on the port that you publish, and listens on IPv6.
Attach an ALB with datumctl
To attach an ALB to a workload, rundatumctl compute deploy with --http-port:
WORKLOAD_NAME: the name of your workload.IMAGE: the full image reference, including the registry host.LOCATION: one or more locations, separated by commas.PORT: the port that your container serves HTTP on, such as8080.
--http-port works when you create a workload and when you update one that you deployed with flags.
The command declares the port on the container, waits for the rollout, and then prints the publishing progress and the ALB’s hostname as the last line of output:
Find your workload’s ALB hostname
To see the ALB hostname of every workload in your project, run the following command:URL column.
To see the hostname and the health of the Instances behind it in each location, run the following command:
jq installed, you can read the hostname in a script. Run the following command:
WORKLOAD_NAME with the name of your workload.
Change or remove the ALB
The ALB keeps its hostname when you redeploy the workload. If you rundatumctl compute deploy without --http-port, the workload keeps its current port and the ALB keeps its hostname.
To change or remove the ALB, do one of the following:
- To serve on a different port, run
datumctl compute deployagain with the new--http-portvalue. The hostname stays the same. - To stop serving the workload publicly, run
datumctl compute deploywith--no-http. This removes the ALB, and the hostname stops responding.
datumctl compute destroy removes the workload’s ALB along with the workload and its Instances. A plain datumctl delete workload deletes the workload and its Instances, but leaves the ALB in place. For more information, see Delete a workload.
Use a custom domain
You can serve a published workload on your own domain, such asapi.example.com, in addition to its generated hostname. The ALB is an HTTPProxy resource named after the workload. For more on custom hostnames, TLS, and WAF protection, see ALB.
To add a custom domain, follow these steps:
- Add and verify your domain in Datum. For more information, see Domains.
-
To open the workload’s
HTTPProxyfor editing, run the following command:ReplaceWORKLOAD_NAMEwith the name of your workload. -
Add your hostname to
spec.hostnames, and then save and close the file: -
Point your hostname at the workload’s generated hostname with a
CNAMErecord. If Datum hosts your DNS, see DNS setup for Application Load Balancer.
datumctl compute deploy keeps custom hostnames when it updates a workload. datumctl compute destroy removes the ALB, including its custom hostnames, but keeps your domain resources.
Publish a workload you manage with manifests
A workload manifest can’t declare an ALB, anddatumctl compute deploy -f doesn’t create or remove one. To attach an ALB to a manifest-managed workload, follow these steps:
- Create the workload with
datumctl compute deployand--http-port, as described in Attach an ALB with datumctl. The command saves the workload toworkload.yamlin the current directory. - Rename
workload.yaml, and make your changes in the renamed file. Keep the container port that you published. - To apply later changes, run
datumctl compute deploy -f FILE, whereFILEis the path to your manifest. The workload keeps its ALB.
Limitations
In addition to the limitations that apply to all of Compute, the ALB has the following limitations:- Clients always connect over HTTPS. Datum connects to your Instances over plain HTTP, and TLS between Datum and your Instances isn’t supported.
datumctl compute deployattaches one ALB to each workload, on one port.
What’s next
- To run in more locations so that more users reach a nearby Instance, see Placement and scaling.
- To learn more about
HTTPProxyrouting and options, see Application Load Balancer. - To learn how Instances connect privately, see Network addressing and traffic.