Skip to content

code for the ci cd gitops example using argoCD and Drone.io

Notifications You must be signed in to change notification settings

seifrajhi/ci-cd-demo-gitops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

CI/CD Demo

This tutorial shows how to build CI/CD pipeline with DroneCI and ArgoCD. In this demo, we use DroneCI for running tests, publishing new images, and update image tags in the manifest repository. We then use ArgoCD for continuous delivery, synchronizing application states in the Kubernetes cluster with manifests maintained in the Git repository.

This way of doing Kubernetes cluster management and application delivery is kown as GitOps. By applying GitOps, we can maintain a 'source of truth' for both the application code and infrastructure, improving system reliability and efficiency for your team.

Architecture overview:

Prerequisites

  1. A Drone server
  2. A K8s cluster
  3. ArgoCD deployment
  4. A Github account and a Dockerhub account

DroneCI

Setup

After you have connected your Github account with Drone, you can browse all your repositories on Drone dashboard. Next, clone this repo, activate it and navigate to Repositories -> cicd-demo -> settings to add the following secrets:

image

  • docker_username: your Dockerhub account
  • docker_password: your Dockerhub password
  • ssh_key: base64-encoded RSA private key for accessing Github

To access Github using SSH, you should first upload a RSA public key, such as ~/.ssh/id_rsa.pub, to Github. Then, you could generate base64-encoded RSA private key by running cat ~/.ssh/id_rsa | base64.

Finally, replace rajhiseif with your Github and Dockerhub account in .drone.yml. Now any push or pull request will trigger a Drone pipeline. You can check details via your repo -> setting -> webhook on Github.

Local Development

For local development, you will not want to push every change to your repo just for testing whether .drone.yml works. Instead, you can use Drone CLI to execute pipeline locally.

Login to Drone:

export DRONE_SERVER=<drone-server-url>
export DRONE_TOKEN=<drone-token> # check token under dashboard -> user setting
drone info

For example, you can run step test only by executing the following script under the project root:

drone exec --include=<pipline-step-name>

ArgoCD

Please clone the application manifest repository first. This repo holds the application manifests and will be synced with ArgoCD later. The manifests are maintained by Kustomize, which is supported by ArgoCD out-of-the-box.

If your repository is set to private, you need to configure access credentials on ArgoCD. Otherwise you can skip this step and create new app directly.

Credentials can be configured using Argo CD CLI:

argocd repo add <repo-url> --username <username> --password <password>

Or you can configure via UI. Navigate to Settings/Repositories; click Connect Repo using HTTPS and enter credentials:

Create new app:

Remember to place the repository with your own repo.

Now we have finish all preparations, and it's time to let the magic happen. Navigate to /applications and click SYNC button on your app in order to synchronize the cluster state:

You can click your app to view details:

As we can see, ArgoCD automatically sync the application to our desired state specified in production base. It also shows how all resources roll out in the cluster. With ArgoCD, we can not only have complete control over the entire application deployment but also track updates to branches, tags, or pinned to a specific version of manifests at a Git commit.

Reference

About

code for the ci cd gitops example using argoCD and Drone.io

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published