ECI supports management through Cloud Shell. This walkthrough deploys WordPress by using Cloud Shell to create an ACK Serverless cluster and an ECI instance for the containerized application.
Background
WordPress is a blog platform developed in PHP. You can use WordPress to build a website on a server that supports PHP and MySQL, or you can use it as a content management system (CMS).
Cloud Shell is a browser-based command-line tool provided by Alibaba Cloud for managing your cloud resources. For more information, see Cloud Shell.
Create an ACK Serverless cluster
-
Open Cloud Shell. In the dialog box that appears, confirm that you want to clone the tutorial script to Cloud Shell.
-
Go to the directory for the WordPress tutorial.
cd eci-wordpress -
(Optional) Modify the cluster configuration file.
vim create.jsonThe
create.jsonfile contains the parameters to create the ACK Serverless cluster. The default configuration is as follows:{ "cluster_type": "ManagedKubernetes", "profile": "Serverless", "name": "wordpress-demo", "region_id": "cn-hangzhou", "endpoint_public_access": true, "snat_entry": true, "addons": [{ "name": "csi-provisioner", "config": "" }], "zoneid": "cn-hangzhou-j" }The file contains the following parameters:
-
name: The name of the cluster. -
region_id: The ID of the region where the cluster is deployed. -
endpoint_public_access: Specifies whether to expose the API server to the internet. -
snat_entry: Specifies whether to create a NAT gateway and configure SNAT rules. -
zoneid: The ID of the zone where the cluster is deployed.
-
-
Run the following command to create the ACK Serverless cluster.
aliyun cs POST /clusters --header "Content-Type=application/json" --body "$(cat create.json)"A successful response looks similar to the following. The
cluster_idfield contains the ID of the new cluster.{ "cluster_id": "c5789a864e71848ab9fa57013********", "instanceId": "c5789a864e71848ab9fa57013********", "request_id": "C5044E47-7AAD-5D6F-A8D9-2249F1******", "task_id": "T-6528e986ba8151096d******" } -
View cluster properties.
aliyun cs GET /clusters/<YOUR-CLUSTER-ID>
Deploy the WordPress application
Ensure that the ACK Serverless cluster is fully initialized before you install WordPress. Initialization typically takes 3 to 5 minutes.
-
Connect to the ACK Serverless cluster.
source use-k8s-cluster ${CLUSTER_ID}Replace ${CLUSTER_ID} with the ID of your cluster. For example:
source use-k8s-cluster c5789a864e71848ab9fa57013******** -
Deploy the WordPress application.
ImportantDeploying with the
wordpress-all-in-one-pod.yamlfile automatically creates an EIP and associates it with the application's ECI pod.kubectl apply -f wordpress-all-in-one-pod.yamlNoteWhen you open Cloud Shell, you are prompted to clone the required scripts. The
wordpress-all-in-one-pod.yamlfile is in theeci-wordpressdirectory. -
Check the deployment status.
kubectl get podsExpected output. The deployment is successful when the pod status is
Running.NAME READY STATUS RESTARTS AGE wordpress 2/2 Running 0 5m59s -
Get the EIP address of the WordPress application.
kubectl get -o json pod wordpress |grep "k8s.aliyun.com/allocated-eipAddress"Expected output:
"k8s.aliyun.com/allocated-eipAddress": "47.99.XX.XX" -
Configure the security group for the WordPress application.
-
Get the security group ID.
kubectl get -o json pod wordpress |grep "k8s.aliyun.com/eci-security-group"Expected output:
"k8s.aliyun.com/eci-security-group": "sg-bp1fw6ecxb0obm******" -
Add a rule to the security group to allow access over port 80.
aliyun ecs AuthorizeSecurityGroup --RegionId ${REGION_ID} --SecurityGroupId ${SECURITY_GROUP_ID} --IpProtocol tcp --PortRange 80/80 --SourceCidrIp 0.0.0.0/0 --Priority 100Replace ${REGION_ID} and ${SECURITY_GROUP_ID} with your region ID and security group ID. For example:
aliyun ecs AuthorizeSecurityGroup --RegionId cn-hangzhou --SecurityGroupId sg-bp1fw6ecxb0obm****** --IpProtocol tcp --PortRange 80/80 --SourceCidrIp 0.0.0.0/0 --Priority 100
-
Install and log in to WordPress
-
Access the WordPress application.
In the address bar of your browser, enter the EIP address of the WordPress application. For example,
http://47.99.XX.XX. -
Select a language and click Continue. Then, enter the required information and click Install WordPress.
This includes the following:
-
Site Title: The name of your WordPress website.
-
Username: The username used to log in to WordPress. Make sure that the username is secure.
-
Password: The password used to log in to WordPress. We recommend that you set a strong password.
-
Your Email: The email address used to receive notifications.
-
-
Click Log In.
-
Enter the username and password that you set during the WordPress installation, and then click Log In.
After you log in, the WordPress dashboard appears.