A CI-CD pipeline has always been an efficient and sustainable way to deliver high velocity bug free code.
What makes it even more interesting is its ability to facilitate automation in the software delivery process.
So what is CI-CD ?
CI stands for continuous integration. i.e Any change in the code automatically generates build-and-test sequence for the project. Continuous delivery on the other hand provisions automatic infrastructure deployment that too with full visibility to the entire team for each fully logged run.
It is interesting to see how software industry is adapting to the use of containers as a way to facilitate development and environment orchestration for application developers. The reason being effective management of available resources which allow for improved scalability and provide support for continuous delivery of new features. Kubernetes is a platform agnostic container orchestration that has been lately a recipe for the Dev-op enthusiasts.
So, whats missing is a well orchestrated pipeline that can manage deployments to Kubernetes cluster. There are a lot many options available that can be considered for this specific operation but here in this blog we will stick to Atlassian owned services.
A simple block diagram of CI/CD pipeline to push docker images to Kubernetes cluster.
- Kubernetes cluster (AWS cloud is used here)
- J frog Artifactory to work as Docker registry and to host Docker images
- Bamboo Server
- Bit-bucket git repository
From Bit bucket, click the + icon in the global sidebar and select Repository.
Bit bucket displays the Create a new repository page. Take some time to review the dialogs contents. With the exception of the Repository type, everything you enter on this page you can later change.
BitbucketStationLocations for the Name field.
Bit-bucket uses this Name in the URL of the repository. For example, if the user
the_best has a repository called
awesome_repo, the URL for that repository would be
Keep the rest of the options as is unless you want to change them:
- Access level — Leave the This is a private repository box checked. A private repository is only visible to you and those with access. If this box is unchecked, anyone can see your repository.
- Include a READ ME? — If you recently created your account, this defaults to a tutorial READ ME. For the purposes of this tutorial, pick either of the Yes options, that way you’ll start out with a file.
- Version control system — Keep Git for the purposes of this tutorial.
Click Create repository.
Bit-bucket creates your repository and displays its Source page
Any new commits to bit-bucket can be made the same way as any git repository . e.g. GitHub
git add <file name>
git commit “new commit ”
git push original master
The above ones are few basic commands. One can play with many more depending on the use case and requirement.
In Bamboo a CI-CD pipeline need to be created which gets triggered, the moment there is a new commit in the Bit-bucket repository.
The first step is to create a plan
After the plan configuration is finished, another window opens where number of jobs and type of jobs need to be defined for the pipeline
The repository option will automatically show the git repository created in the bit-bucket. This task clones your already linked repository to build plan’s workspace
Next, create another task which will create an image out of Docker file. The docker file from the bit-bucket repository will be pulled out and docker image will be created out of it.
Now its time to push the image to the registry created in Artifactory
The repository address need to be same in both the tasks; one to create an image out of a docker file and another one to push the image to docker registry hosted in Artifactory.
Artifactory hosts three types of repository:
Local and remote repositories are true physical repositories, while a virtual repository is actually an aggregation of them used to create controlled domains for search and resolution of artifacts.To configure repositories, in the Admin module, select Repositories.Repositories can be created, deleted, edited, ordered and aggregated.
Pulling Docker images from private registry
In order to run applications, Docker images have to be pulled from the private Docker registry hosted in Artifatory. To facilitate that, additional configurations need to be set in Docker in the Kubernetes hosts and on the pods.
- Add authentication information in Docker
In order to enable docker to be able to pull images, authentication information needs to be added to $HOME/.docker/config.json file ON ALL WORKERS. This is automatically done when docker login is executed on the respective workers
Now docker pull can be performed on images in the private registry.
2. Create a secret from the config file and reference it on the pod specification, following the steps described here
Coming up ….
So, what you see in this blog is a quick and dirty way to configure application deploy-able pipeline. Still there are a lot many ways one can improvise on Continuous deployment in Bamboo.
Grafana and Prometheus as a monitoring and logging solution might be next on the talks.
So till then…..