How circleCI fits into the setup | step 3
Tags: kubernetes, helm, circleci, cicd
Published: 2020-09-14 05:36:48

CircleCI is a tool to handle the continuous integration and continuous development.

Basically, Continuous Integration means multiple developers pushing small, frequent changes to a shared repository or ‘master’. They are integrating changes continuously, rather than periodically.

Because the CD is a periodic process and CI is not the CD is getting handled separately.



### **How does CircleCI helps?**

CIrcleCI provides simple integration to code repositories like github and bitbucket

It automatically run the circleCI pipeline when triggered by merges.

Notification of everything happening on the attached circleCI's

Build all jobs within one  circle.yml file.

No need to manage server as every job will be started on new environment.

Web UI is truly interactive and improving frequently



#### *To attach repositories*

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/j6af2drvbp05iapqykcg.JPG)







> ##### *Thanks to role set access control based on SSH key, because It is important when working as an organization.*

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/smsdqanp2eal2r06ncnu.JPG)





#### `circle.yml` explained

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/inyvct026rpck1xcvc9i.JPG)

  

**Add a folder '.cirlceci', create 'config.yml', and push it to the repository to active the triggers of repository attached to circleCI**



### **Points to understand**

- workflow (lines 30-37) - runs the jobs in a sequence
- jobs (lines 5-28) - The jobs level contains a collection of arbitrarily named children. build is the first named child in the jobs
- filter (lines 35-37) - pipeline only triggers when a request is merged in the listed branch
- build (lines 6-16) - Boilerplate kind of jobs
- steps (lines 20-28) - actual commands run in a sequence as it is declared
- orbs - explained below



### **Importance of orbs**

Orbs is reusable package of YAML configuration that contains repeated pieces of config into a single line of code. CircleCI orbs are open-source, shareable packages of reusable configuration elements, including [jobs](https://circleci.com/docs/2.0/reusing-config/#authoring-parameterized-jobs), [commands](https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands), and [executors](https://circleci.com/docs/2.0/reusing-config/#executor).

orbs save a lot of extra efforts and time. The [Orb Registry](https://circleci.com/orbs/registry/) is an open repository of all published orbs



> In config.yml from line 12-21 all the steps are the command of the orbs.
>
> node, gcp-gcr, gcp-gke, helm are the orbs which are getting used in the setup.

`gcp-gcr` .  An orb for working with [Google Container Registry](https://cloud.google.com/container-registry) . `gcr/gcr-auth` is authentication to google container registry and it fetch the credentials from circleCI environment variable. Environment variable will not get exposed throughout, the execution of pipeline which indicate that sensitive data can be store inside.



#### Environment Variables

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xe4ibvadzsll09xz7l90.JPG)



The target of this part of setup is to store all the unique tags of images in google container registry  with the help of `CIRCLE_SHA1` which is unique commit id and those tags were further use to update the deployment.



video link is there for the whole implementation

{% youtube 43-JQ5xuk0A %}