Atlantis -GitOps

 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

In a nut shell GitOps is purely an automated process that leverages on purely version controller purely version controlled a git tool deploy infrastructure code .

Atlantis is a GitOps tools that allows you to track everything in your infrastructure code repo. 

Lets attempt to setup Atlantis on our local machine . I have created a new repository for this series which is what I have opened up for the VS code session . I will create a new directory called scripts  and I will create a new file inside this folder called - local-setup.sh 

This script will contain all the necessary steps to run the  pre-requisites step to run Atlantis local setup.

  1. Downloading the Atlantis library 



2. Before we go any further lets do re-factoring on the fly .

We will define atlantis version and atlantis package. I will define appropriate values from the URL and pull the variables.



Next step is to make my local Proxy available to accessible via internet. For that we will setup NGROK .


I also need to download a secret string that I need to setup for my Atlantis setup . Github configuration which we will see later on. 


I am going to change the permission of this file to make it executable. And I am going to run this script.

I am going to copy the secret generated script on the console. 


I am going to copy the secret and store all my local environment variables starting with the secret variable ==> atlantis.var


Next I will add a Infrastructure repository to integrate with Atlantis . Before that I shall run NGROK on port 4141 . 

Port 4141 is what Atlantis will open once it is running. 

./ngrok http 4141

And the forwarding URL that is provided in this console will be the end point that will make the Atlantis instance accessible from Internet . 



So I am going to copy this URL from this console. And then head back to my code 

In the variables file i will add another variable called the URL and set the NGROK end point. 



Let me switch back to my Git account on my web browser 

In my repository I am going to setting and set webhooks . Click Add Webhook > I would set the 
payload URL to NGROK endpoint . 





and add keywords > events at the end. 
change the content type to > application/json

I will place here the randomly generated secret key when i ran my setup script.



In the section "which event would you like to trigger"

> Let me select individual events 

Make sure to select the following.

> Issue comments  -- this will allow issue and comments from the pull request . -- we will see how this works exactly later on. 
> Pull request reviews -- 
> Pushes
> Pull requests

And at the bottom of this page click --> Web Hook 

In my Atlantis.var file we will add two more variables.


USERNAME 
REPO_ALLOWLIST



to start my Atlantis local instance I will create a new script and call it -- Atlantis.sh 

The first step that I will do inside my script is source my viable file. 


And I will open up a new terminal to make sure I am not disturbing my NGROK session . And I will make my new Atlantis script executable. And start running my local Atlantis instance 


And now it is all set . 

And now it is time to create a new branch out of my repo and raise a pull request . lets switch vscode sessions . 

He is creating a new file inside the tfvars directory and call it poc.tfvars and inside this file I will set the permissions . This is the same permission list that I have defined in terragrunt file . 


I am going to commit my changes and push my changes to the remote repository . 

Notice the process was automatically pulled as a the pull request checks.









































Comments

Popular posts from this blog

Altlantis : Lesson 1