Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In my last post, I covered how you can create a simple Web API, run the Web API in a Docker container and then deploy the container to a Kubernetes cluster provisioned using Azure Container Service (ACS) in Azure. You can find the full post here.
In this blog, I will cover how CI/CD can be implemented so that the sample Web API can be deployed automatically as soon as a change is made to the Web API code. To create the Web API code with Docker support, follow the section “Creating a simple web API with Docker Support using Visual Studio” in my last post here. This blog assumes you have a VSTS account setup and a Team Project created. You can create a VSTS account for free here. It also assumes that the sample API code is checked in to the Team Project version control.
Some tasks we will be using to set up CI/CD don’t come out of the box with VSTS. Instead, you will need to install them from the VSTS Marketplace. The following extensions need to be installed:
Now that we have a build setup, we can set up a release that can deploy the application to our Kubernetes cluster. The following are the steps to do so
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: sampleapi-deployment
spec:
replicas: 3
template:
metadata:
labels:
app: sampleapi
spec:
containers:
- name: sampleapi
image: xyz/sampleapi:latest
ports:
- containerPort: 80
Note: if you make a change to the code, the image version number will need to be updated so that Kubernetes can trigger a deployment. One way to do this is to include a placeholder in the sampleapi.yml as well docker-compose.yml files and then replace these placeholders with actual version numbers for each build during build time. A task such as Replace Tokens can be used to accomplish this substitution.
We have just walked through how to setup CI/CD for a Web API with Docker support running on a Kubernetes cluster. I hope this was informative.
Please leave us your feedback.
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in