petbattle / ubiquitous-journey

Apache License 2.0
2 stars 6 forks source link

☘️ pet battle ubquitous journey ☘️

Tekton pipelines for the Pet Battle suite of applications.

If you want to learn how to create this project read DEVELOPMENT.md

We use a Pull Model of deployment - Tekton for the CI pipeline, and ArgoCD to deploy changes using GitOps.

pull-model.png

🤠 For the impatient 🤠

Just run this code as a cluster admin user once logged in via command line to your cluster:

# clone this repo and
# bootstrap to install argocd and create projects
helm dependency up bootstrap/
helm upgrade --install bootstrap -f bootstrap/values-bootstrap.yaml bootstrap --create-namespace --namespace labs-bootstrap
# Create GitHub and ArgoCD secrets
# Login to ArgoCD WebUI and then run this until it succeeds (may need to run twice, fill in with your own tokens)
./tekton/secrets/create-petbattle-secrets.sh -t <GITHUB_TOKEN> -s <WEBHOOK_SECRET> -a <ARGOCD_USERNAME>
# give me ALL THE TOOLS, EXTRAS & OPSY THINGS !
helm template -f argo-app-of-apps.yaml ubiquitous-journey/ | oc -n labs-ci-cd apply -f-
# start a pipeline run
oc -n labs-ci-cd process pet-battle-api | oc -n labs-ci-cd create -f-
oc -n labs-ci-cd process pet-battle | oc -n labs-ci-cd create -f-
oc -n labs-ci-cd process pet-battle-tournament | oc -n labs-ci-cd create -f-

If you have already built and tagged images, you can redeploy the argocd application suite (helm template) using:

oc -n labs-ci-cd process pet-battle-api-deploy -p HELM_CHART_VERSION=1.0.15 | oc -n labs-ci-cd create -f-
oc -n labs-ci-cd process pet-battle-deploy -p HELM_CHART_VERSION=1.0.6 | oc -n labs-ci-cd create -f-
oc -n labs-ci-cd process pet-battle-tournament-deploy -p HELM_CHART_VERSION=1.0.39 | oc -n labs-ci-cd create -f-

If you are on a branch called develop, you can test a deployment (the same as a helm update --install) using:

# HELM_CHART_VERSION is Optional (it will pull latest chart from nexus helm chart repo if not specified)
oc -n labs-ci-cd process pet-battle-api-deploy -p GIT_SHORT_REVISION=develop -p GIT_BRANCH=develop -p HELM_CHART_VERSION=1.0.15 | oc -n labs-ci-cd create -f-
# OR
oc -n labs-ci-cd process pet-battle-api-deploy -p GIT_SHORT_REVISION=develop -p GIT_BRANCH=develop | oc -n labs-ci-cd create -f-

Or you can do a full build and deployment pipeline of a branch called develop using

oc -n labs-ci-cd process pet-battle-api -p GIT_REVISION=develop -p GIT_SHORT_REVISION=develop -p GIT_BRANCH=develop | oc -n labs-ci-cd create -f-

To create webhooks that trigger a full pipeline build and deployment in your github repos run these (TaskRuns) once manually:

oc -n labs-ci-cd process create-webhook -p GITHUB_ORG=petbattle -p GITHUB_REPO=pet-battle-api -p WEBHOOK_URL=http://$(oc -n labs-ci-cd get route webhook -o custom-columns=ROUTE:.spec.host --no-headers) | oc -n labs-ci-cd create -f-
oc -n labs-ci-cd process create-webhook -p GITHUB_ORG=petbattle -p GITHUB_REPO=pet-battle -p WEBHOOK_URL=http://$(oc -n labs-ci-cd get route webhook -o custom-columns=ROUTE:.spec.host --no-headers) | oc -n labs-ci-cd create -f-
oc -n labs-ci-cd process create-webhook -p GITHUB_ORG=petbattle -p GITHUB_REPO=tournamentservice -p WEBHOOK_URL=http://$(oc -n labs-ci-cd get route webhook -o custom-columns=ROUTE:.spec.host --no-headers) | oc -n labs-ci-cd create -f-
oc -n labs-ci-cd process create-webhook -p GITHUB_ORG=petbattle -p GITHUB_REPO=ubiquitous-journey -p WEBHOOK_URL=https://$(oc get route argocd-server --template='{{ .spec.host }}' -n labs-ci-cd)/api/webhook | oc -n labs-ci-cd create -f-

To Be Done