Build and Deploy maven application into JBoss EAP 7.4 using Openshift PipeLine(CI) and ArgoCD(CD) in Red Hat OpenShift(RHOCP)
In this project i used Openshift pipeline as a CI tool to build the maven project and image and used ArgoCD as a CD tool to deploy this "Hello World" maven application into JBoss EAP 7.4.
Note: The helloworld
maven project is taken from the jboss-eap-quickstart project- https://github.com/jboss-developer/jboss-eap-quickstarts/tree/7.4.x
To create and run the openshift pipeline follow the below mentioned steps:
- Clone this repo
$ git clone https://github.com/anilabhabaral/hello-cicd-argocd-jboss.git
- Login to Openshift cluster
$ oc login --token=<TOKEN> --server=<SERVER_URL>
- Create new project/namespace in Openshift cluster
$ oc new-project testpipeline
- Install Red Hat OpenShift Pipelines from Operators --> Operator Hub
- Run the following command to see the pipeline service account
$ oc get serviceaccount pipeline
- Create the tasks
$ oc apply -f .infra/tasks/.
- List the tasks
$ tkn task ls
- Create pipeline
$ oc apply -f .infra/pipeline/pipeline.yaml
- List the available pipeline
$ oc get pipeline
- Run Pipeline
$ tkn pipeline start new-pipeline -w name=workspace-test,volumeClaimTemplateFile=https://raw.githubusercontent.com/anilabhabaral/hello-cicd-argocd-jboss/main/.infra/pipeline/pvc-anil.yaml --use-param-defaults
- Check pipelinerun result
$ tkn pipelinerun ls
- Check whether the image of the new pipelinerun is pushed into internal image registry
$ oc get is
To deploy the the image build by the above pipeline i used Openshift GitOps operator(GitOps). Steps:
- Login to Openshift web console
- Go to Operators --> Operator Hub
- Search GitOps operator
- Install Openshift GitOps operator
- Click on the
Red Hat OpenShift GitOps
. It will show the below page: - Click on
+ Create instance
inACD Argo CD
- It will open a Form view like below. In the Form view enter a
Name
and leave the other input box as default. - After creating the instance, it can be viewed as below:
- Run
$ oc get pod
to see all the agrocd pods are ready or not:
$ oc get pod
NAME READY STATUS RESTARTS AGE
argocd-anil-application-controller-0 1/1 Running 0 9m35s
argocd-anil-dex-server-764d564bc8-8jx4f 1/1 Running 0 12m
argocd-anil-redis-59cf94479-mrnq2 1/1 Running 0 2m41s
argocd-anil-repo-server-58f84645b5-g94xz 1/1 Running 0 12m
argocd-anil-server-6c67d9659d-l4gkv 1/1 Running 0 12m
- Check the argocd route using
$ oc get route
:
$ oc get route
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
argocd-anil-server argocd-anil-server-testpipeline.apps.xxxxx.xxxxx.xxxx.xxxxxx.xxxxx.xxxx.xxxxx.com argocd-anil-server https passthrough/Redirect None
- Copy and past the route url of argocd in a browser, it will show the login page of argocd:
- Click on
LOG IN VIA OPENSHIFT
. It will redirect to the openshift login page. Use the required username and password to login to argocd using openshift login. - ArgoCD home page:
- Click on
+ NEW APP
- It will open a Form view like below:
- Enter the details as below and click
Create
: - After creating all the deployment,service and route the argocd app will look:
- Check the deployment created by argocd:
$ oc get deploy -n <NAMESPACE_NAME>
NAME READY UP-TO-DATE AVAILABLE AGE
helloworld-deployment 1/1 1 1 47m
- Check the service created by argocd:
$ oc get svc -n <NAMESPACE_NAME>
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
jboss-helloworld-service ClusterIP xxx.xx.xx.xx <none> 8080/TCP 49m
- Check the route created by argocd:
$ oc get route -n <NAMESPACE_NAME>
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
jboss-helloworld-service-route jboss-helloworld-service-eap-test-02.apps.xxxx.xxxx.xxxx.xxxxx.xxxx.xxxx.xxxx.com jboss-helloworld-service 8080 None