For the readers of this article

If you are a beginner to Kubernetes, this article can help you quickly set up a working cluster environment on the cloud and launch your first application. You don’t need to prepare any hardware resources or download any software packages in advance. If you already have a self-built Kubernetes cluster and want to try a managed cluster on Ali Cloud, this article can help you quickly get started without having to read ali Cloud’s help documentation in detail, thereby saving you time. You can optionally read the help documentation for container services and container mirroring services after you have a first end-to-end experience. If you already have a traditional Web application deployed in the cloud (such as ECS deployed in the cloud) and want to make a container transformation, this article can also help you. You don’t even need to learn Kubernetes in depth, just understand the basic concepts.

Ready to code

All the operations in this article are based on Ali Cloud console, so you only need an Ali cloud console login account. Let’s get the application code ready. Please login code.aliyun.com/, after completion of the login, visit code.aliyun.com/shengbo.tsb… Click the icon for the fork item.



In the confirmation box that pops up, click on the avatar to confirm the derivation.



Alternative: If you have trouble deriving, you can go directly to github.com/docker-trai… Clone the project and push it to code.aliyun.com by git yourself.

Preparing the Mirror Warehouse

Login cr.console.aliyun.com/cn-beijing/… Choose Namespace in the left navigation bar.



Click “Create command Space” and enter the name “tengshengbo”.

After confirming that the namespace is created, click “Mirror Repository” in the left navigation bar, click “Create Mirror Repository”, and enter the repository name “Yunputest”.



In the next step, select the repository you just created. Select “Overseas Machine Build” to speed up the build. Tip: If there is no code repository in the drop-down box, click the refresh button on the right.



Creating a New image

Go back to code.aliyun.com/ and click on the yunputest project. Note that the project is under your own name, not the shengbo.tsb account. Click New TAB.





Enter the label name release-v1.5. Note that you must use the release-v[version number] form, such as release-v2.5 or otherwise.



Return to the list of image warehouses, cr.console.aliyun.com/cn-beijing/… Select your own mirror repository and choose “Build” in the left navigation. You can see that a build is automatically generated.



Create a Kubernetes cluster

Access the Container Services console cs.console.aliyun.com/#/k8s/clust… Select “Create Kubernetes Cluster” and select the first “Standard managed cluster” for the cluster template



Select Yunpu-k8s for the cluster name, private network and virtual switch, public network access (for the convenience of development and testing), instance type (t5 or T6 instances can be used simply to save money without considering performance), and other default Settings are good.



Note: The Pod CIDR and Service CIDR cannot conflict with existing network segments in the VPC. If an error message is displayed, change the network CIDR.



Select the protocol in the confirmation dialog box to complete the creation. After that, verify that your cluster is running.



Deploy the first application

In the navigation tree on the left of the container service, choose Application – Stateless and click Create with Image. In the Basic Application Information area, enter the application name Yunpuapp and select the newly created cluster Yunpu-k8s. The other default values are as follows:



Next, container configuration, image name, click “Select Image”, select the image that was created automatically from the code



For mirror Tag, click “Select Mirror Tag” and select the version number you just defined, such as 1.4. Leave everything else as default. Click Next.



In advanced configuration, click Create next to Service.



For port mapping, enter the name port. Note service port 80 and container port 5000.



Click “Create” next to “Ingress”, enter the domain name Yunpuapp and select the service you just created along with port.



After the application is successfully created, you can see the access method of the application. In the “Routing (Ingress)”, there is a link under “Rules”.



Click the link to access the application, which displays the response time, host name, and IP address of the application when it runs. If you refresh the link several times, you can see different IP addresses.



Upgrade application

It is recommended that you try to change the application code yourself, such as simply changing the webapp/app.py file, and git push after completing the git tag.

$git tag release-v1.5 $git push origin release-v1.5Copy the code
Alternatively, you can create a new tag release-v1.5 for the Master branch directly from the code.aliyun.com/ console

After the image is updated, click Edit next to the app on the Stateless App page.



Edit the page, select the new version 1.5, and click Update



The next step

Aliyun’s container service Kubernetes is not only a managed version, but also a proprietary version and Serverless version. The proprietary version is suitable for large enterprise users who have rich experience in container operation and maintenance, want to run an application for a long time, and independently operate and maintain all the infrastructure. Serverless is for small and medium business users who don’t want to care about infrastructure operations, or who just want to run an application for a short period of time and want to use it right out of the box. The managed version described in this article is somewhere in between the proprietary and Serverless versions.







The original link

This article is the content of Ali Cloud, shall not be reproduced without permission.