All Products
Search
Document Center

Serverless App Engine:Configure application access based on Kubernetes Service names

Last Updated:Dec 01, 2023

Serverless App Engine (SAE) provides the multi-language service registration and discovery feature based on Kubernetes Service names. You can perform inter-service calls by using Kubernetes Service names. Each time an application is deployed, the IP addresses of the application instances are changed. To prevent the issues that may occur due to the changes of instance IP addresses, you can configure a fixed domain name that can be accessed in the SAE cluster for an application. This topic describes how to configure Kubernetes Service name-based service access for an application in the SAE console.

Background information

In a distributed microservices framework, a server can communicate with a caller by using the service registration and discovery feature when services are started, shut down, or changed.

  • Service registration applies to the server. After a server-side instance registers its service information with a registry, the caller can read and subscribe to the information from the registry.

  • Service discovery applies to the caller. The registry detects the instance address and metadata of services, and provides the predefined interface to allow the caller to query data. A caller-side service instance sends a request to the registry to obtain the registered information of a server-side service instance. Then, the caller-side service instance sends a request to call a service that is provided by the server-side service instance based on the obtained information.

Limits

  • A specified domain name can only be used to access the instances of the corresponding SAE application. The instances or clusters of other cloud services, such as Function Compute, Container Service for Kubernetes (ACK), and Elastic Compute Service (ECS), cannot access the SAE application by using the domain name. If other cloud services need to access an SAE application, we recommend that you bind an internal-facing or Internet-facing Classic Load Balancer (CLB) instance to the application. For more information, see Configure application access based on CLB instances.

  • You cannot run the ping command to access an application by using a Kubernetes Service name. You can configure TCP or UDP-related settings in the application code to access an application by using a Service name. To check whether the network connection is normal, we recommend that you run the ping command to test the IP address of a pod in an application.

  • An application pod cannot access itself by using a Kubernetes Service name.

  • To implement communication between a server and a caller, you must configure Kubernetes Service names for the server and caller.

Configure the service registration and discovery feature when you create an application

  1. Log on to the SAE console.

  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click Create Application.

  3. In the Basic Information step, configure the parameters and click Next: Application Deployment Configurations.

  4. In the Deployment Configurations step, configure the Technology Stack Programming Language and Application Deployment Method parameters and the corresponding settings.

  5. In the Service Registration and Discovery section, click the Kubernetes Service-based Service Registration and Discovery tab. On this tab, turn on Enable Kubernetes Service-based Service Registration and Discovery and configure the parameters.

    Parameter

    Description

    Service Name

    By default, the system automatically specifies a Service name in the Application name-Namespace ID format. The suffix -Namespace ID cannot be modified.

    Note

    After you create a Service, you cannot change the name of the Service.

    Port

    Enter a port number in the Port field. Valid values: 1 to 65535.

    Note

    You can add up to five configurations of ports and protocols.

    Protocol

    Select a protocol from the drop-down list. Valid values:

    • TCP

    • UDP

  6. Click Next: Confirm Specifications.

  7. In the Specification Confirmation step, view the details of the application and the fee for the selected specifications. Then, click Confirm.

    The Creation Completed step appears. You can click Application Details to go to the Basic Information page of the application.

  8. Check whether the configurations have taken effect by using one of the following methods:

    • Method 1:

      In the left-side navigation pane of the Basic Information page, click Change Records. On the Change Records page, view the change details. If Executed is displayed in the Change Status column, the application is deployed and the configurations have taken effect.

    • Method 2:

      On the Basic Information page, click the Instance Deployment Information tab to view the Status of the instances. If Running is displayed in the Status column, the application is deployed and the configurations have taken effect.

    • Method 3:

      In the Application Access Settings section of the Basic Information page, click the K8s Service Name-based Access tab to view the configurations of service discovery. If the specified Service name, port number, and protocol are displayed, the application is deployed and the configurations have taken effect.

Configure the service registration and discovery feature when you deploy an application

Warning

After 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.

The procedure that can be performed to update an application varies based on the number of instances in the application. This section provides an example on how to configure the required features for an application in which the number of instances is greater than or equal to 1. For information about how to update an application in which the number of instances is 0, see Update an application.

  1. Log on to the SAE console.

  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click the name of an application.

  3. In the upper-right corner of the Basic Information page, click Deploy Application.

  4. In the Service Registration and Discovery section of the Deploy Application page, click the Kubernetes Service-based Service Registration and Discovery tab. On this tab, turn on Enable Kubernetes Service-based Service Registration and Discovery and configure the parameters.

    Parameter

    Description

    Service Name

    By default, the system automatically specifies a Service name in the Application name-Namespace ID format. The suffix -Namespace ID cannot be modified.

    Note

    After you create a Service, you cannot change the name of the Service.

    Port

    Enter a port number in the Port field. Valid values: 1 to 65535.

    Note

    You can add up to five configurations of ports and protocols.

    Protocol

    Select a protocol from the drop-down list. Valid values:

    • TCP

    • UDP

  5. After you configure the settings, click Confirm.

  6. Check whether the configurations have taken effect by using one of the following methods:

    • Method 1:

      In the left-side navigation pane of the Basic Information page, click Change Records. On the Change Records page, view the change details. If Executed is displayed in the Change Status column, the application is deployed and the configurations have taken effect.

    • Method 2:

      On the Basic Information page, click the Instance Deployment Information tab to view the Status of the instances. If Running is displayed in the Status column, the application is deployed and the configurations have taken effect.

    • Method 3:

      In the Application Access Settings section of the Basic Information page, click the K8s Service Name-based Access tab to view the configurations of service discovery. If the specified Service name, port number, and protocol are displayed, the application is deployed and the configurations have taken effect.