Terraform Integrated with GitHub Actions to setup Argo CD on Civo π‘ππ
π 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 :
- After creating cluster you need to download kubeconfig file.
- Then need to have kubectl installed in your local system [Note: You can use civo CLI as well]
- 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 username
is 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