-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
434 additions
and
15 deletions.
There are no files selected for viewing
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,51 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: db-init-job | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "2" | ||
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: POSTGRESQL_DATABASE | ||
value: claimdb.ic-shared-db.svc.cluster.local | ||
containers: | ||
- name: postgresql | ||
image: registry.redhat.io/rhel9/postgresql-13:latest | ||
env: | ||
- 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.ic-shared-db.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
namespace: ic-shared-db | ||
name: ic-shared-db | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "1" | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: ic-shared-db | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: ic-shared-db | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
namespace: ic-shared-db | ||
|
||
commonLabels: | ||
component: ic-shared-db | ||
|
||
resources: | ||
# wave 0 | ||
- namespace.yaml | ||
# wave 1 | ||
- pvc.yaml | ||
- secret.yaml | ||
- secret-minio.yaml | ||
- deployment.yaml | ||
- service.yaml | ||
- sql-script-configmap.yaml | ||
# wave 2 | ||
- db-init-job.yaml | ||
- populate-images.yaml |
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,11 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: ic-shared-db | ||
labels: | ||
app: ic-shared-db | ||
argocd.argoproj.io/managed-by: openshift-gitops | ||
annotations: | ||
openshift.io/display-name: "Shared PostgreSQL Database" | ||
argocd.argoproj.io/sync-wave: "0" |
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: populate-images | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "2" | ||
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/parasol-insurance.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")) | ||
# Create image bucket | ||
bucket_name = "claim-images" | ||
try: | ||
s3.head_bucket(Bucket=bucket_name) | ||
except botocore.exceptions.ClientError as e: | ||
if e.response['Error']['Code'] == '404': | ||
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: | ||
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: | ||
s3.upload_fileobj(f, bucket_name, f"processed_images/{filename}") | ||
EOF | ||
envFrom: | ||
- secretRef: | ||
name: secret-minio | ||
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,16 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: claimdb | ||
namespace: ic-shared-db | ||
labels: | ||
app: ic-shared-db | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "1" | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 10Gi |
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,14 @@ | ||
kind: Secret | ||
apiVersion: v1 | ||
metadata: | ||
name: claimdb | ||
namespace: ic-shared-db | ||
labels: | ||
app: ic-shared-db | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "1" | ||
stringData: | ||
database-name: claimdb | ||
database-password: claimdb | ||
database-user: claimdb | ||
type: Opaque |
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,20 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: claimdb | ||
namespace: ic-shared-db | ||
labels: | ||
app: ic-shared-db | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "1" | ||
spec: | ||
ports: | ||
- name: postgresql | ||
protocol: TCP | ||
port: 5432 | ||
targetPort: 5432 | ||
selector: | ||
app: ic-shared-db | ||
sessionAffinity: None | ||
type: ClusterIP |
Binary file modified
BIN
-21.3 KB
(60%)
content/modules/ROOT/assets/images/04/04-02-react-diagram.png
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
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.