TLDR: This repository creates a local sandbox environment with a kubernetes cluster and Argo CD and showcases various possibilities of managing multiple stages of an application and how to promote new releases.
- Only tested on Fedora and Ubuntu
- Install the following tools:
- Docker with capability of running Docker without sudo
- kubectl
- helm
- k3d (version 5.x)
Follow all these steps in the exact order. You wil have to switch between GitHub settings and your locally cloned fork a few times.
- Fork this repository. Leave repository name as "gitops-test-env".
- Go to https://github.com/settings/tokens and click on
Generate new token (Classic)
. Give it the following scopes and any name, save it and copy your generated token (we will need it in the next few steps): - Go to https://github.com/USERNAME/gitops-test-env/settings/secrets/actions and create a
Repository secret
calledRENOVATE_TOKEN
. Use the previously generated Token as the value. - Go to https://github.com/USERNAME/gitops-test-env/settings/actions and set the following Actions settings:
- Clone your fork
- In the root path of the cloned fork, run the following command after adding your GitHub username in it (renames all occurences of the original repository or ghcr to yours):
# IMPORTANT NOTE:
# write your github username here in lowercase (e.g.: your name is FooBar, then type in GH_USER_NAME=foobar)
GH_USER_NAME=<your-github-user-name>
grep -rl --exclude-dir=.git --exclude=Readme.md --exclude=LICENSE lukma99 . | xargs sed -i "s/lukma99/${GH_USER_NAME}/g"
- Go to
.github/renovate.js
and manually replace the e-mail-address ingitAuthor
with your own GitHub e-mail-address you use for commits. If your GitHub username contains uppercase letters, then also correct the two occurrences of your username in this file. Other than in the script, you must provide you username here as it appears in GitHub with possible uppercase letters. - Commit and push these changes.
- Go to GitHub Actions, allow them to be run,
88B4
and run the job
Build and Push Docker Image
with the tag1.0.0
(because all manifests are initially set to this version). Don't worry that after the first run, the jobDeployment Pipeline with PRs
will start and fail. That is because there is nothing to change in the YAMLs yet, as1.0.0
is already included in them.
- Make sure port 8080 is not used by anything. If you must use another port, then change it at the top of
./scripts/setup_cluster.sh
. Remember that all following links will then also use this port. - In the root path of the cloned fork, run
./scripts/setup_cluster.sh
. This will install a local k3d cluster with Argo CD ready to use with this project. During the script it will ask you to enter your GitHub Username and previously generated token. - Go to
http://localhost:8080/argocd
. Wait a few minutes for first sync or pressSync now
. All applications should be deployed and are accessible with the links from the section Accessing Argo CD and deployed applications.
Port can be changed by changing INGRESS_PORT
in ./scripts/setup_cluster.sh
Argo CD:
For the deployments, either click on the following links or find them by yourself on the Argo CD UI: Click on the application card -> Click on APP DETAILS
-> Click on the link under URLs
Manual Deployment:
- Dev:
http://localhost:8080/manual-dev
- Staging:
http://localhost:8080/manual-staging
- Prod:
http://localhost:8080/manual-prod
CI-Pipeline Deployment:
- Dev:
http://localhost:8080/ci-pipeline-dev
- Staging:
http://localhost:8080/ci-pipeline-staging
- Prod:
http://localhost:8080/ci-pipeline-prod
Image-Updater Deployment:
- Dev:
http://localhost:8080/image-updater-dev
- Staging:
http://localhost:8080/image-updater-staging
- Prod:
http://localhost:8080/image-updater-prod
Dependency-Bot Deployment:
- Dev:
http://localhost:8080/dependency-bot-dev
- Staging:
http://localhost:8080/dependency-bot-staging
- Prod:
http://localhost:8080/dependency-bot-prod
Preview-Environments:
http://localhost:8080/preview-<BRANCH_NAME>-<PR_NUMBER>
(e.g.: Source-Branchfeature/mytest
) on PR42
will becomehttp://localhost:8080/preview-feature-mytest-42
. Remember adding thepreview
label to the PR.
See individual usage guides for the release promotion mechanisms in the docs
folder: