-
Access to an OpenShift Cluster
-
Have the OpenShift Pipeline Operator install
. For instructions on how to install OpenShift Pipiline you can refer to my OpenShift Pipeline Demo in this section -
Have the OpenShift GitOps Operator install
. For instructions on how to install OpenShift Gitops you can refer to my OpenShift GitOps Demo in this section -
Have a clone/fork of this repository
.
In this demo we will be demontrating how to use OpenShift
Gitops to manage our application and to deploy an application. To do this we need to deploy an other ArgoCD instance
that will be use for developers to manage the applications
NOTE
-
The default
cluster
instance of Argo CD is meant for cluster admin tasks like creating namespace managing role bindings not for day to day application management. -
The Developer Argo CD instance
will be deploy in it own namespaces and is intented for the developper to use to manage the application.
-
Login to you cluster using the CLI
-
Use
kustomize
to create the different resources needed to run the demooc apply -k gitops-demo/setup/overlays/demo
This will create all the elements required
* simple-quarkus-gitops - The namespace where the argoCD instance for Developer will be install. * simple-quarkus-pipeline - The namespaces where the pipeline resources will be install. * simple-quarkus-dev - TheDEV
environment for the demo. * simple-quarkus-prod - ThePROD
environment for the demo.
The automation flow uses a mix of Tekton and ArgoCD.
Tekton Build the application and creates the PR. ArgoCD monitor the changes in Git. The Pipeline is trigger woth a WebHook from GitHub.
flowchart LR;
A(Clone source code) --> B(Run Unit Test);
A --> C(Create Image tag);
B --> D(Buil Application);
C --> D;
D --> E(Clone Deployment \n Repository DEV);
E --> F(Patch DEV Deployment \n with new image tag);
F --> G(Commit change to \n DEV Repository);
G --> H(Patch PROD Deployment \n with new image tag);
H --> I(Create Branch in Git);
I --> J(Commit PR \n for PROD changes);
We need to set up 2 different elements in GitHub 1. A personel Token on you profile 2. A Webhook on the code repository
From your GitHub account.
-
Select
Developer settings
-
Select
Personal access tokens
-
Click
Generate new token
and enter the information.Note
: A name for tokenExpiration
:When the token should expire according to you security policy.Select scopes
: Repo need to be selected at a minumun- Click
Generate token
⚠️ Copy the generated token in a secure place, since once the window is close, you won't be able to retrieve it. -
Generate the require secret for OpenShift to commit.
- You need to edit the file
../gitops-demo/manifest/github-secret.yaml
- Replace following token with the appropriate value
[CLEAR_TEXT_USERNAME]
[CLEAR_TEXT_TOKEN]
- Apply the file to OpenShift
oc apply -f gitops-demo/manifest/github-secret.yaml
⚠️ currently tekton only support basic_auth or ssh, this is why we need to generate one encrypted for the pull request that requires the encrypted token. - You need to edit the file
-
Generate the require encrypted secret for OpenShift to create a Pull Request.
- You need to edit the file
../gitops-demo/manifest/github.yaml
- You need to replace in base64 the folowwing information
- token: [64_encoded_token]
- username: [64_encoded_username]
- email: [64_encoded_email]
- Apply the file to OpenShift
oc apply -f gitops-demo/manifest/github.yaml
- You need to edit the file
-
Retrive the trigger url.
echo "$(oc get route el-github-webhook -n simple-quarkus-pipeline --template='http://{{.spec.host}}')"
-
Open GitHub in the the code repository, go to setting -> Webhook -> Add Webhook
You can now push a change to the repository, it should trigger the pipeline.
- Modify the source code will trigger the pipeline
- Modify the manifest it will trigger the ArgoCD sync
🎉 CONGRATULATIONS
You have now deploy the service using OpenShift GitOps.
👉 Return: Reposotory content