Skip to content

Commit

Permalink
app deployment using shared ArgoCD
Browse files Browse the repository at this point in the history
  • Loading branch information
guimou committed Oct 24, 2024
1 parent 9615f43 commit c98cef6
Show file tree
Hide file tree
Showing 27 changed files with 70 additions and 140 deletions.
11 changes: 6 additions & 5 deletions app/backend/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ def __init__(self, config, logger):
def format_sources(self, input_list):
sources = ""
if len(input_list) != 0:
sources += input_list[0].metadata["source"] + ', page: ' + str(input_list[0].metadata["page"])
page_list = [input_list[0].metadata["page"]]
sources += input_list[0].metadata["metadata"]["source"] + ', page: ' + str(input_list[0].metadata["metadata"]["page"])
page_list = [input_list[0].metadata["metadata"]["page"]]
for item in input_list:
if item.metadata["page"] not in page_list: # Avoid duplicates
page_list.append(item.metadata["page"])
sources += ', ' + str(item.metadata["page"])
if item.metadata["metadata"]["page"] not in page_list: # Avoid duplicates
page_list.append(item.metadata["metadata"]["page"])
sources += ', ' + str(item.metadata["metadata"]["page"])
return sources


def stream(self, query, claim) -> Generator:
# A Queue is needed for Streaming implementation
q = Queue()
Expand Down
9 changes: 0 additions & 9 deletions bootstrap/ic-rhoai-configuration/job-patch-code-server.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion bootstrap/ic-shared-app/deployment-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
spec:
containers:
- name: insurance-claim-app
image: quay.io/rh-aiservices-bu/rhoai-lab-insurance-claim-app:2.2.0
image: quay.io/rh-aiservices-bu/rhoai-lab-insurance-claim-app:2.2.1
ports:
- containerPort: 5000
protocol: TCP
Expand Down
11 changes: 6 additions & 5 deletions bootstrap/ic-shared-database/populate-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ spec:
args:
- -ec
- |-
git clone https://github.com/rh-aiservices-bu/parasol-insurance.git
BRANCH_NAME="dev"
git clone https://github.com/rh-aiservices-bu/parasol-insurance.git && cd parasol-insurance && git checkout $BRANCH_NAME
cat << 'EOF' | python3
import boto3, os, botocore
Expand All @@ -43,13 +44,13 @@ spec:
s3.create_bucket(Bucket=bucket_name)
# Upload original images to minio
for filename in os.listdir("parasol-insurance/bootstrap/ic-shared-database/images/original_images"):
with open(f"parasol-insurance/bootstrap/ic-shared-database/images/original_images/{filename}", "rb") as f:
for filename in os.listdir("/opt/app-root/src/parasol-insurance/bootstrap/ic-shared-database/images/original_images"):
with open(f"/opt/app-root/src/parasol-insurance/bootstrap/ic-shared-database/images/original_images/{filename}", "rb") as f:
s3.upload_fileobj(f, bucket_name, f"original_images/{filename}")
# Upload processed images to minio
for filename in os.listdir("parasol-insurance/bootstrap/ic-shared-database/images/processed_images"):
with open(f"parasol-insurance/bootstrap/ic-shared-database/images/processed_images/{filename}", "rb") as f:
for filename in os.listdir("/opt/app-root/src/parasol-insurance/bootstrap/ic-shared-database/images/processed_images"):
with open(f"/opt/app-root/src/parasol-insurance/bootstrap/ic-shared-database/images/processed_images/{filename}", "rb") as f:
s3.upload_fileobj(f, bucket_name, f"processed_images/{filename}")
EOF
Expand Down
24 changes: 24 additions & 0 deletions bootstrap/ic-user-projects/create-projects-and-resources-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,30 @@ spec:
volumeMode: Filesystem
EOF
# Create the ArgoCD Project
cat << EOF | oc apply -f-
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: project-$USER_PROJECT
namespace: openshift-gitops
spec:
description: Application project for $USER_PROJECT
destinations:
- name: in-cluster
namespace: $USER_PROJECT
server: 'https://kubernetes.default.svc'
roles:
- description: Sync privileges for any application
groups:
- $USER_PROJECT
name: ci-role
policies:
- 'p, proj:project-$USER_PROJECT:ci-role, applications, *, project-$USER_PROJECT/*, allow'
sourceRepos:
- 'https://github.com/rh-aiservices-bu/parasol-insurance.git'
EOF
sleep 20
done
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed content/modules/ROOT/assets/images/05/web-term-1.png
Binary file not shown.
Binary file removed content/modules/ROOT/assets/images/05/web-term-2.png
Binary file not shown.
1 change: 0 additions & 1 deletion content/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* 5. Web App Deployment
** xref:05-01-application.adoc[5.1 Application overview]
** xref:05-02-openshift-terminal.adoc[5.2 OpenShift Terminal]
** xref:05-03-web-app-deploy-application.adoc[5.3 Deploying the application via GitOps]
** xref:05-04-web-app-validating.adoc[5.4 Validating the application]
** xref:05-05-process-claims.adoc[5.5 Process claims with a pipeline]
Expand Down
29 changes: 0 additions & 29 deletions content/modules/ROOT/pages/05-02-openshift-terminal.adoc

This file was deleted.

115 changes: 29 additions & 86 deletions content/modules/ROOT/pages/05-03-web-app-deploy-application.adoc
Original file line number Diff line number Diff line change
@@ -1,90 +1,36 @@
= Deploying the application via GitOps
include::_attributes.adoc[]

== Deploy your instance of {argocd}
== Deploy the application(s) via GitOps

We will start by deploying an instance of ArgoCD in your namespace. +
This will be used to deploy the application.
We are going to use OpenShift GitOps/{argocd} to deploy the application in your namespace.

- Copy the following text, and paste it in the {ocp-short} Terminal to deploy {argocd}.
- Access the {argocd} Console by clicking on the link in the top right menu.
+
[.lines_space]
[.console-input]
[source, text]
cat <<EOF | oc apply -f -
---
apiVersion: argoproj.io/v1alpha1
kind: ArgoCD
metadata:
name: argocd
spec:
sso:
dex:
openShiftOAuth: true
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 250m
memory: 128Mi
provider: dex
rbac:
defaultPolicy: "role:readonly"
policy: "g, system:authenticated, role:admin"
scopes: "[groups]"
server:
insecure: true
route:
enabled: true
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
EOF

- Still in the Terminal, run the following command to check the status of the {argocd} deployment.
+
[.lines_space]
[.console-input]
[source, text]
oc rollout status deploy/argocd-server
[.bordershadow]
image::05/05-open-argocd.png[]

- After a few seconds, the deployment should be complete:
- Click on "Log in via OpenShift" to log in with your credentials.
+
[.bordershadow]
image::05/argocd-rollout.png[]
image::05/05-login-argocd-openshift.png[]

**Optional**: If you know and understand {argocd} and want to look at its interface, look at the following details. Otherwise, you can skip to the next step.
[%collapsible]
====
Now that Argo is deployed, you can connect to its UI through its Route.
[.bordershadow]
image::05/05-openshift-login.png[]

- Let's find the Route of the {argocd} instance by running the following command in the Terminal:
- Once logged in, you will be redirected to the {argocd} Console. In the "Applications" tab, click on "Create Application".
+
[.lines_space]
[.console-input]
[source, text]
echo " {argocd} UI : https://$(oc get route argocd-server -ojsonpath='{.status.ingress[0].host}')/ "
[.bordershadow]
image::05/05-create-application.png[]

- You should obtain something like this:
- On the top right corner of the panel that opened, click on "Edit as YAML".
+
[.bordershadow]
image::05/argocd-route.png[]
image::05/05-edit-as-yaml.png[]

- You can now connect to the ArgoCD UI using your given credentials ({user}/{password}).
====

== Deploy the application(s) via GitOps

Now that {argocd} is deployed in your namespace, we can use it to deploy the application via GitOps.

- Copy the content of the following text, and paste it in the {ocp-short} Terminal to deploy the application.
- Copy the content of the following text, paste it in the editor, then click on "Save".
+
[.lines_space]
[.console-input]
[source, text, subs="attributes+"]
cat <<EOF | oc apply -f -
---
[source, yaml, subs="attributes+"]
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
Expand All @@ -93,7 +39,7 @@ spec:
destination:
server: https://kubernetes.default.svc
namespace: {user}
project: default
project: project-{user}
source:
path: lab-materials/05/app
repoURL: https://github.com/rh-aiservices-bu/parasol-insurance.git
Expand All @@ -103,29 +49,26 @@ spec:
prune: true
selfHeal: false
syncOptions: [CreateNamespace=false]
EOF

- Go to the Admin view in the {ocp-short} Console

[.bordershadow]
image::05/05-switch-to-admin-view.jpg[]

- Wait for the application to be fully deployed and initialized. It will be the case when the two Jobs `db-init-job` and `populate-images` are completed (Completions: 1 of 1).
image::05/05-application-yaml-save.png[]

- Back on the form view, click on "Create".
+
[.bordershadow]
image::05/jobs-completed.png[]
image::05/05-create-application-validation.png[]

- Once the application is deployed, you can check its Route with the following command:
- The Application will start deploying. You can click on the Card to see the details.
+
[.lines_space]
[.console-input]
[.lines_space]
[.console-input]
[source, text]
echo " Application URL : https://$(oc get route ic-app -ojsonpath='{.status.ingress[0].host}')/ "
[.bordershadow]
image::05/05-application-creation.png[]

- After a few seconds, all the elements will be deployed, and the Application will report as "Healthy" and "Synced".
+
[.bordershadow]
image::05/05-open-url.jpg[]
image::05/05-application-deployed.png[]

- You can now access the application at the following URL:
https://ic-app-{user}.{openshift_cluster_ingress_domain}/[https://ic-app-{user}.{openshift_cluster_ingress_domain}/,window=_blank]

Open the the URL in your browser to access the application and head to the next step.
2 changes: 1 addition & 1 deletion content/modules/ROOT/pages/05-04-web-app-validating.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include::_attributes.adoc[]

What you see when you first connect to the application is the new version.

But to see where we are coming from, let's start by navigating to the original version and see what it looked like. Click on the **Original App** menu on the left.
But to see where we are coming from, let's start by navigating to the original version and see what it looked like. Click on the **Original App** menu on the bottom left.

[.bordershadow]
image::05/original-app-link.png[]
Expand Down
6 changes: 3 additions & 3 deletions lab-materials/05/app/deployment-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
spec:
containers:
- name: insurance-claim-app
image: quay.io/rh-aiservices-bu/rhoai-lab-insurance-claim-app:2.1.2
image: quay.io/rh-aiservices-bu/rhoai-lab-insurance-claim-app:2.2.1
ports:
- containerPort: 5000
protocol: TCP
Expand All @@ -29,9 +29,9 @@ spec:
fieldRef:
fieldPath: metadata.namespace
- name: INFERENCE_SERVER_URL
value: http://llm.ic-shared-llm.svc.cluster.local:8000/v1
value: http://granite-7b-instruct-predictor.ic-shared-llm.svc.cluster.local:8080/v1
- name: MODEL_NAME
value: 'mistralai/Mistral-7B-Instruct-v0.2'
value: 'granite-7b-instruct'
- name: MAX_TOKENS
value: '512'
- name: TOP_P
Expand Down

0 comments on commit c98cef6

Please sign in to comment.