Terraform Integrated with GitHub Actions to setup Argo CD on Civo πŸŽ‘πŸ‹πŸ’™

Vrukshali Torawane
5 min readDec 3, 2021

--

πŸš€ GitHub Actions

GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. You can create workflows that build and test every pull request to your repository, or deploy merged pull requests to production.

GitHub Actions goes beyond just DevOps and lets you run workflows when other events happen in your repository. For example, you can run a workflow to automatically add the appropriate labels whenever someone creates a new issue in your repository.

GitHub provides Linux, Windows, and macOS virtual machines to run your workflows, or you can host your own self-hosted runners in your own data center or cloud infrastructure.

More Information : https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions

πŸ¦‘ Argo CD

ArgoCD is a GitOps tool that helps with your GitOps workflows. ArgoCD can be used as a standalone tool or as a part of your CI/CD workflow. ArgoCD works with Git as a source off truth, with current Kubernetes manifests, or with Helm charts.

More Information : https://argo-cd.readthedocs.io/en/stable/

⚑Terraform

Terraform is an infrastructure as code (IaC) tool that allows you to build, change, and version infrastructure safely and efficiently. This includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc. Terraform can manage both existing service providers and custom in-house solutions.

More Information : https://www.terraform.io/intro/index.html

🀠 Civo

Civo is the first cloud native service provider powered only by Kubernetes. Blazing fast cluster launch times in under 90 seconds and simplified developer experience.

❄ Architecture

Let’s start :

Terraform code for Launching Civo Cluster with Argo CD :

Note: You need to create token first to connect to CIVO :

Create token here : https://www.civo.com/account/security

πŸ‘‰πŸ» provider.tf

You can create secret in github to store your token (I have directly pasted the token)

terraform {
required_providers {
civo = {
source = "civo/civo"
version = "0.10.3"
}
}
}
provider "civo" {
token = "token"
region = "LON1"
}

πŸ‘‰πŸ» main.tf

resource "civo_kubernetes_cluster" "cluster" {
name = "sample"
applications = "-Traefik,-metrics-server,argo-cd"
num_target_nodes = 3
target_nodes_size = "g3.k3s.medium"
}

πŸ‘‰πŸ» In your GitHub Repository, Click Setup Terraform Workflow :

πŸ‘‰πŸ» Code :

πŸ‘‰πŸ» Workflow :

πŸ‘‰πŸ» Cluster with 3 nodes launched :

πŸ‘‰πŸ» Logging in to Argo CD web console :

  1. After creating cluster you need to download kubeconfig file.
  2. Then need to have kubectl installed in your local system [Note: You can use civo CLI as well]
  3. Let’s see :

Here, we can see 3 nodes are up and running :

Here, you can see argocd namespace :

Here, you can see now :

ArgoCD usernameis admin and password is stored in secrects(argocd-initial-admin-secret :

Convert it into base64 and there you go:

Now create a git repository as source of truth :

Link to my repo : https://github.com/Vrukshali-26/K8S-yamls

πŸ‘‰πŸ» Now follow below steps :

Step 1: Go to Manage your repositories tab :

Step 2 : Click on repositories

Step 3 : Click on connect repo using https :

Step 4 : Add link to your repo and connect !!

πŸ‘‰πŸ» Let’s go and do some configuration :

Here you can see new namespace with name new-ns will be created for that select the option Auto-create NameSpace and click CREATE!

Now, you can see below new namespace and resources are created!

Hope you learnt something new and you liked it!

Thanks for Reading !! πŸ™ŒπŸ»πŸ˜πŸ“ƒ

πŸ”° Keep Learning !! Keep Sharing !! πŸ”°

πŸš€ Feel free to connect with me :

LinkedIn : https://www.linkedin.com/in/vrukshali-torawane/

GitHub : https://github.com/Vrukshali-26

Twitter : https://twitter.com/Vrukshali26

--

--