-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from rh-aiservices-bu/feature/per-user-db
claim processing review - step 1
- Loading branch information
Showing
20 changed files
with
505 additions
and
22 deletions.
There are no files selected for viewing
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: db-init-job | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "1" | ||
spec: | ||
template: | ||
spec: | ||
initContainers: | ||
- name: wait-for-db | ||
image: busybox:1.28 | ||
command: ['sh', '-c', 'until nc -z -v -w30 $POSTGRESQL_DATABASE 5432; do echo "Waiting for database connection..."; sleep 2; done;'] | ||
env: | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: POSTGRESQL_DATABASE | ||
value: claimdb.$(NAMESPACE).svc.cluster.local | ||
containers: | ||
- name: postgresql | ||
image: registry.redhat.io/rhel9/postgresql-13:latest | ||
env: | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: POSTGRESQL_DATABASE | ||
valueFrom: | ||
secretKeyRef: | ||
name: claimdb | ||
key: database-name | ||
- name: POSTGRESQL_USER | ||
valueFrom: | ||
secretKeyRef: | ||
name: claimdb | ||
key: database-user | ||
- name: PGPASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: claimdb | ||
key: database-password | ||
- name: POSTGRESQL_DATABASE_HOST | ||
value: claimdb.$(NAMESPACE).svc.cluster.local | ||
command: ["/bin/bash", "-c"] | ||
args: | ||
- | | ||
echo "Running SQL script" | ||
psql -h $POSTGRESQL_DATABASE_HOST -p 5432 -U $POSTGRESQL_USER -d $POSTGRESQL_DATABASE -f /sql-script/script.sql | ||
volumeMounts: | ||
- name: sql-script-volume | ||
mountPath: /sql-script | ||
restartPolicy: Never | ||
volumes: | ||
- name: sql-script-volume | ||
configMap: | ||
name: sql-script-configmap | ||
backoffLimit: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: claimdb | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "1" | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: claimdb | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: claimdb | ||
spec: | ||
containers: | ||
- name: postgresql | ||
image: registry.redhat.io/rhel9/postgresql-13:latest | ||
resources: | ||
limits: | ||
memory: 512Mi | ||
readinessProbe: | ||
exec: | ||
command: | ||
- /usr/libexec/check-container | ||
initialDelaySeconds: 5 | ||
timeoutSeconds: 1 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
failureThreshold: 3 | ||
livenessProbe: | ||
exec: | ||
command: | ||
- /usr/libexec/check-container | ||
- '--live' | ||
initialDelaySeconds: 120 | ||
timeoutSeconds: 10 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
failureThreshold: 3 | ||
env: | ||
- name: POSTGRESQL_USER | ||
valueFrom: | ||
secretKeyRef: | ||
name: claimdb | ||
key: database-user | ||
- name: POSTGRESQL_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: claimdb | ||
key: database-password | ||
- name: POSTGRESQL_DATABASE | ||
valueFrom: | ||
secretKeyRef: | ||
name: claimdb | ||
key: database-name | ||
securityContext: | ||
capabilities: {} | ||
privileged: false | ||
ports: | ||
- containerPort: 5432 | ||
protocol: TCP | ||
imagePullPolicy: IfNotPresent | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
volumeMounts: | ||
- name: claimdb-data | ||
mountPath: /var/lib/pgsql/data | ||
volumes: | ||
- name: claimdb-data | ||
persistentVolumeClaim: | ||
claimName: claimdb | ||
strategy: | ||
type: Recreate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: populate-images | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "1" | ||
spec: | ||
backoffLimit: 4 | ||
template: | ||
spec: | ||
initContainers: | ||
- name: wait-for-minio | ||
image: busybox:1.28 | ||
command: ['sh', '-c', 'until nc -z -v -w30 $MINIO_ENDPOINT 9000; do echo "Waiting for Minio connection..."; sleep 2; done;'] | ||
env: | ||
- name: MINIO_ENDPOINT | ||
value: minio.ic-shared-minio.svc.cluster.local | ||
containers: | ||
- name: add-images-to-bucket | ||
image: image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/s2i-generic-data-science-notebook:1.2 | ||
imagePullPolicy: IfNotPresent | ||
command: ["/bin/bash"] | ||
args: | ||
- -ec | ||
- |- | ||
git clone https://github.com/rh-aiservices-bu/insurance-claim-processing.git | ||
cat << 'EOF' | python3 | ||
import boto3, os, botocore | ||
s3 = boto3.client("s3", | ||
endpoint_url=os.getenv("AWS_S3_ENDPOINT"), | ||
aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"), | ||
aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY")) | ||
# Set bucket | ||
bucket_name = os.getenv("NAMESPACE") | ||
# Upload original images to minio | ||
for filename in os.listdir("insurance-claim-processing/bootstrap/ic-shared-database/images/original_images"): | ||
with open(f"insurance-claim-processing/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("insurance-claim-processing/bootstrap/ic-shared-database/images/processed_images"): | ||
with open(f"insurance-claim-processing/bootstrap/ic-shared-database/images/processed_images/{filename}", "rb") as f: | ||
s3.upload_fileobj(f, bucket_name, f"processed_images/{filename}") | ||
EOF | ||
env: | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: AWS_S3_ENDPOINT | ||
value: http://minio.ic-shared-minio.svc.cluster.local:9000 | ||
- name: AWS_ACCESS_KEY_ID | ||
valueFrom: | ||
secretKeyRef: | ||
name: secret-minio | ||
key: aws_access_key_id | ||
- name: AWS_SECRET_ACCESS_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: secret-minio | ||
key: aws_secret_access_key | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: claimdb | ||
labels: | ||
app: claimdb | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "0" | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 100Mi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.