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

--

--

Recommended from Medium

Lists

See more recommendations