Galactic VPC is in preview, and the
networking.datumapis.com/v1alpha API can change.How network services work
A network service is aNetworkService resource with two parts:
- A selector: labels that an Instance’s network interface must carry to belong to the service. Every Instance of a workload carries the workload’s name as a label, so a service usually selects one workload.
- Ports: the ports the Instances listen on, each with a name, such as
httpon port8080. A load balancer refers to a port by its name, not its number.
- One network: A service covers Instances on one network. If the selector matches Instances on more than one network, the service serves none of them.
- Ready Instances only: A service sends traffic only to Instances that report themselves ready. An Instance that is starting, failing, or shutting down doesn’t receive traffic.
- Nearest location first: Each request goes to the nearest location with a ready Instance. If that location has none, the request goes to the next nearest.
- Created before the workload: You can create a service before its workload exists. The service starts serving when matching Instances are ready.
datumctl compute deploy --http-port, the command creates a network service named after the workload. For more information, see Serve public traffic with ALB.
Before you begin
- Install
datumctl, log in, and select a project. For more information, see the datumctl quickstart. - Install the
networkplugin. For more information, see Manage networks with datumctl. - To create, change, or delete network services, you need the Network Admin role in the project.
Create a network service
To create a network service for a workload, run the following command:SERVICE_NAME: a name for the service. You can’t change the name later.WORKLOAD_NAME: the name of the workload whose Instances answer for the service.PORT_NAME: a name for the port, such ashttp. Use lowercase letters, numbers, and hyphens.PORT_NUMBER: the port that your Instances listen on, such as8080.
--port. A service takes up to 16 ports, and each name and number must be unique.
To select Instances by label instead of by workload, use --selector, such as --selector app=web. The labels must be on the Instances’ network interfaces, not only on the workload.
Send load balancer traffic to a network service
To send a load balancer’s traffic to a network service, name the service and one of its port names:Check a network service
To see what a service selects, its ports, and where it’s serving, run the following command:Change a network service
To change which workload a service selects, run the following command:--port replaces the whole port list, so name every port that the service should keep. A load balancer that refers to a port name that you remove stops reaching the service.
Delete a network service
To delete a network service, run the following command:What’s next
- To manage networks and Instances’ network interfaces from the command line, see Manage networks with datumctl.
- To publish a workload with a load balancer in one step, see Serve public traffic with ALB.
- To learn how Instances connect privately, see Network addressing and traffic.