{"id":18852083,"url":"https://github.com/verma-kunal/ci-cd-gitlab-argo","last_synced_at":"2025-07-23T21:32:52.301Z","repository":{"id":181577195,"uuid":"666987380","full_name":"verma-kunal/ci-cd-gitlab-argo","owner":"verma-kunal","description":"CI/CD with GitLab CI and Argo CD","archived":false,"fork":false,"pushed_at":"2023-07-16T09:13:28.000Z","size":745,"stargazers_count":7,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-08T03:40:52.562Z","etag":null,"topics":["argocd","docker","gitlab-migrated","kubernetes","ngrok","sonarqube"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/verma-kunal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-16T09:02:24.000Z","updated_at":"2024-07-15T01:22:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"ce9fa173-9388-441d-bf12-a952066df3e9","html_url":"https://github.com/verma-kunal/ci-cd-gitlab-argo","commit_stats":null,"previous_names":["verma-kunal/ci-cd-gitlab-argo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/verma-kunal%2Fci-cd-gitlab-argo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/verma-kunal%2Fci-cd-gitlab-argo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/verma-kunal%2Fci-cd-gitlab-argo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/verma-kunal%2Fci-cd-gitlab-argo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/verma-kunal","download_url":"https://codeload.github.com/verma-kunal/ci-cd-gitlab-argo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231888988,"owners_count":18441359,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argocd","docker","gitlab-migrated","kubernetes","ngrok","sonarqube"],"created_at":"2024-11-08T03:37:58.110Z","updated_at":"2024-12-30T16:56:34.176Z","avatar_url":"https://github.com/verma-kunal.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CI/CD with GitLab CI and Argo CD\n\u003e **📍 NOTE:**\n\u003e \n\u003e This project has originally been implemented on GitLab, as it's specifically focused towards using the GitLab CI.\n\u003e [GitLab repo link](https://gitlab.com/devops-projects6943118/ci-cd/go-rest-api)\n\n![](./images/illustration.png)\n\n## Introduction \n\nThis project is an implementation of **Continuous Integration and Continuous Deployment (CI/CD)** on a simple [Go-REST-API](https://github.com/verma-kunal/Go-REST-API) application. It provides a comprehensive example of **building**, **testing**, and **deploying** a Go application using **GitLab CI** and **Argo CD**.\n\n## Features\n\n* RESTful API built with **Go** and **Gin**\n* Demonstrates all **CRUD operations**\n* Includes simple test suite for **unit testing**\n* A configured CI/CD pipeline for automated **building**, **testing**, and **deployment**\n* **Static Code Analysis** using [SonarQube](https://www.sonarsource.com/products/sonarqube/)\n* **GitOps enabled** - Utilizes **Argo CD** for **Kubernetes-based** deployment\n* **Dockerized application** for easy deployment and scalability\n\n## Prerequisites\n\nBefore getting started with this project, ensure you have the following dependencies installed:\n\n- [Go (version 1.16+)](https://go.dev/doc/install)\n- [Docker](https://www.docker.com/)\n- [Kubernetes Cluster](https://kubernetes.io/docs/setup/) (either local or on Cloud)\n- SonarQube server up and running\n    - Refer the [documentation](https://docs.sonarqube.org/latest/) to configure SonarQube\n- [Ngrok](https://ngrok.com/) (if you wish to run SonarQube in Docker)\n- [Argo CD](https://argo-cd.readthedocs.io/en/stable/) installed\n\n## Getting Started\n\n### Setup the Project\n\nPlease follow the instructions given in the [README](https://github.com/verma-kunal/Go-REST-API), to set up the **GO-REST-API application** correctly.\n\n## Overview of CI/CD Workflow\n\n### GitLab CI - Continuous Integration\n\nRefer the [**`.gitlab-ci.yml`**](https://gitlab.com/devops-projects6943118/ci-cd/go-rest-api/-/blob/main/.gitlab-ci.yml) for the full configuration.\n\n#### Prerequisites\n\n- Setup the following environment variables:\n    - `DOCKERHUB_USER` - DockerHub Username\n    - `DOCKERHUB_PASS` - DockerHub Password or Access Token\n    - `SONAR_TOKEN` - SonarQube Token\n    - `SSH_KNOWN_HOSTS` - SSH known hosts for GitLab (with `ssh-keyscan`)\n    - `SSH_PRIVATE_KEY` - SSH private key\n\nThe CI pipeline consists of 5 stages:\n\n1. **build** - Builds the Go binaries for Darwin, Linux and Windows\n2. **test** - Run simple unit tests using [Go testing library](https://)\n3. **code_quality** - Static code analysis using [SonarQube](https://)\n4. **image_build** - Builds a new docker image and push to DockerHub\n5. **update_k8s_manifest** - Updates the latest image tag in Kubernetes manifests\n\n\u003e **📍NOTE:**\n\u003e \n\u003e The CI pipeline is configured to be triggered \"on push\" to the project. There are two conditions defined:\n\u003e\n\u003e 1. Trigger the CI, if the commit message ends with \"-ci\" keyword\n    \u003e Example: **\"update:readme-ci\"**\n\u003e \n\u003e 2. Do not trigger the CI, if the commit message ends with **\"-draft\"** or **\"-test\"**\n\n##### Steps to run SonarQube Locally (Linux)\n\n```\napt install unzip\nadduser sonarqube\nwget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.4.0.54424.zip\nunzip *\nchmod -R 755 /home/sonarqube/sonarqube-9.4.0.54424\nchown -R sonarqube:sonarqube /home/sonarqube/sonarqube-9.4.0.54424\ncd sonarqube-9.4.0.54424/bin/linux-x86-64/\n./sonar.sh start\n```\n\nYou can access the SonarQube Server on **`http://\u003cip-address\u003e:9000`**\n\n##### Steps to run SonarQube on Docker\n\n```\ndocker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest\n```\n\nRefer the [documentation](https://docs.sonarqube.org/9.6/try-out-sonarqube/) for more information.\n\n##### Connecting GitLab and SonarQube Server\n\nIf you are using SonarQube in Docker, you would need to expose the Sonar Server using a tool like [Ngrok](https://ngrok.com/), for GitLab to communicate with it.\n\nRefer the [guide](https://ngrok.com/docs/using-ngrok-with/docker/) to know more about using **Ngrok** and **Docker** together.\n\n\n### Argo CD - Continuous Deployment\n\nRefer the [**`app.yml`**](https://gitlab.com/devops-projects6943118/ci-cd/go-rest-api/-/blob/main/argocd/app.yml) for full application configuration for Argo CD.\n\nA few important points for configuring Argo CD:\n\n1. Replace the namespace \u0026 server cluster URL with the target namespace \u0026 cluster URL for your Kubernetes cluster:\n\n    ```\n    destination:\n        server: https://kubernetes.docker.internal:6443 \n        namespace: go-app\n    ```\n2. Argo CD will automatically sync the application and deploy it based on the configuration defined:\n\n    ```\n    syncPolicy:\n        automated:\n          selfHeal: true\n    ```\n3. Monitor the deployment status and access the application once it's successfully deployed.\n\n    ![](./images/argo.png)\n\n📍 To learn more about Argo CD and configure it in your cluster, refer the [documentation](https://argo-cd.readthedocs.io/en/stable/getting_started/).\n\n## Contributing\n\nContributions are welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the **MIT License**. Feel free to use and modify the code according to your needs.\n\n## Acknowledgements\n\nThe RESTful API has been built with the help of the official Go tutorial - [**Tutorial: Developing a RESTful API with Go and Gin**](https://go.dev/doc/tutorial/web-service-gin).\n\nThe CI/CD workflow is inspired from [Abhishek Veeramalla](https://youtu.be/jNPGo6A4VHc)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverma-kunal%2Fci-cd-gitlab-argo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fverma-kunal%2Fci-cd-gitlab-argo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverma-kunal%2Fci-cd-gitlab-argo/lists"}