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.

目录
打赏
0
0
0
0
45
分享
相关文章
plugin cannot be loaded for module “QtQuick“ && Could not load the Qt platform plugin “windows“
本文讨论了在Qt应用程序中遇到的平台插件加载问题,包括具体的错误信息、解决方案和参考链接。问题表现为无法加载“QtQuick”模块的插件,并且无法找到“windows”平台插件。解决方案是修改环境变量`Qt5_DIR`以使用正确的Qt版本和编译器环境。
414 1
[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.
108 1
vs2019 This application failed to start because it could not find or load the QT platform plugin
这篇文章介绍了在VS2019中解决QT程序运行时出现的“无法找到或加载QT平台插件”错误的步骤,通过将必要的DLL文件和插件目录复制到项目解决方案中解决了问题。
《500 Lines or Less》(4)Contingent: A Fully Dynamic Build System(构建系统)
《500 Lines or Less》(4)Contingent: A Fully Dynamic Build System(构建系统)
报错解决:Could not build wheels for soxr, which is required to install pyproject.toml-based projects(可用)
链接如下:【金山文档】 1-Microsoft Visual C++ Build Tools。找了好久,才找到正确的解决方案,网上一大堆升级setuptools的方法只对少数人管用。注意,虽然我的这个报错内容有点长,但是我感觉和其它的。如果网页提示登录,可以不用登录,直接下载即可。然后打开镜像ios文件(双击即可)错误是一样的解决方案。文件,打开后安装即可。
2962 1
报错解决:Could not build wheels for soxr, which is required to install pyproject.toml-based projects(可用)
编译JDK11:ERROR: Build failed for target ‘default (exploded-image)‘ in configuration ‘windows-x86_64
编译JDK11:ERROR: Build failed for target ‘default (exploded-image)‘ in configuration ‘windows-x86_64
313 0
Failed to find Build Tools revision 25.0.2
Failed to find Build Tools revision 25.0.2
151 0
Perhaps you should add the directory containing libpcre.pc to the PKG_CONFIG_PATH
Perhaps you should add the directory containing libpcre.pc to the PKG_CONFIG_PATH
207 0
ERROR:the default discovery settings are unsuitable for production use
ERROR:the default discovery settings are unsuitable for production use
238 0

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等