Deploy application in Kubernetes cluster using GoCD with helm

Software Engineer - 11 October 2019 -
Software Engineer - 11 October 2019 -
This blog will explain the deployment of the micro-service applications using the GoCD with Helm deployment manager in the K8s cluster.
Blog consider that user is having some background knowledge of below technology
GoCD is an opensource tool used in the software development process. It supports continuous integration and continuous delivery (CI/CD) software lifecycle.
GoCD Architecture
– material update sub-system
– scheduling sub-system
– work assignment sub-system.
Tasks: This is a single entity consider as a single command.
Eg. sh –c mvn install
Fig. Task
Job: Job consist of multiple tasks. Bended to run sequentially. The tasks are run independently will not get affected by other tasks definitions. Job will stop execution if previous tasks failed tasks queue.
Fig. Job
Stage: stage consist of multiple jobs. The jobs are executed in parallel. if a single job failed then also the other job will complete its tasks independently.
Fig. Stage
Pipeline: pipeline consist of multiple stages. The stages are run in sequence.
Fig. Pipeline
Materials: GoCD supports Git, SVN, Mercurial repository, artifact publish by the GoCD pipeline.
Trigger: GoCD pipeline can be triggered based on manual, commit, time schedule and based on previous pipeline status – failed/passed
Fig. Materials and trigger
Value Stream Map: Visual map for pipelines and its connectivity.
Artifacts: Every job can publish its own material so that other jobs or stage can access in execution.
Agent: GoCD agents are the workers in GoCD, they will pick-up the tasks from the pipeline and execute them. The agents are in ideal state until the pipeline gets a trigger.
Resources: Resource is the tagging for an agent. Using tagging jobs can decide to run the tasks on the specific agents. Generally, the tags are assigned with specific software installed on agent. For example, the maven job we can have the agent running with a maven package installed on it.
Environments: Environment is to isolate the pipeline and agent. The pipeline will only run its job on an agent within the same environment. Else if no environment is assigned pipeline will run on an agent with no environment assigned
Installation of GoCD
systemctl start go-server
In GoCD practical mention the lab setup we are using.
Configure kubectl in GoCD server
kubectl get pod
Install docker and enable the docker access to `go` system user.
Helm:
Helm tool helps to manage the Kubernetes application. Just store the Kubernetes template using helm chart and use helm with install, update. Helm allows creating a configuration package so we can use the same k8s template with multiple environments.
In our scenario, we are going to use the Helm atop of Kubernetes orchestration scripts.
Configure the helm package
helm init
Create the helm chart.
Install maven on GoCD server
mvn -v
Quick check for what we have setup.
Let’s start with the practical
In the following tutorial, we are going to create a maven build, build a docker image from build and deploy the image in Kubernetes cluster using the helm package.
Pre-requisite
Deploy Kubernetes application using GoCD pipelines
Step 1. In basic setting pass the pipeline name and pipeline group name. –> Next
Step 2. Provide the materials. Materials type URL is mandatory. Also, check the connection before processing. If a connection does not work, follow this step to Connecting to GitHub with SSH [ https://help.github.com/en/articles/connecting-to-github-with-ssh ]
Once the step is done. Run the below command by replacing your repo name. Confirm the connection request.
git ls-remote git@github.com:<repo_name> refs/heads/dev
Once, this step is done again try to run the connection test from the GoCD console.
Step 3. Stage/Job definition, add the name for stage. Configure the trigger.
Initial job details. Save the settings.
Step 1. Add the pipeline name and add the pipeline group name
Step 2. Add the material as build pipeline. So, the deployment will get trigger when build is done. Select the build pipeline name from dropdown.
Step 3: Add the stage and job for the deployment as below. Adding first step as docker pull
It’s done.
Leave a Reply