From fc85f093be06fe2ec23a53d34d97bc6f496df5ca Mon Sep 17 00:00:00 2001 From: acies312 Date: Wed, 6 Mar 2024 16:20:42 +0300 Subject: [PATCH] fixes for kubernetes deployment --- .../application-kubernetes.properties | 1 + cosv-backend/build.gradle.kts | 2 + .../application-kubernetes.properties | 18 +++++---- .../src/main/resources/application.properties | 1 + .../save-cloud/templates/backend-cosv.yaml | 8 +++- .../save-cloud/templates/backend.yaml | 26 +++++++------ .../src/main/resources/img/codehub.svg | 37 ------------------- .../views/index/IndexLogoButtons.kt | 2 +- 8 files changed, 37 insertions(+), 58 deletions(-) delete mode 100644 save-cosv-frontend/src/main/resources/img/codehub.svg diff --git a/api-gateway/src/main/resources/application-kubernetes.properties b/api-gateway/src/main/resources/application-kubernetes.properties index aa0aac44db..29736dd0ac 100644 --- a/api-gateway/src/main/resources/application-kubernetes.properties +++ b/api-gateway/src/main/resources/application-kubernetes.properties @@ -1,6 +1,7 @@ gateway.backend.url=http://backend gateway.frontend.url=http://frontend gateway.demo-cpg.url=http://demo-cpg +gateway.backend-cosv.url=http://backend-cosv gateway.frontend-cosv.url=http://frontend-cosv gateway.demo.url=http://demo server.shutdown=graceful diff --git a/cosv-backend/build.gradle.kts b/cosv-backend/build.gradle.kts index c1ef2e8ea0..80aca29362 100644 --- a/cosv-backend/build.gradle.kts +++ b/cosv-backend/build.gradle.kts @@ -14,4 +14,6 @@ dependencies { implementation(libs.spring.security.core) implementation(libs.spring.data.jpa) implementation(libs.hibernate.jpa21.api) +// needed for kubernetes configs and secrets to be added as additional configurations + implementation(libs.spring.cloud.starter.kubernetes.client.config) } diff --git a/cosv-backend/src/main/resources/application-kubernetes.properties b/cosv-backend/src/main/resources/application-kubernetes.properties index cc12d5135c..88ac0c0d74 100644 --- a/cosv-backend/src/main/resources/application-kubernetes.properties +++ b/cosv-backend/src/main/resources/application-kubernetes.properties @@ -1,13 +1,17 @@ -backend.preprocessor-url=http://preprocessor -backend.orchestrator-url=http://orchestrator -backend.demo-url=http://demo -backend.loki.url=http://loki:3100 -backend.loki.labels.agent-container-name=pod -backend.loki.labels.application-name=app -backend.agent-settings.backend-cosv-url=http://backend-cosv +cosv.preprocessor-url=http://preprocessor +cosv.orchestrator-url=http://orchestrator +cosv.demo-url=http://demo +cosv.loki.url=http://loki:3100 +cosv.loki.labels.agent-container-name=pod +cosv.loki.labels.application-name=app +cosv.agent-settings.backend-cosv-url=http://backend-cosv +cosv.gatewayUrl=http://gateway server.shutdown=graceful management.endpoints.web.exposure.include=* management.server.port=5701 spring.datasource.url=${spring.datasource.backend-cosv-url} +spring.second-datasource.jdbc-url = ${spring.datasource.backend-url} +spring.second-datasource.username = ${spring.datasource.username} +spring.second-datasource.password = ${spring.datasource.password} logging.level.org.springframework=DEBUG logging.level.com.saveourtool=DEBUG \ No newline at end of file diff --git a/cosv-backend/src/main/resources/application.properties b/cosv-backend/src/main/resources/application.properties index 923ae3aed8..7b208c6e24 100644 --- a/cosv-backend/src/main/resources/application.properties +++ b/cosv-backend/src/main/resources/application.properties @@ -16,3 +16,4 @@ cosv.s3-storage.bucketName=${s3-storage.bucketName} cosv.s3-storage.prefix=cnb/files cosv.s3-storage.credentials.accessKeyId=${s3-storage.credentials.accessKeyId} cosv.s3-storage.credentials.secretAccessKey=${s3-storage.credentials.secretAccessKey} +cosv.working-dir=/home/cnb/cosv-working-dir diff --git a/save-cloud-charts/save-cloud/templates/backend-cosv.yaml b/save-cloud-charts/save-cloud/templates/backend-cosv.yaml index 0f1154e422..fd30a76d51 100644 --- a/save-cloud-charts/save-cloud/templates/backend-cosv.yaml +++ b/save-cloud-charts/save-cloud/templates/backend-cosv.yaml @@ -77,7 +77,7 @@ spec: runAsGroup: 1001 args: - --url=$(DB_URL)?createDatabaseIfNotExist=true - - --changeLogFile=db/db.changelog-master.xml + - --changeLogFile=cosv-backend/db/db.changelog-cosv.xml - --username=$(DB_USERNAME) - --password=$(DB_PASSWORD) - --log-level=info @@ -96,7 +96,7 @@ spec: valueFrom: secretKeyRef: name: db-secrets - key: spring.datasource.backend-url + key: spring.datasource.backend-cosv-url - name: DB_USERNAME valueFrom: secretKeyRef: @@ -117,10 +117,12 @@ spec: name: migrations-data - mountPath: {{ .Values.mysql.dbPasswordFile }} name: database-secret + {{ if .Values.gateway.initCerts.enabled }} - name: ca-pemstore mountPath: /etc/ssl/certs/ca-certificates.crt subPath: ca-certificates.crt readOnly: false + {{ end }} volumes: - {{ include "spring-boot.config-volume" (dict "service" .Values.backend_cosv) | indent 10 | trim }} - name: database-secret @@ -131,9 +133,11 @@ spec: secretName: s3-secrets - name: migrations-data emptyDir: {} + {{ if .Values.gateway.initCerts.enabled }} - name: ca-pemstore configMap: name: ca-pemstore + {{ if .Values.gateway.initCerts.enabled }} --- apiVersion: v1 kind: ConfigMap diff --git a/save-cloud-charts/save-cloud/templates/backend.yaml b/save-cloud-charts/save-cloud/templates/backend.yaml index d159fa88e7..1c098d7f0c 100644 --- a/save-cloud-charts/save-cloud/templates/backend.yaml +++ b/save-cloud-charts/save-cloud/templates/backend.yaml @@ -117,10 +117,12 @@ spec: name: migrations-data - mountPath: {{ .Values.mysql.dbPasswordFile }} name: database-secret + {{ if .Values.gateway.initCerts.enabled }} - name: ca-pemstore mountPath: /etc/ssl/certs/ca-certificates.crt subPath: ca-certificates.crt readOnly: false + {{ end }} volumes: - {{ include "spring-boot.config-volume" (dict "service" .Values.backend) | indent 10 | trim }} - name: database-secret @@ -131,9 +133,21 @@ spec: secretName: s3-secrets - name: migrations-data emptyDir: {} + {{ if .Values.gateway.initCerts.enabled }} - name: ca-pemstore configMap: name: ca-pemstore + {{ end }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.backend.name }}-config +data: + application.properties: | + {{ if .Values.backend.applicationProperties }} + {{- .Values.backend.applicationProperties | nindent 4 }} + {{ end }} --- apiVersion: v1 kind: Service @@ -146,14 +160,4 @@ spec: ports: {{- include "service.common.ports" (dict "service" .Values.backend) | nindent 4 }} selector: - {{- include "service.common.selectors" (dict "service" .Values.backend) | nindent 4 }} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ .Values.backend.name }}-config -data: - application.properties: | - {{ if .Values.backend.applicationProperties }} - {{- .Values.backend.applicationProperties | nindent 4 }} - {{ end }} + {{- include "service.common.selectors" (dict "service" .Values.backend) | nindent 4 }} \ No newline at end of file diff --git a/save-cosv-frontend/src/main/resources/img/codehub.svg b/save-cosv-frontend/src/main/resources/img/codehub.svg deleted file mode 100644 index 6153995a75..0000000000 --- a/save-cosv-frontend/src/main/resources/img/codehub.svg +++ /dev/null @@ -1,37 +0,0 @@ - - logo - - - - - - - - - - - - - - - - - - - - - - - - Layer 1 - - - \ No newline at end of file diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt index 74f11e13f6..4082af06d3 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt @@ -41,7 +41,7 @@ val logoButtons: FC = FC { logo( "VULN", - "https://cosv.gitlink.org.cn/${FrontendCosvRoutes.VULN}", + "https://cosv.gitlink.org.cn", "Archive of 1-Day Vulnerabilities Aggregated from Various Sources".t(), "/img/vuln-logo-bg.png",