☁️Website Containerization with CCE Service in Huawei Cloud
Introduction
Hello Everyone;
In this article, I will show you how to containerize a Linux-based web site, take its image, and then run and manage it on Cloud Container Engine (CCE) in Huawei Cloud.
Let’s do all the steps in order!
Docker, a leading containerization platform, enables developers to store and service applications and their dependencies in lightweight, portable containers. Containerization and Kubernetes, today’s most update architectures for the deployment and management of applications in software development have become popular with companies. Based on this approach, Cloud Service providers are trying to offer users a simple, low-cost and useful platform with their own Kubernetes services.
Step 1: Installing Docker on Huawei Cloud Linux ECS
Install Docker inside the ECS after creates Linux Centos 7.6 OS with command ‘yum install docker -y’
Step2: Upload Web Files to Linux Centos OS
Upload the files contained in your website such as index.html, pictures, css, js to the relevant directory. I put it in the root directory and I made an SSH connection with MobaXterm to transfer files quickly.
Step 3: Creating a Dockerfile
First of all, the file is opened in the root directory with the ‘touch Dockerfile’ command and the necessary contents to create the docker image as below, Then save the file.
FROM centos:7
RUN yum update -y && yum install -y httpd
COPY ./WEBSITE /var/www/html/
EXPOSE 80
#httpdserver
CMD [“/usr/sbin/httpd”, “-D”, “FOREGROUND”]
Docker file has been created in root directory.
Step 4: Start the docker server
Run Docker and enable it. Then we need to make sure that the docker server is active.
Step 5: Creating the Docker Image
To create the Docker image, go to the directory (root) containing the Docker file and run the following command. This command creates the Docker image using the Docker file and assigns the apache_webserver_docker tag to it.
Docker image was created with latest tag
Step6: Push Docker Image to Huawei Cloud SWR
What is the SWR?
Software Repository for Container (SWR) provides easy, secure, and reliable management of container images throughout their lifecycle, facilitating the deployment of containerized applications. SWR allows you to securely host and efficiently distribute images on the cloud without building or maintaining image repositories by yourselves
First of all, in order to log in to the organization we created in SWR via Docker, we take our temporary login command from SWR and log in via Docker. Then, we retag our docker image and push it to SWR.
1-) Login SWR Service and create an organization
Organizations enable efficient management of images. Organizations are used to isolate image repositories. With each organization being limited to one company or department, images can be managed in a centralized and efficient manner. An image name needs to be unique within an organization.
2-) Generate a Temporary Login Command
In order to access and provide SWR via Docker, we must generate a Temporary Login Command.
Click upload Through Client button and copy the Temporary Login Command.
3-) Login SWR from Docker , retag docker image and push it to SWR.
Step7: Create a Cluster in CCE Service
What is the CCE?
CCE is a one-stop platform integrating compute (ECS or BMS), networking (VPC, EIP, and ELB), storage (EVS, OBS, and SFS), and many other services. It supports heterogeneous computing architectures such as GPU, NPU, and Arm. Multi-AZ, multi-region disaster recovery ensures high availability of Kubernetes clusters.
We can now include the Docker image in the Kubernetes containerization system and install and manage it through the CCE service provided by Huawei Cloud.
1-) Create a cluster
By selecting the billing mode as pay per use, 50 nodes will be visible to us.
In a short time, the Cluster will look like the following
2-) Create Nodes
When creating a node, let’s set our ECS specifications to 4 core vCPU and 8GB RAM to run the pods.
As seen below, our node is running and 6 pods are running inside it.
3-) Setting Workloads
We select the image we created and make the workload settings.
Now the workload has been created and the pods are working properly.
4-) Choose Service Type
We select the service type as ELB and assign an EIP to ELB. Then, we select the Container and Service ports and enable the website to be accessed from outside.
Step8: Login the Website from Public IP and port to check operability
Now we can open our browser and access the website via EIP and service port.
Note: To access the web service using the service port over the Internet, we need to open port 8081 to all IPs from the security group settings. Otherwise, access cannot be provided from a different network.
Conclusion
Running websites using traditional structures leaves many companies faced with many problems such as labor costs, high error rates and loss of time. Thanks to the advantages brought by Docker and Kubernetes, we can quickly convert applications running on many different web service infrastructures such as Apache, Tomcat, NodeJS, nginx into container structures. At this point, Huawei Cloud’s CCE service will be the best choice to solve these problems with its stable, easy to use and functional structure.
https://info.support.huawei.com/info-finder/encyclopedia/en/Docker+Container.html