Setting up a Multi-Cloud CI/CD Chain using Alibaba Tools

简介: These days, having a continuous integration and delivery (CI/CD) pipeline in place is pretty much essential for any kind of software development.

NW_005

These days, having a continuous integration and delivery (CI/CD) pipeline in place is pretty much essential for any kind of software development. Therefore, the question isn’t so much if you should set up a CI/CD pipeline, but how.

And when it comes to the how of CI/CD, you have a lot of options. There are countless CI/CD solutions on the market, including commercial as well as open source platforms, both of which have their own distinct advantages and disadvantages over the other.

In this article, I outline the reasons why you may wish to use a commercial CI/CD platform, then walk through the steps of taking advantage of tools on Alibaba Cloud that allow you to set up a production-ready CI/CD pipeline.

Commercial vs Open Source

A commercial CI/CD platform is typically a hosted service that deals with the build and deployment steps in a standard pipeline. While there are privacy concerns that can be raised with commercial platforms, and the cost is generally higher than self-hosted solutions, they are a great way to establish a CI/CD pipeline with minimal resources. In addition to hosted services, on-premises commercial CI/CD solutions are available as well, which can help get around the privacy and security concerns that exist with hosted services.

Many commercial CI/CD platforms give back to the developer community by open-sourcing their CI/CD engines. While not every commercial platform open-sources their engine, and not every open source engine is backed by a commercial platform, these solutions provide a lot more control at the expense of ease-of-use. Spinning up an open source CI/CD platform is significantly more involved, and requires some sort of server to run on. Open source platforms are an excellent option for organizations that require more resources for their build processes, or even organizations that simply prefer to keep their code in-house whenever possible.

Alibaba + CI/CD

When it comes to hosting an application on Alibaba Cloud, both CI/CD solutions are viable—depending on the needs and use-cases of the application. To demonstrate, let's take a look at how to accomplish running remote commands and deploying a simple application using either a commercial or open source CI/CD platform. While the configuration of open source and commercial solutions differ, the process of actually implementing a CI/CD pipeline is pretty similar across the board, and interacting with servers—both in a private and public cloud—comes down to two commands: rsync and ssh.

Deployments in a Nutshell

Before we get started, let's assume that our CI/CD pipeline consists of only three parts: test -> build -> deploy. While the test and build processes can happen directly within the platform, deploying a build means that we will have to get creative with our deployment method. Some cloud providers offer APIs that make this solution feel more streamlined, but at a high level, the following method will work with any VPS. Thankfully, we can deploy any built code to a running ECS instance using standard shell commands:

rsync -r --delete-after --quiet /path/to/build <ssh-user>@<ecs-host>:path/to/files

rsync is a command line utility that is used to synchronize files across servers. It has been around for a while—The rsync algorithm is well-known as having been used by Dropbox to deal with file synchronization. The beauty of this deployment method is that it can be used regardless of the hosting provider you use, which means that you can deploy to multiple cloud providers simultaneously, both internally at Alibaba Cloud, and externally.

It is important to note that, in order to successfully authenticate to our ECS instance, you will have to generate an SSH key and give your CI/CD platform access to it. While out of the scope of this article, Digital Ocean has an excellent guide for generating SSH keys. (Take note: If you follow the Digital Ocean guide, you should not set up an SSH passphrase—otherwise your automated deploy process won't be able to use your key.)

Executing Commands

Now, imagine that we need to execute a new command on our CI/CD pipeline. Let's say, for example, that after deployment we need to run database migrations on ApsaraDB, updating our pipeline to test -> build -> deploy -> migrate. As with the above deployment command, this can be accomplished through a simple SSH command:

ssh <ssh-user>@<ecs-host> -C "<migration-command>"

The -C option of the SSH command will execute any command within the login shell you have created. Using this principle, we can accomplish significantly more than running simple database migrations. This allows us to interact with various Alibaba Cloud services, such as clearing a cache that is stored in ApsaraDB for Redis, which can only be accessed from within the Alibaba Cloud Intranet.

Next Steps

While the above commands are enough to deploy and interact with any VPS at a basic level, building out a more robust pipeline using the Alibaba Cloud API will give you far more control. It will give you the ability to more programmatically interact with resources, manage your load balancers, automatically provision staging servers, and more. This solution is far more involved, but will provide you with the same level of control you can find with other fully integrated CI/CD hosting platforms. When it comes down to it, building a proper CI/CD pipeline is about planning and automation, not the specific tool you use. Given the right commands, anything is possible, no matter what platform you use.

Bio

01

Zachary Flower (@zachflower) is a Fixate IO Contributor and lead developer at Emerson Stone, a Boulder-based design and branding agency. He has an eye for simplicity and usability, and strives to build products with both the end user and business goals in mind. From building projects for the NSA to creating features for companies like Name.com and Buffer, Zach has always taken a strong stand against needlessly reinventing the wheel, often advocating for the use of well established third-party and open source services and solutions to improve the efficiency and reliability of a development project.

目录
相关文章
|
3月前
|
Android开发
[ionic]解决Could not read build file capacitor/build.gradle as it does notexist.
[ionic]解决Could not read build file capacitor/build.gradle as it does notexist.
33 1
|
4月前
|
存储 JavaScript 算法
若依修改-Starting development server...10% building 0/1 modules 1 active ...-node
若依修改-Starting development server...10% building 0/1 modules 1 active ...-node
|
5月前
|
Java
ElasticSearch启动报错 java version is an early-access build ,only use release builds【已解决】
ElasticSearch启动报错 java version is an early-access build ,only use release builds【已解决】
63 0
|
C++ iOS开发
报错解决:Could not build wheels for soxr, which is required to install pyproject.toml-based projects(可用)
链接如下:【金山文档】 1-Microsoft Visual C++ Build Tools。找了好久,才找到正确的解决方案,网上一大堆升级setuptools的方法只对少数人管用。注意,虽然我的这个报错内容有点长,但是我感觉和其它的。如果网页提示登录,可以不用登录,直接下载即可。然后打开镜像ios文件(双击即可)错误是一样的解决方案。文件,打开后安装即可。
2633 1
报错解决:Could not build wheels for soxr, which is required to install pyproject.toml-based projects(可用)
No matching configuration of project :libusb was found.
No matching configuration of project :libusb was found.
606 0
No plugin found for prefix ‘doclint‘ in the current project
No plugin found for prefix ‘doclint‘ in the current project
128 0
|
开发工具
Failed to find Build Tools revision 25.0.2
Failed to find Build Tools revision 25.0.2
126 0
|
Docker 容器
ERROR:the default discovery settings are unsuitable for production use
ERROR:the default discovery settings are unsuitable for production use
213 0
|
开发工具 Android开发
Failed to find Build Tools revision 28.0.3
Failed to find Build Tools revision 28.0.3
304 0
Failed to find Build Tools revision 28.0.3
|
JavaScript 前端开发 物联网
12 Open Source Projects by Alibaba – Part 2
This article introduces and summarizes twelve open source projects from Alibaba and Alibaba Cloud.
2264 0
12 Open Source Projects by Alibaba – Part 2