Deploy a static website
SAE provides an Nginx environment. To deploy a static website, package your static resources, such as HTML, CSS, and JavaScript files, and upload the package to SAE.
Getting Started
Step 1: Create a code package
Adjust the directory structure: Ensure that your static resources follow the directory structure below.
. └── app └── index.html └── Other static resource files/foldersPackage the project: In the directory that contains the
appfolder, run the following command to package all static resources into a ZIP file.zip -r demo.zip appImportantTo ensure that the code package can run on SAE, follow these rules:
The directory that contains the static resource files must be named
app. If the directory is nameddist, rename it toapp.Package the
appfolder directly. Do not package the parent directory.
Step 2: Create an application
On the SAE application list page, select a destination region and namespace from the top of the page, and then click Create Application.
Select an application edition: For more information about the differences between editions, see Application editions.
NoteThe Lightweight Edition and Professional Edition are available by invitation only. If you are not in the beta program, your application is created as the Standard Edition and you do not need to select an edition.
Basic Information Settings:
Application Name: Enter a custom name for the application.
Namespace Type: A namespace is equivalent to a Kubernetes (K8s) namespace and is used to isolate resources for different environments. You cannot change the namespace of an application after it is created, so plan your configuration accordingly.
System Created: Use the default namespace, vSwitch, and security group that are created by the system in the current region.
Existing Namespace: Select the namespace, vSwitch, and security group that you previously created.
Application Deployment Method: Select Code Package-based Deployment, and click Configure Code Package-based Deployment.
Technology Stack Programming Language: Select HTML.
Code Package Type: Select ZIP Package Deployment.
NGINX environment: Select an environment that is compatible with your code. For more information, see HTML - Nginx environment introduction.
Upload Method: You can upload a local code package or provide the URL of the code package.
Version: Enter a version number for the application or select Use Timestamp as Version Number.
Time Zone Settings: Select a time zone for the application.
Capacity Settings:
Resource Type: Select Default.
NoteResource Type can be set to Default or Hygon. The Hygon resource type is available by invitation only. If you are not in the beta program, Resource Type is automatically set to Default, and you do not need to select it.
Single Instance Type: Select the CPU and memory specifications for each instance.
Instances: Set the initial number of instances.
Click Create Application with One Click and wait for the application to be created.
Step 3: Access the application
You can expose your application to the internet by attaching an NLB, attaching a CLB, or configuring gateway Ingress. The following steps use attaching an NLB as an example.
In the SAE application list, select the destination region and namespace at the top of the page. Then, click the Application ID of an application to open its details page.
In the Application Access Settings area, select the NLB-based access tab, and click Add NLB Access.
Instance Source: Select Create an instance.
Network Type: Select Public Network.
vSwitch: Specify the zone and virtual switch for the NLB instance.
NoteFor high availability, select at least two zones and their corresponding virtual switches.
If no virtual switch is available, click Create to create one. After the virtual switch is created, click the refresh icon and select the new virtual switch.
Protocol Type: Select TCP.
Listener Port: The port that accepts and forwards requests to backend servers. This port is customizable. In this example, enter
80.Container Port: The listening port for the container process, which is defined in the application. For an Nginx environment in SAE, the default port is
80.
Click Confirm and wait for the instance to be created.
Verify the result:
Click the ID of the NLB instance to go to its details page. In the Zone section, copy an EIP of the NLB instance.
Access the application from a browser. The URL format is
http://<EIP>:<Listener Port>.
Advanced Settings
When you create and deploy an application, you can configure the following advanced features as needed.
Runtime environment and lifecycle management
By setting environment variables, setting Hosts bindings, injecting configuration information, and injecting confidential information, you can change variables or configuration files in the runtime environment after deployment without rebuilding the image.
You can set up a health check to monitor the health of application instances. Unhealthy instances are automatically restarted, and requests are routed to them only after they become healthy.
You can use Application Lifecycle Management to customize commands that are executed after an application starts and before it stops to ensure a graceful shutdown.
Application access and traffic management
You can enable service invocation between applications through service registration and discovery.
You can expose an application to external traffic by attaching an NLB, attaching a CLB, or configuring gateway routing.
Applications can access external resources or services by configuring a NAT Gateway or attaching an EIP to an application instance.
Data persistence
Store your application data in NAS, OSS, or a database to prevent data loss when an application is changed or terminated.
Logging and monitoring
After you deploy an application, you can immediately view real-time logs and view resource usage and payload without any additional configuration. You can also export logs to SLS or Kafka for centralized management and analysis.
Application Real-Time Monitoring Service (ARMS) provides a comprehensive view of your application's status. It helps you quickly detect faulty and slow API operations, identify performance bottlenecks, and reproduce call parameters. This greatly improves the efficiency of diagnosing online issues.
For Std Edition applications, you can view ARMS Basic Edition monitoring data immediately after deployment without any additional configuration. You can also subscribe to ARMS Premium Edition monitoring.
For Pro Edition applications, after you enable Application Monitoring in the Advanced Settings and deploy the application, you can view ARMS Premium Edition monitoring data at no additional cost.
Microservice governance
Microservices Governance enables lossless deployment and undeployment, traffic protection, end-to-end canary releases, and prioritized routing within the same availability zone for Java applications.
For Std Edition applications, after you deploy the application, you must go to the application details page to purchase the MSE microservice governance feature.
For Pro Edition applications, after you enable Microservices Governance in the Advanced Settings, you can configure graceful deployment and undeployment. After the application is deployed, you can configure more features on the application details page at no additional cost.
Other features
By enabling the CPU Burst feature (available only for Standard and Professional Editions), you can prevent resource waste caused by applications that require more CPU resources at startup than during normal operation.
Use Add a Sidecar container to decouple and standardize non-business features from the main container.