Creating a Deployment (Nginx) from an Image
You can use images to quickly create a single-pod workload that can be accessed from public networks. This section describes how to use CCE to quickly deploy an Nginx application and manage its life cycle.
Prerequisites
A cluster of at least one node has been created. The node has an elastic IP address (EIP).
A cluster is a logical group of cloud servers that run workloads. Each cloud server is a node in the cluster.
For details on how to create a cluster, see Creating a Kubernetes Cluster.
Nginx Overview
Nginx is a lightweight web server. On CCE, you can quickly set up a Nginx web server.
The following describes how to create Nginx from the Open Source Images. It takes about 5 minutes to complete Nginx creation.
After Nginx is created successfully, you can access the Nginx web page.
Procedure
The following is the procedure for creating a containerized workload from a container image.
- Log in to the CCE console.
- Choose the target cluster.
- In the navigation pane, choose Workloads. Then, click Create from Image.
- Configure the following parameters and retain the default value for other parameters:
Basic Info
- Workload Type: Select Deployment.
- Workload Name: Set it to nginx.
- Pods: Set the quantity of pods to 1.
Container Settings
In the Basic Info area, click Select Image. In the dialog box displayed, select Open Source Images, search for nginx, and select the nginx image.
Figure 2 Selecting the nginx image
Service Settings
Click the plus sign (+) to create a Service for accessing the workload from an external network. In this example, create a LoadBalancer Service. Set the following parameters:
- Service Name: name of the Service exposed to external networks. In this example, the Service name is nginx.
- Access Type: Select LoadBalancer.
- Service Affinity: Retain the default value.
- Load Balancer: If a load balancer is available, select an existing load balancer. If not, click Create Load Balancer to create one on the ELB console.
- Port:
- Protocol: Select TCP.
- Service Port: Set this parameter to 8080, which is mapped to the container port.
- Container Port: port on which the application listens. For containers created using the nginx image, set this parameter to 80. For other applications, set this parameter to the port of the application.
Figure 3 Creating a Service
- Click Create Workload.
Wait until the workload is created.
The created Deployment will be displayed on the Deployments page.
Figure 4 Workload created successfully
Accessing Nginx
- Obtain the external access address of Nginx.
Click the nginx workload to enter its details page. On the Access Mode tab page, you can view the IP address of Nginx. The load balancer IP address is the external access address, as shown in the following figure.Figure 5 Obtaining the external access address
- Enter the external access address in the address box of a browser. The following shows the welcome page if you successfully access the workload.
Figure 6 Accessing Nginx
Last Article: Creating a Kubernetes Cluster
Next Article: Deploying WordPress and MySQL That Depend on Each Other
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.