From d86dcbd5353b2f61e48483b27172508157aef967 Mon Sep 17 00:00:00 2001 From: OMPRAKASH MISHRA Date: Thu, 8 Feb 2024 15:24:32 -0800 Subject: [PATCH 1/2] code changes to make JDBC_URL ENv var --- .dockerignore | 4 +++ charts/nr-oracle-service/README.md | 36 ++++++++++--------- .../templates/deployment.yaml | 6 ++++ charts/nr-oracle-service/values.schema.json | 3 ++ charts/nr-oracle-service/values.yaml | 4 ++- src/main/resources/application.properties | 3 +- 6 files changed, 37 insertions(+), 19 deletions(-) diff --git a/.dockerignore b/.dockerignore index b72f18e..0f81f3d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,3 +6,7 @@ target/quarkus-app/* .idea/* .github/* charts/* +.mvn +.quarkus +.vscode/* +oracle-data diff --git a/charts/nr-oracle-service/README.md b/charts/nr-oracle-service/README.md index ccc3d5b..95f6dd0 100644 --- a/charts/nr-oracle-service/README.md +++ b/charts/nr-oracle-service/README.md @@ -4,25 +4,29 @@ The following table lists the configurable parameters and their default values. -| Parameter | Description | Default | -|-----------------------------------------|-------------|---------| -| `app.envs.DB_HOST` | | | -| `app.envs.DB_NAME` | | | -| `app.envs.DB_PASSWORD` | | | -| `app.envs.DB_PORT` | | | -| `app.envs.DB_SECRET` | | | -| `app.envs.DB_USER` | | | -| `app.envs.HTTP_PORT` | | 3000 | -| `app.envs.POOL_IDLE_TIMEOUT` | | 60000 | -| `app.envs.POOL_INITIAL_SIZE` | | 1 | -| `app.envs.POOL_LEAK_DETECTION_INTERVAL` | | 300000 | -| `app.envs.POOL_MAX_LIFETIME` | | 180000 | -| `app.envs.POOL_MAX_SIZE` | | 1 | -| `app.envs.POOL_MIN_SIZE` | | 1 | +| Parameter | Description | Default | +|-----------------------------------------|-------------------------------------------------|---------| +| `app.envs.DB_HOST` | | | +| `app.envs.DB_NAME` | | | +| `app.envs.DB_PASSWORD` | | | +| `app.envs.DB_PORT` | | | +| `app.envs.DB_SECRET` | | | +| `app.envs.DB_USER` | | | +| `app.envs.HTTP_PORT` | | 3000 | +| `app.envs.POOL_IDLE_TIMEOUT` | | 60000 | +| `app.envs.POOL_INITIAL_SIZE` | | 1 | +| `app.envs.POOL_LEAK_DETECTION_INTERVAL` | | 300000 | +| `app.envs.POOL_MAX_LIFETIME` | | 180000 | +| `app.envs.POOL_MAX_SIZE` | | 1 | +| `app.envs.POOL_MIN_SIZE` | | 1 | +| `app.envs.JDBC_URL` | Required if values.global.tcpsEnabled is false. | | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. -Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the +chart. For example, + ``` $ helm install --name chart-name -f values.yaml . ``` + > **Tip**: You can use the default [values.yaml](values.yaml) diff --git a/charts/nr-oracle-service/templates/deployment.yaml b/charts/nr-oracle-service/templates/deployment.yaml index a2bcc6d..dc57f00 100644 --- a/charts/nr-oracle-service/templates/deployment.yaml +++ b/charts/nr-oracle-service/templates/deployment.yaml @@ -27,6 +27,7 @@ spec: claimName: {{ include "component.name" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.global.tcpsEnabled }} initContainers: - name: {{ .Chart.Name }}-init image: "image-registry.openshift-image-registry.svc:5000/{{.Release.Namespace}}/{{ include "component.name" . }}-init:{{ .Values.image.tag | default .Chart.AppVersion }}" @@ -49,6 +50,7 @@ spec: volumeMounts: - name: {{ include "component.name" . }} mountPath: /app/cert + {{- end }} containers: - name: {{ .Chart.Name }} securityContext: @@ -99,6 +101,10 @@ spec: secretKeyRef: key: apiKey name: {{ include "component.name" . }} + {{- if not .Values.global.tcpsEnabled }} + - name: JDBC_URL + value: {{ required "A valid .Values.app.envs.JDBC_URL entry required!" .Values.app.envs.JDBC_URL | quote }} + {{- end }} - name: DB_PORT value: '1543' - name: CERT_SECRET diff --git a/charts/nr-oracle-service/values.schema.json b/charts/nr-oracle-service/values.schema.json index 6326b3e..8377516 100644 --- a/charts/nr-oracle-service/values.schema.json +++ b/charts/nr-oracle-service/values.schema.json @@ -191,6 +191,9 @@ "POOL_MIN_SIZE": { "type": "string", "default": "1" + }, + "JDBC_URL": { + "type": "string" } }, diff --git a/charts/nr-oracle-service/values.yaml b/charts/nr-oracle-service/values.yaml index 5faea27..1b89a11 100644 --- a/charts/nr-oracle-service/values.yaml +++ b/charts/nr-oracle-service/values.yaml @@ -4,7 +4,8 @@ # Declare variables to be passed into your templates. replicaCount: 1 - +global: + tcpsEnabled: true image: repository: ghcr.io/bcgov/nr-oracle-service/nr-oracle-service repositoryInit: ghcr.io/bcgov/nr-oracle-service/nr-oracle-service-init @@ -85,5 +86,6 @@ app: POOL_MAX_SIZE: "1" POOL_MIN_SIZE: "1" ACCESS_LOG_ENABLED: "false" + JDBC_URL: ~ ports: http: 3000 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 7e894c2..eff5ce0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,7 @@ quarkus.datasource.db-kind=oracle quarkus.datasource.username=${DB_USER} quarkus.datasource.password=${DB_PASSWORD} -quarkus.datasource.jdbc.url=jdbc:oracle:thin:@tcps://${DB_HOST}:${DB_PORT}/${DB_NAME}?javax.net.ssl.trustStore=/app/cert/jssecacerts&javax.net.ssl.trustStorePassword=${CERT_SECRET}&javax.net.ssl.keyStore=/app/cert/jssecacerts&javax.net.ssl.keyStorePassword=${CERT_SECRET}&oracle.net.ssl_certificate_alias=${DB_HOST}&oracle.net.ssl_server_dn_match=false +quarkus.datasource.jdbc.url=${JDBC_URL: jdbc:oracle:thin:@tcps://${DB_HOST}:${DB_PORT}/${DB_NAME}?javax.net.ssl.trustStore=/app/cert/jssecacerts&javax.net.ssl.trustStorePassword=${CERT_SECRET}&javax.net.ssl.keyStore=/app/cert/jssecacerts&javax.net.ssl.keyStorePassword=${CERT_SECRET}&oracle.net.ssl_certificate_alias=${DB_HOST}&oracle.net.ssl_server_dn_match=false} quarkus.datasource.jdbc.min-size=${POOL_MIN_SIZE:1} quarkus.datasource.jdbc.max-size=${POOL_MAX_SIZE:1} quarkus.datasource.jdbc.initial-size=${POOL_INITIAL_SIZE:1} @@ -9,7 +9,6 @@ quarkus.datasource.jdbc.max-lifetime=${POOL_MAX_LIFETIME:180000} quarkus.datasource.jdbc.idle-removal-interval=${POOL_IDLE_TIMEOUT:60000} quarkus.datasource.jdbc.leak-detection-interval=${POOL_LEAK_DETECTION_INTERVAL:45000} quarkus.http.port=${HTTP_PORT:3000} -%dev.quarkus.datasource.jdbc.url=jdbc:oracle:thin:@${DB_HOST}:1521/${DB_NAME} api.key=${API_KEY} quarkus.http.access-log.enabled=${ACCESS_LOG_ENABLED:false} quarkus.native.additional-build-args=-march=compatibility From 0e6e6ad11bf3bc96805a3ecf7a65d2f2525f775d Mon Sep 17 00:00:00 2001 From: OMPRAKASH MISHRA Date: Thu, 8 Feb 2024 15:27:27 -0800 Subject: [PATCH 2/2] fix dockerignore --- .dockerignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 0f81f3d..1404950 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,7 +6,6 @@ target/quarkus-app/* .idea/* .github/* charts/* -.mvn .quarkus .vscode/* oracle-data