This repository contains the GitOps configuration for CHSRC. It is based on ArgoCD and connected to a development Kubernetes cluster. As future development it is planned to implement Kustomize overlays for managing development and production environments in two separate Kubernetes clusters.
The repository will contain the manifests necessary to deploy the CHSRC infrastructure, currently applications are still being added.
[TOC]
This repository reflects the CHSRC GitOps setup. If you want to replicate a similar setup, feel free to use the manifests herein as a base. It is constantly evolving, so please contact the Chocolate team to get the most recent Kubernetes prerequisites, context, and explanations for how to get the most out of this repo.
To contribute to this repository, please clone the repository and create a branch with a name that reflects what you are adding, for example by referring to a JIRA ticket (choc-123-add-ci-pipeline
). Then follow the below steps.
To see an example of a simple application deployed with ArgoCD and fetching secrets using the External Secrets Operator and Vault, please see the http-echo directory.
- Add an
Application
ArgoCD resource for the application you want to add. You can use the http-echo app as an example. TheApplication
manifests are in the applications directory. - Ensure that you name your
Application
resource file using the application name for clarity (e.g.vault.yaml
). - Edit the
Application
resource as needed, for example, set the Helm chart repo and version to the one you wish to use. If you are working on a branch, you should point to the branch. - Merge the
Application
manifest tomain
.- TODO: Discuss if there is a better way to do this, to avoid having to edit
main
before starting to develop.
- TODO: Discuss if there is a better way to do this, to avoid having to edit
- You can continue working in your branch and adding manifests as needed (
values.yaml
for the chart, secrets, certificate...) and see them getting deployed from your branch into the development cluster. - When you are finished, and the application works as expected, create a merge request to add your work to
main
. - When the application directory and manifests are merged to
main
, update the originalApplication
resource to point tomain
and delete the branch you were using if you don't need it anymore.
- These instructions are for adding manifest in case they are not part of a Helm chart (e.g. a
Deployment.yaml
, service account, a certificate...) - If you are adding a manifest to an existing directory, simply add the manifest (
*.yaml
file) in the application directory (e.g.vault/deployment.yaml
). - To add single manifests, if the application doesn't exist yet, you will always need to add an
Application
ArgoCD resource and a directory where the manifests will be stored. Name theApplication
yaml file and directory using your application name (e.g.vault.yaml
andvault
). - When adding manifests (without a Helm chart) you need an application as follows. Please edit
metadata.name
,spec.sources.targetRevision
,spec.sources.path
andspec.destination.namespace
as needed:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: application-name-here
namespace: argocd
spec:
project: default
sources:
- repoURL: https://gitlab.com/ska-telescope/src/ska-chsrc-gitops.git
targetRevision: main
ref: argorepo
path: applications/application-name-here
directory:
exclude: 'values.yaml'
destination:
server: https://kubernetes.default.svc
namespace: namespace-the-resources-go-into
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
- When you are finished editing, create a merge requests to the
main
branch. If you want to keep developing on a branch, point to it usingtargetRevision
in theApplication
manifest. Note that nothing will be deployed from a development branch if you don't have anApplication
in themain
branch that points to your development branch. - When you have merged to
main
, you can either keep developing on your branch if you were using one, or clean up themain
branch if you are finished. To clean up, remember to edit thetargetRevision
in theApplication
inmain
if you were using a branch and to delete your development branch if you don't need it anymore.
When you are ready to submit your work, create a merge request for main and assign someone from the Chocolate team to review your contribution.
At the moment we are using a simple CI pipeline based on kubeconform to lint the manifests we deploy. The pipeline may be further enhanced in the future with additional tools to ensure a good quality and correctness.
- Note that nothing will be deployed from a development branch if you don't have an
Application
in themain
branch that points to your development branch. See Contributing for details.
The code is managed by the Chocolate team 🍫 within SRCNet.