Quarkus based backend service for the Find My Relative demo application.
Frontend Service can be found here.
-
Locally
Modify the
INCIDENT_SERVICE_URL
andMISSION_SERVICE_URL
inapplication.properties
file.Run
./mvnw compile quarkus:dev
-
Deploy on OpenShift
You can deploy using Dockerfile on OpenShift Webconsole or run the following command.
oc new-app --name find-service --strategy docker https://github.com/Emergency-Response-Demo/find-service
You will need to pass
INCIDENT_SERVICE_URL
andMISSION_SERVICE_URL
as Environment variable.
-
Prerequisite
-
OpenShift v4.x Cluster with cluster admin permissions.
-
Tekton Pipeline Installed. You can install using
OpenShift Pipelines Operator
from the Operator Hub. -
Knative Installed. You can follow this steps to install Serverless in OpenShift.
-
Tekton CLI (tkn) (Optional). Download the Tekton CLI by following instructions available on the CLI GitHub repository.
-
-
Installation Steps
-
Fork this repository so that you can create a trigger for any GitHub Event which will trigger the pipeline and deploy the new code.
-
Clone the repository to your local machine.
git clone https://github.com/<your-github-username>/find-service
-
Login to your OpenShift Cluster.
-
Create a new project
find-my-relative
oc new-project find-my-relative
-
Before Installing Pipeline, Create a Config Map with name
erd-urls
which will haveINCIDENT_SERVICE_URL
andMISSION_SERVICE_URL
.To create config map, you can use
erd-urls-config-map.yaml
ink8s
folder. Add the urls and apply the yaml file using below command.oc apply -f k8s/erd-urls-config-map.yaml
-
Traverse to the pipeline folder.
cd pipeline/
-
Install the Pipeline Resources,Task and Pipeline.
-
Pipeline - There are two task in pipeline - buildah and openshift-client.
Install pipeline using below command -
02-pipelines/01-findmyrelative-backend-pipeline.yaml
-
Tasks -
-
buildah - This task build a image using the Dockerfile and then push it to repository which we will specify in pipeline resource.
-
openshift-client - Here, this task is used to apply knative service which will deploy the image as serverless.
buildah and openshift-client used from the cluster task. So, they come pre-installed with the OpenShift Pipelines Operator.
-
-
Pipeline Resources - First is git resource where we give git url of repository and second is image resource where the image will be pushed.
Here we are using OpenShift Internal Registry but you can also use any external registry like DockerHub, Quay.
Before Installing Resources, Replace your git url of find-service in
01-findmyrelative-backend-git-resource.yaml
Now, you can install using below command -
oc apply -f 01-pipelineresources/
Now, we are ready to run the pipeline. You can run it by using below command or Go to OpenShift Web Console -> find-my-relative Project -> Pipeline Tab -> Pipeline -> Click on pipeline and Start.
tkn pipeline start findmyrelative-backend-pipeline -r source-git-repo=findmyrelative-backend-git-repo -r image-resource-name=findmyrelative-backend-image -s pipeline
Also, You can start pipeline using pipeline run.
oc apply -f 03-pipelineruns/01-findmyrelative-backend-pipelinerun.yaml
-
-
Next Step is to create a trigger so that on any code change in GitHub the pipeline will start and deploy the new code.
Install Event Listener, Trigger Template and Trigger binding.
oc apply -f 04-pipeline-triggers/
New pod will be created for Event listener. Get the url for Event Listener which we will need for creating Webhook -
oc get route
. -
Create a webhook -
Firstly, create a GitHub Personal access token. Follow this instructions to create a GitHub token.
The token should have the access -
public_repo
andadmin:repo_hook
.To create a webhook - Go to GitHub Repository -> Settings -> Webhooks -> Add webhook -> Add the EventListener url, the token as secret and select the event.
Also, you can create a webhook using Webhook task which you can find in
03_create-webhook-task.yaml
. Follow below steps to create using a task --
Add your GitHub Personal access token and Random String data in
secret
in02_webhook-secret.yaml
. -
In
04_backend-webhook-run.yaml
add your GitHub Username forGitHubOrg
andGitHubUser
. Add the Event Listener's url forExternalDomain
.
Now, install the task and the task run.
oc apply -f 05-github-webhooks/
If you go to Github, you can see a webhook created for the repository.
-
-
Now, when you change code and push it to repository. You can see a new pipelinerun is started.
-