A CI/CD pipeline using VSTS to deploy containerized applications to Kubernetes — Part 3
Previous two parts (Part 1 & Part 2) of this article explained how to create A CI/CD pipeline using VSTS to deploy containerized applications to Kubernetes. Now, the question is what’s next? The answer is simple. We are DevOps enthusiasts, we automate things!
As the next step we will be working on building an automation framework that will be capable of creating the entire pipeline with all the customization that one can think of. The idea is to use the REST API support from VSTS.
Here is a glimpse of what we are working on!
VSTS provides REST APIs through which we can automate creation/managing if the resources/tasks in VSTS. Find the official documentation here
VSTS has also a CLI offering to carry out few tasks, but this is in an early stage now and does not allow us to manage all the resources in VSTS. For example, it does not allow you to create/manage build and release definitions in VSTS project. So to achieve this REST APIs are our only option at this point.
Below is an example of how to use the VSTS CLI to create a team project.
You have to download and install VSTS CLI in your laptop first. Click here to know the CLI installation/configuration procedure
Go to Security page and create a personal access token to allow access to your VSTS project from CLI. Personal access tokens can be used instead of a password to allow applications outside the browser access to the resources stored in your account.
Now authenticate to your account using this token:
vsts login — instance https://MYACCOUNT.visualstudio.com — token MYTOKEN
Now to create the project:
vsts project create — name
[ — description]
[ — detect {off, on}]
[ — instance]
[ — open-browser]
[ — process]
[ — source-control {git, tfvc}]
Where — name is a required parameter, others are optional parameters. Find the official documentation here.
Coming back to REST API, it is still evolving and is in preview release version at this point for most of the VSTS resources. Every API request should include an api-version to avoid having your app or service break as APIs evolve. api-versions are in the following format: `{major}.{minor}[-{stage}[.{resource-version}]], for example:
api-version=1.0
api-version=1.2-preview
api-version=2.0-preview.1
Find sample PowerShell scripts which will create the build and release definitions here.
Wrapping Up
I hope this Three part series will help you to get started with CI/CD using VSTS and Kubernetes