Updated on 2023-10-18 GMT+08:00

Preparing the Environment

You need to prepare the local development and commissioning environment and cloud environment.

Preparing a Local Development and Commissioning Environment

The local development and commissioning environment is used to set up a simple test environment. The options are as follows:

  • Download the local CSE.
  • Use the exclusive microservice engine and open the IP address for public network access to ensure that the local environment can be accessed.

Preparing the Cloud Environment

Before deploying microservice applications on the cloud, you need to prepare the cloud environment. Perform the following procedure to prepare the environment:

  • Obtain the AK/SK and project name. For details, see Obtaining the AK/SK and Project Name.
    • If the professional microservice engine is used, you need to configure the AK/SK.
    • If the exclusive microservice engine is used, you do not need to configure the AK/SK.

Common Environment Variables

Using ServiceStage to manage environments and deploy applications simplifies user configuration. ServiceStage sets some environment variables for applications. The following table lists some common environment variables:

Table 1 Common environment variables

Name

Description

PAAS_CSE_ENDPOINT

Address of services such as the CSE registry center and configuration center. This environment variable is used when the professional microservice engine is accessed through API Gateway. A unified domain name applies to the external access addresses of the preceding services.

NOTE:

You are not advised to use this environment variable. Instead, use the environment variable of a specific service, so that you do not need to modify the application when connecting to the exclusive microservice engine.

PAAS_CSE_SC_ENDPOINT

Registry center address of a microservice engine.

PAAS_CSE_CC_ENDPOINT

Configuration center address of a microservice engine.

PAAS_PROJECT_NAME

Name of a project.

CAS_APPLICATION_NAME

Name of a ServiceStage application.

CAS_COMPONENT_NAME

Name of a ServiceStage component.

CAS_INSTANCE_VERSION

Version of the deployed ServiceStage.

You can use these variables based on the mechanisms of different microservice development frameworks, such as the Place Holder mechanism of Spring Cloud and the mapping.yaml mechanism of Java chassis, to reduce manual input during deployment.

When creating an application on ServiceStage, you can bind middleware, such as Distributed Cache Service (DCS) and Relational Database Service (RDS), to the application. You can obtain the configuration information about the middleware bound to applications by using the following environment variables.

  • Distributed session

    Distributed sessions are stable and reliable session storage based on DCS, supporting automatic injection for mainstream web containers, such as tomcat context, node.js express-session, and PHP session handler.

    The following table describes the environment variables of distributed sessions.

    Table 2 Environment variables of DCS sessions

    Name

    Description

    DISTRIBUTED_SESSION_CLUSTER

    Whether the instance is in cluster mode. Value: true or false.

    DISTRIBUTED_SESSION_TYPE

    Storage type of a distributed session instance. Currently, only Redis is supported.

    DISTRIBUTED_SESSION_VERSION

    Version of a distributed session instance.

    DISTRIBUTED_SESSION_NAME

    Name of a distributed session instance.

    DISTRIBUTED_SESSION_HOST

    IP address for connecting to a distributed session instance.

    DISTRIBUTED_SESSION_PORT

    Port for connecting to a distributed session instance.

    DISTRIBUTED_SESSION_PASSWORD

    Password for connecting to a distributed session instance.

  • Distributed cache

    DCS is an online, distributed, in-memory cache service compatible with Redis and Memcached. It combines high reliability and scalability with instant availability and easy management, delivering high read/write performance and fast data access.

    The following table describes the environment variables of DCS.

    Table 3 Environment variables of DCS

    Name

    Description

    DISTRIBUTED_CACHE_CLUSTER

    Whether the instance is in cluster mode. Value: true or false.

    DISTRIBUTED_CACHE_TYPE

    Storage type of a distributed cache instance. Currently, only Redis is supported.

    DISTRIBUTED_CACHE_VERSION

    Version of a DCS instance.

    DISTRIBUTED_CACHE_NAME

    Name of a DCS instance.

    DISTRIBUTED_CACHE_HOST

    IP address for connecting to a DCS instance.

    DISTRIBUTED_CACHE_PORT

    Port for connecting to a DCS instance.

    DISTRIBUTED_CACHE_PASSWORD

    Password for connecting to a DCS instance.

  • Cloud database

    RDS for MySQL is a cloud-based web service that is reliable, scalable, easy to manage, and out of the box.

    The following table describes the environment variables of RDS.

    Table 4 Environment variables of RDS

    Name

    Description

    RELATIONAL_DATABASE_NAME

    Name of an RDS instance.

    RELATIONAL_DATABASE_CONNECTION_TYPE

    Connection type of an RDS instance. Value: JNDI/SPRING_CLOUD_CONNECTOR.

    RELATIONAL_DATABASE_JNDI_NAME

    JNDI name of an RDS instance. This variable is used if the connection type is JNDI.

    RELATIONAL_DATABASE_DB_NAME

    Database name of an RDS instance.

    RELATIONAL_DATABASE_DB_USER

    Database user of an RDS instance.

    RELATIONAL_DATABASE_DB_TYPE

    Database type of an RDS instance. Currently, only MySQL is supported.

    RELATIONAL_DATABASE_VERSION

    Database version of an RDS instance.

    RELATIONAL_DATABASE_HOST

    Database IP address of an RDS instance.

    RELATIONAL_DATABASE_PORT

    Database port of an RDS instance.

    RELATIONAL_DATABASE_PASSWORD

    Database password of an RDS instance.