SAE supports service registration and discovery for applications in multiple languages, enabling inter-service calls using a K8s ServiceName. You can configure a fixed, accessible domain name for an application within an SAE cluster. This resolves the issue of instance IP addresses changing after each deployment. This topic describes how to use the SAE console to configure application access using a K8s ServiceName.
How it works
In a distributed microservice framework, service registration and discovery enable servers and clients to communicate properly when the online or offline status of services changes.
Service registration: This applies to the server. A service instance registers its information with a registry. The client then reads and subscribes to this information from the registry.
Service discovery: This applies to the client. The registry probes the instance addresses and metadata of a service and provides this information to clients through a predefined interface. Clients query the registry to obtain information about the services they depend on and then use that information to make calls.
Usage notes
This domain name can only be used to access instances within an SAE application. Instances or clusters from other services, such as FC, ACK, or ECS, cannot use this domain name to access the SAE application. If applications from other services need to access the SAE application, you must associate a private or public Classic Load Balancer (CLB) to provide access. For more information, see Configure application service access using a CLB.
Do not use the ping command to access the K8s ServiceName. Instead, access the ServiceName from your code using TCP or UDP. You can use the ping command to test the pod IP address of the application to check for network connectivity.
An application pod cannot access itself using its ServiceName.
If a server application and a client application need to call each other, both must be configured with a K8s ServiceName.
Configuration guide
Console entry point.
Upon application creation
Log on to the SAE console. In the navigation pane on the left, choose . Select a region and namespace, and then click Create Application.
Select an application version and click Create Application.
On the Basic Information page, configure the settings and click Next: Advanced Settings.
On the Advanced Settings page, find and expand the Service Registration And Discovery section.
Upon application deployment
WarningAfter you redeploy an application, the application is restarted. To prevent unpredictable errors such as business interruptions, we recommend that you deploy applications during off-peak hours.
Log on to the SAE console. In the navigation pane on the left, choose . Select a region and namespace, and then click the name of the target application.
On the Basic information page of the application, click Deploy Application.
On the Deploy Application page, find and expand the Service Registration and Discovery section.
Configure the feature.
Turn on the Kubernetes Service-based Service Registry and Discovery switch.
Configure the Service Name, Port, and so on.
Configuration Item
Description
Service Name
Enter a custom service name. The name must be unique within the same region for your account and cannot be changed after creation.
NoteThe default service name is the application name.
Port
Enter a Port number from 1 to 65535.
NoteYou can add a maximum of five port and protocol configurations.
Container Port
Enter the container port.
Protocol
Select a protocol from the drop-down list. The following protocols are supported:
TCP
UDP
View access domain names
On the Basic information page of the target application, navigate to the Application Access Settings section. Click the Kubernetes Service Name-based Access tab to view the domain name.
The following four types of domain names are supported:
To access applications in the same namespace, use the service name. For example, `demo`.
To access applications across namespaces, use one of the following domain name formats.
demo.nsfoo
In this example, `nsfoo` is a custom namespace. If the target application is in the `default` namespace, use `default` as the namespace ID. For example: `demo.default`.
demo.nsfoo.svc.cluster.local
demo.nsfoo.svc.cluster.local.cn-hangzhou
