From 56589c229ed243e11df9c60ba4ef06d8cdc3c292 Mon Sep 17 00:00:00 2001 From: soujanyanmbri <54130357+soujanyanmbri@users.noreply.github.com> Date: Wed, 21 Aug 2024 01:48:30 +0530 Subject: [PATCH 01/10] tests --- .../helm/templates/mongodb/statefulset.yaml | 12 +++++-- deploy/helm/templates/mongodb/storage.yaml | 32 +++++++++++++------ deploy/helm/values.yaml | 26 +++++++++++---- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/deploy/helm/templates/mongodb/statefulset.yaml b/deploy/helm/templates/mongodb/statefulset.yaml index da60b6c6..5f405920 100644 --- a/deploy/helm/templates/mongodb/statefulset.yaml +++ b/deploy/helm/templates/mongodb/statefulset.yaml @@ -33,5 +33,13 @@ spec: name: mongodb-data volumes: - name: mongodb-data - persistentVolumeClaim: - claimName: {{ .Values.mongodb.pvc.name }} + persistentVolume: + claimName: {{.Values.mongodb.storage.pv.name}} + # {{- if eq .Values.mongodb.storage.type "manual" }} + # persistentVolume: + # claimName: {{.Values.mongodb.storage.pv.name}} + # --- + # {{- else }} + # persistentVolumeClaim: + # claimName: {{.Values.mongodb.storage.pvc.name}} + # {{- end }} diff --git a/deploy/helm/templates/mongodb/storage.yaml b/deploy/helm/templates/mongodb/storage.yaml index 759d215a..26294a5f 100644 --- a/deploy/helm/templates/mongodb/storage.yaml +++ b/deploy/helm/templates/mongodb/storage.yaml @@ -1,16 +1,30 @@ -kind: PersistentVolumeClaim +{{- if eq .Values.mongodb.storage.type "manual" }} +apiVersion: v1 +kind: PersistentVolume +metadata: + name: {{ .Values.mongodb.storage.pv.name }} + labels: + release: {{ .Release.Name }} + {{- toYaml .Values.mongodb.storage.pv.labels | nindent 4 }} +spec: + capacity: + storage: {{ .Values.mongodb.storage.pv.resources.requests.storage }} + accessModes: + - {{ .Values.mongodb.storage.pv.accessModes }} + hostPath: + path: {{ .Values.mongodb.storage.pv.hostPath }} +--- +{{- else }} apiVersion: v1 - +kind: PersistentVolumeClaim metadata: - name: {{ .Values.mongodb.pvc.name }} + name: {{ .Values.mongodb.storage.pvc.name }} labels: release: {{ .Release.Name }} - {{- toYaml .Values.mongodb.pvc.labels | nindent 4 }} - + {{- toYaml .Values.mongodb.storage.pvc.labels | nindent 4 }} spec: - #storageClassName: local-path accessModes: - - ReadWriteOnce - + - {{ .Values.mongodb.storage.pvc.accessModes }} resources: - {{- toYaml .Values.mongodb.pvc.resources | nindent 4 }} + storage: {{ .Values.mongodb.storage.pvc.resources.requests.storage }} +{{- end }} diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index 492b8fc0..9f994b49 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -187,13 +187,25 @@ mongodb: mongoPassword: crapisecretpassword mongoDbName: crapi mongoUri: "admin:crapisecretpassword@mongodb:27017" - pvc: - name: mongodb-pv-claim - labels: - app: mongodb - resources: - requests: - storage: 2Gi + storage: + type: "manual" + pv: + name: mongodb-pv + labels: + app: mongodb + resources: + requests: + storage: 2Gi + hostPath: /mnt/test + accessModes: ReadWriteOnce + + # pvc: + # name: mongodb-pv-claim + # labels: + # app: mongodb + # resources: + # requests: + # storage: 2Gi serviceSelectorLabels: app: mongodb podLabels: From 1489cc906146229dba744a3a50f5c06325e3c1b3 Mon Sep 17 00:00:00 2001 From: soujanyanmbri <54130357+soujanyanmbri@users.noreply.github.com> Date: Wed, 21 Aug 2024 02:25:28 +0530 Subject: [PATCH 02/10] Check --- .../helm/templates/mongodb/statefulset.yaml | 17 +++---- deploy/helm/templates/mongodb/storage.yaml | 4 +- .../helm/templates/postgres/statefulset.yaml | 9 +++- deploy/helm/templates/postgres/storage.yaml | 32 ++++++++---- deploy/helm/values.yaml | 50 ++++++++++++------- 5 files changed, 70 insertions(+), 42 deletions(-) diff --git a/deploy/helm/templates/mongodb/statefulset.yaml b/deploy/helm/templates/mongodb/statefulset.yaml index 5f405920..9e2bbeac 100644 --- a/deploy/helm/templates/mongodb/statefulset.yaml +++ b/deploy/helm/templates/mongodb/statefulset.yaml @@ -33,13 +33,10 @@ spec: name: mongodb-data volumes: - name: mongodb-data - persistentVolume: - claimName: {{.Values.mongodb.storage.pv.name}} - # {{- if eq .Values.mongodb.storage.type "manual" }} - # persistentVolume: - # claimName: {{.Values.mongodb.storage.pv.name}} - # --- - # {{- else }} - # persistentVolumeClaim: - # claimName: {{.Values.mongodb.storage.pvc.name}} - # {{- end }} + {{- if eq .Values.mongodb.storage.type "manual" }} + hostPath: + path: {{ .Values.mongodb.storage.pv.hostPath }} + {{- else }} + persistentVolumeClaim: + claimName: {{ .Values.mongodb.storage.pvc.name }} + {{- end }} \ No newline at end of file diff --git a/deploy/helm/templates/mongodb/storage.yaml b/deploy/helm/templates/mongodb/storage.yaml index 26294a5f..f1e05e3c 100644 --- a/deploy/helm/templates/mongodb/storage.yaml +++ b/deploy/helm/templates/mongodb/storage.yaml @@ -8,7 +8,7 @@ metadata: {{- toYaml .Values.mongodb.storage.pv.labels | nindent 4 }} spec: capacity: - storage: {{ .Values.mongodb.storage.pv.resources.requests.storage }} + storage: {{ .Values.mongodb.storage.pv.resources.storage }} accessModes: - {{ .Values.mongodb.storage.pv.accessModes }} hostPath: @@ -26,5 +26,5 @@ spec: accessModes: - {{ .Values.mongodb.storage.pvc.accessModes }} resources: - storage: {{ .Values.mongodb.storage.pvc.resources.requests.storage }} + {{- toYaml .Values.mongodb.storage.pvc.resources | nindent 4 }} {{- end }} diff --git a/deploy/helm/templates/postgres/statefulset.yaml b/deploy/helm/templates/postgres/statefulset.yaml index 46d6602d..bb4245d9 100644 --- a/deploy/helm/templates/postgres/statefulset.yaml +++ b/deploy/helm/templates/postgres/statefulset.yaml @@ -35,6 +35,11 @@ spec: name: postgres-data subPath: postgres volumes: - - name: postgres-data + - name: postgresdb-data + {{- if eq .Values.postgresdb.storage.type "manual" }} + hostPath: + path: {{ .Values.postgresdb.storage.pv.hostPath }} + {{- else }} persistentVolumeClaim: - claimName: {{ .Values.postgresdb.pvc.name }} + claimName: {{ .Values.postgresdb.storage.pvc.name }} + {{- end }} diff --git a/deploy/helm/templates/postgres/storage.yaml b/deploy/helm/templates/postgres/storage.yaml index 17afb462..53283cc7 100644 --- a/deploy/helm/templates/postgres/storage.yaml +++ b/deploy/helm/templates/postgres/storage.yaml @@ -1,16 +1,30 @@ -kind: PersistentVolumeClaim +{{- if eq .Values.postgresdb.storage.type "manual" }} +apiVersion: v1 +kind: PersistentVolume +metadata: + name: {{ .Values.postgresdb.storage.pv.name }} + labels: + release: {{ .Release.Name }} + {{- toYaml .Values.postgresdb.storage.pv.labels | nindent 4 }} +spec: + capacity: + storage: {{ .Values.postgresdb.storage.pv.resources.storage }} + accessModes: + - {{ .Values.postgresdb.storage.pv.accessModes }} + hostPath: + path: {{ .Values.postgresdb.storage.pv.hostPath }} +--- +{{- else }} apiVersion: v1 - +kind: PersistentVolumeClaim metadata: - name: {{ .Values.postgresdb.pvc.name }} + name: {{ .Values.postgresdb.storage.pvc.name }} labels: release: {{ .Release.Name }} - {{- toYaml .Values.postgresdb.pvc.labels | nindent 4 }} - + {{- toYaml .Values.postgresdb.storage.pvc.labels | nindent 4 }} spec: - #storageClassName: local-path accessModes: - - ReadWriteOnce - + - {{ .Values.postgresdb.storage.pvc.accessModes }} resources: - {{- toYaml .Values.postgresdb.pvc.resources | nindent 4 }} + {{- toYaml .Values.postgresdb.storage.pvc.resources | nindent 4 }} +{{- end }} diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index 9f994b49..68f6bed2 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -188,24 +188,24 @@ mongodb: mongoDbName: crapi mongoUri: "admin:crapisecretpassword@mongodb:27017" storage: - type: "manual" - pv: - name: mongodb-pv + # type: "manual" + # pv: + # name: mongodb-pv + # labels: + # app: mongodb + # resources: + # rstorage: 2Gi + # hostPath: /mnt/test + # accessModes: ReadWriteOnce + type: "default" + pvc: + name: mongodb-pv-claim labels: app: mongodb + accessModes: ReadWriteOnce resources: requests: storage: 2Gi - hostPath: /mnt/test - accessModes: ReadWriteOnce - - # pvc: - # name: mongodb-pv-claim - # labels: - # app: mongodb - # resources: - # requests: - # storage: 2Gi serviceSelectorLabels: app: mongodb podLabels: @@ -233,13 +233,25 @@ postgresdb: postgresUser: admin postgresPassword: crapisecretpassword postgresDbName: crapi - pvc: - name: postgres-pv-claim - labels: - app: postgresdb - resources: - requests: + storage: + type: "manual" + pv: + name: postgres-pv + labels: + app: postgresdb + resources: storage: 2Gi + hostPath: /mnt/test + accessModes: ReadWriteOnce + # type: "default" + # pvc: + # name: postgres-pv-claim + # labels: + # app: postgresdb + # accessModes: ReadWriteOnce + # resources: + # requests: + # storage: 2Gi serviceSelectorLabels: app: postgresdb podLabels: From aa80a54ab38ef4614e208e2ee2c9fad6311966ad Mon Sep 17 00:00:00 2001 From: soujanyanmbri <54130357+soujanyanmbri@users.noreply.github.com> Date: Wed, 21 Aug 2024 02:29:40 +0530 Subject: [PATCH 03/10] Add a separate PV --- deploy/helm/values-pv.yaml | 284 +++++++++++++++++++++++++++++++++++++ deploy/helm/values.yaml | 30 ++-- 2 files changed, 299 insertions(+), 15 deletions(-) create mode 100644 deploy/helm/values-pv.yaml diff --git a/deploy/helm/values-pv.yaml b/deploy/helm/values-pv.yaml new file mode 100644 index 00000000..ed0cbd05 --- /dev/null +++ b/deploy/helm/values-pv.yaml @@ -0,0 +1,284 @@ +# Default values for crapi. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +jwtSecret: crapi +enableLog4j: true +enableShellInjection: true +imagePullPolicy: Always +apiGatewayServiceUrl: https://api.mypremiumdealership.com +apiGatewayServiceInstall: true +apiGatewayPassword: +tlsEnabled: false +jwtExpiration: 604800000 +logLevel: INFO + +waitForK8sResources: + enabled: True + image: groundnuty/k8s-wait-for:v2.0 + imagePullPolicy: IfNotPresent + +web: + name: crapi-web + image: crapi/crapi-web + replicaCount: 1 + port: 80 + sslPort: 443 + service: + name: crapi-web + labels: + app: crapi-web + nodePort: 30080 + sslNodePort: 30443 + config: + name: crapi-web-configmap + labels: + app: crapi-web + deploymentLabels: + app: crapi-web + podLabels: + app: crapi-web + deploymentSelectorMatchLabels: + app: crapi-web + serviceSelectorLabels: + app: crapi-web + +identity: + name: crapi-identity + image: crapi/crapi-identity + port: 8080 + replicaCount: 1 + service: + name: crapi-identity + labels: + app: crapi-identity + jwtKeySecret: + name: jwt-key-secret + file: keys/jwks.json + labels: + app: crapi-identity + config: + name: crapi-identity-configmap + labels: + app: crapi-identity + postgresDbDriver: postgresql + appName: "crapi-identity" + mailhogDomain: "example.com" + smtpHost: "smtp.example.com" + smtpPort: 587 + smtpEmail: "user@example.com" + smtpPass: "xxxxxxxxxxxxxx" + smtpFrom: "no-reply@example.com" + smtpAuth: true + smtpStartTLS: true + keyStoreType: PKCS12 + keyStore: classpath:certs/server.p12 + keyStorePassword: passw0rd + keyPassword: passw0rd + keyAlias: identity + deploymentLabels: + app: crapi-identity + podLabels: + app: crapi-identity + deploymentSelectorMatchLabels: + app: crapi-identity + serviceSelectorLabels: + app: crapi-identity + +community: + name: crapi-community + image: crapi/crapi-community + port: 8087 + replicaCount: 1 + service: + name: crapi-community + labels: + app: crapi-community + config: + name: crapi-community-configmap + labels: + app: crapi-community + postgresDbDriver: postgres + mongoDbDriver: mongodb + deploymentLabels: + app: crapi-community + podLabels: + app: crapi-community + deploymentSelectorMatchLabels: + app: crapi-community + serviceSelectorLabels: + app: crapi-community + +workshop: + name: crapi-workshop + image: crapi/crapi-workshop + port: 8000 + replicaCount: 1 + service: + name: crapi-workshop + labels: + app: crapi-workshop + config: + name: crapi-workshop-configmap + labels: + app: crapi-workshop + postgresDbDriver: postgres + mongoDbDriver: mongodb + secretKey: crapi + deploymentLabels: + app: crapi-workshop + podLabels: + app: crapi-workshop + deploymentSelectorMatchLabels: + app: crapi-workshop + serviceSelectorLabels: + app: crapi-workshop + +mailhog: + name: mailhog + image: crapi/mailhog + webPort: 8025 + smtpPort: 1025 + replicaCount: 1 + minReadySeconds: 10 + progressDeadlineSeconds: 600 + namespace: crapi + smtpService: + name: mailhog + labels: + app: mailhog + webService: + name: mailhog-web + labels: + app: mailhog + nodePort: 30025 + config: + name: mailhog-configmap + labels: + app: mailhog + mailhogStorage: mongodb + deploymentLabels: + app: mailhog + podLabels: + app: mailhog + podAnnotations: + sidecar.traceable.ai/inject: "false" + deploymentSelectorMatchLabels: + app: mailhog + serviceSelectorLabels: + app: mailhog + +mongodb: + name: mongodb + image: mongo + version: 5.0 + imagePullPolicy: IfNotPresent + port: 27017 + replicaCount: 1 + service: + name: mongodb + labels: + app: mongodb + config: + name: mongodb-config + labels: + app: mongodb + mongoUser: admin + mongoPassword: crapisecretpassword + mongoDbName: crapi + mongoUri: "admin:crapisecretpassword@mongodb:27017" + storage: + type: "manual" + pv: + name: mongodb-pv + labels: + app: mongodb + resources: + rstorage: 2Gi + hostPath: /mnt/test + accessModes: ReadWriteOnce + # type: "default" + # pvc: + # name: mongodb-pv-claim + # labels: + # app: mongodb + # accessModes: ReadWriteOnce + # resources: + # requests: + # storage: 2Gi + serviceSelectorLabels: + app: mongodb + podLabels: + app: mongodb + statefulsetLabels: + app: mongodb + statefulsetSelectorMatchLabels: + app: mongodb + +postgresdb: + name: postgresdb + image: postgres + version: 14 + imagePullPolicy: IfNotPresent + port: 5432 + replicaCount: 1 + service: + name: postgresdb + labels: + app: postgresdb + config: + name: postgres-config + labels: + app: postgresdb + postgresUser: admin + postgresPassword: crapisecretpassword + postgresDbName: crapi + storage: + type: "manual" + pv: + name: postgres-pv + labels: + app: postgresdb + resources: + storage: 2Gi + hostPath: /mnt/test + accessModes: ReadWriteOnce + # type: "default" + # pvc: + # name: postgres-pv-claim + # labels: + # app: postgresdb + # accessModes: ReadWriteOnce + # resources: + # requests: + # storage: 2Gi + serviceSelectorLabels: + app: postgresdb + podLabels: + app: postgresdb + statefulsetLabels: + app: postgresdb + statefulsetSelectorMatchLabels: + app: postgresdb + +apiGatewayService: + name: gateway-service + image: crapi/gateway-service + port: 443 + replicaCount: 1 + service: + name: "gateway-service" + labels: + app: gateway-service + config: + name: gateway-service + labels: + app: gateway-service + deploymentLabels: + app: gateway-service + podLabels: + app: gateway-service + deploymentSelectorMatchLabels: + app: gateway-service + serviceSelectorLabels: + app: gateway-service diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index 68f6bed2..bb3f6ec1 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -234,24 +234,24 @@ postgresdb: postgresPassword: crapisecretpassword postgresDbName: crapi storage: - type: "manual" - pv: - name: postgres-pv - labels: - app: postgresdb - resources: - storage: 2Gi - hostPath: /mnt/test - accessModes: ReadWriteOnce - # type: "default" - # pvc: - # name: postgres-pv-claim + # type: "manual" + # pv: + # name: postgres-pv # labels: # app: postgresdb - # accessModes: ReadWriteOnce # resources: - # requests: - # storage: 2Gi + # storage: 2Gi + # hostPath: /mnt/test + # accessModes: ReadWriteOnce + type: "default" + pvc: + name: postgres-pv-claim + labels: + app: postgresdb + accessModes: ReadWriteOnce + resources: + requests: + storage: 2Gi serviceSelectorLabels: app: postgresdb podLabels: From e01df51e78eb8c165dbb008e70e5ecdb1fb5e0c9 Mon Sep 17 00:00:00 2001 From: soujanyanmbri <54130357+soujanyanmbri@users.noreply.github.com> Date: Wed, 21 Aug 2024 12:59:48 +0530 Subject: [PATCH 04/10] Test 2 --- deploy/helm/templates/mongodb/statefulset.yaml | 6 +----- deploy/helm/templates/mongodb/storage.yaml | 14 +++++++++----- deploy/helm/templates/postgres/statefulset.yaml | 5 ----- deploy/helm/templates/postgres/storage.yaml | 14 ++++++++------ deploy/helm/values.yaml | 4 ---- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/deploy/helm/templates/mongodb/statefulset.yaml b/deploy/helm/templates/mongodb/statefulset.yaml index 9e2bbeac..9d13689d 100644 --- a/deploy/helm/templates/mongodb/statefulset.yaml +++ b/deploy/helm/templates/mongodb/statefulset.yaml @@ -33,10 +33,6 @@ spec: name: mongodb-data volumes: - name: mongodb-data - {{- if eq .Values.mongodb.storage.type "manual" }} - hostPath: - path: {{ .Values.mongodb.storage.pv.hostPath }} - {{- else }} persistentVolumeClaim: claimName: {{ .Values.mongodb.storage.pvc.name }} - {{- end }} \ No newline at end of file + \ No newline at end of file diff --git a/deploy/helm/templates/mongodb/storage.yaml b/deploy/helm/templates/mongodb/storage.yaml index f1e05e3c..a8a4d412 100644 --- a/deploy/helm/templates/mongodb/storage.yaml +++ b/deploy/helm/templates/mongodb/storage.yaml @@ -1,5 +1,5 @@ -{{- if eq .Values.mongodb.storage.type "manual" }} apiVersion: v1 +{{- if eq .Values.mongodb.storage.type "manual" }} kind: PersistentVolume metadata: name: {{ .Values.mongodb.storage.pv.name }} @@ -7,14 +7,15 @@ metadata: release: {{ .Release.Name }} {{- toYaml .Values.mongodb.storage.pv.labels | nindent 4 }} spec: + storageClassName: {{ .Values.mongodb.storage.type }} capacity: storage: {{ .Values.mongodb.storage.pv.resources.storage }} accessModes: - - {{ .Values.mongodb.storage.pv.accessModes }} + - ReadWriteOnce hostPath: path: {{ .Values.mongodb.storage.pv.hostPath }} --- -{{- else }} +{{- end }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -23,8 +24,11 @@ metadata: release: {{ .Release.Name }} {{- toYaml .Values.mongodb.storage.pvc.labels | nindent 4 }} spec: + {{- if ne .Values.mongodb.storage.type "default" }} + storageClassName: {{ .Values.mongodb.storage.type }} + {{- end }} accessModes: - - {{ .Values.mongodb.storage.pvc.accessModes }} + - ReadWriteOnce resources: {{- toYaml .Values.mongodb.storage.pvc.resources | nindent 4 }} -{{- end }} + diff --git a/deploy/helm/templates/postgres/statefulset.yaml b/deploy/helm/templates/postgres/statefulset.yaml index bb4245d9..bb608ae4 100644 --- a/deploy/helm/templates/postgres/statefulset.yaml +++ b/deploy/helm/templates/postgres/statefulset.yaml @@ -36,10 +36,5 @@ spec: subPath: postgres volumes: - name: postgresdb-data - {{- if eq .Values.postgresdb.storage.type "manual" }} - hostPath: - path: {{ .Values.postgresdb.storage.pv.hostPath }} - {{- else }} persistentVolumeClaim: claimName: {{ .Values.postgresdb.storage.pvc.name }} - {{- end }} diff --git a/deploy/helm/templates/postgres/storage.yaml b/deploy/helm/templates/postgres/storage.yaml index 53283cc7..ee31cac0 100644 --- a/deploy/helm/templates/postgres/storage.yaml +++ b/deploy/helm/templates/postgres/storage.yaml @@ -1,5 +1,5 @@ -{{- if eq .Values.postgresdb.storage.type "manual" }} apiVersion: v1 +{{- if eq .Values.postgresdb.storage.type "manual" }} kind: PersistentVolume metadata: name: {{ .Values.postgresdb.storage.pv.name }} @@ -7,15 +7,15 @@ metadata: release: {{ .Release.Name }} {{- toYaml .Values.postgresdb.storage.pv.labels | nindent 4 }} spec: + storageClassName: {{ .Values.postgresdb.storage.type }} capacity: storage: {{ .Values.postgresdb.storage.pv.resources.storage }} accessModes: - - {{ .Values.postgresdb.storage.pv.accessModes }} + - ReadWriteOnce hostPath: path: {{ .Values.postgresdb.storage.pv.hostPath }} --- -{{- else }} -apiVersion: v1 +{{- end }} kind: PersistentVolumeClaim metadata: name: {{ .Values.postgresdb.storage.pvc.name }} @@ -23,8 +23,10 @@ metadata: release: {{ .Release.Name }} {{- toYaml .Values.postgresdb.storage.pvc.labels | nindent 4 }} spec: + {{- if ne .Values.postgresdb.storage.type "default" }} + storageClassName: {{ .Values.postgresdb.storage.type }} + {{- end }} accessModes: - - {{ .Values.postgresdb.storage.pvc.accessModes }} + - ReadWriteOnce resources: {{- toYaml .Values.postgresdb.storage.pvc.resources | nindent 4 }} -{{- end }} diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index bb3f6ec1..8b02f6ab 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -196,13 +196,11 @@ mongodb: # resources: # rstorage: 2Gi # hostPath: /mnt/test - # accessModes: ReadWriteOnce type: "default" pvc: name: mongodb-pv-claim labels: app: mongodb - accessModes: ReadWriteOnce resources: requests: storage: 2Gi @@ -242,13 +240,11 @@ postgresdb: # resources: # storage: 2Gi # hostPath: /mnt/test - # accessModes: ReadWriteOnce type: "default" pvc: name: postgres-pv-claim labels: app: postgresdb - accessModes: ReadWriteOnce resources: requests: storage: 2Gi From 8625a8037eeb0e6118a20fa026b4fe848f131125 Mon Sep 17 00:00:00 2001 From: soujanyanmbri <54130357+soujanyanmbri@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:04:54 +0530 Subject: [PATCH 05/10] Clean up --- deploy/helm/templates/postgres/statefulset.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/helm/templates/postgres/statefulset.yaml b/deploy/helm/templates/postgres/statefulset.yaml index bb608ae4..e0356001 100644 --- a/deploy/helm/templates/postgres/statefulset.yaml +++ b/deploy/helm/templates/postgres/statefulset.yaml @@ -35,6 +35,6 @@ spec: name: postgres-data subPath: postgres volumes: - - name: postgresdb-data + - name: postgres-data persistentVolumeClaim: claimName: {{ .Values.postgresdb.storage.pvc.name }} From 042cd490a85e7b9bc8c4ab8056cbde4aff430384 Mon Sep 17 00:00:00 2001 From: soujanyanmbri <54130357+soujanyanmbri@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:53:37 +0530 Subject: [PATCH 06/10] Clean up --- deploy/helm/templates/mongodb/storage.yaml | 2 +- deploy/helm/templates/postgres/storage.yaml | 3 +- deploy/helm/values-pv.yaml | 279 ++------------------ 3 files changed, 20 insertions(+), 264 deletions(-) diff --git a/deploy/helm/templates/mongodb/storage.yaml b/deploy/helm/templates/mongodb/storage.yaml index a8a4d412..ea7b61c6 100644 --- a/deploy/helm/templates/mongodb/storage.yaml +++ b/deploy/helm/templates/mongodb/storage.yaml @@ -1,5 +1,5 @@ -apiVersion: v1 {{- if eq .Values.mongodb.storage.type "manual" }} +apiVersion: v1 kind: PersistentVolume metadata: name: {{ .Values.mongodb.storage.pv.name }} diff --git a/deploy/helm/templates/postgres/storage.yaml b/deploy/helm/templates/postgres/storage.yaml index ee31cac0..6d50bbbd 100644 --- a/deploy/helm/templates/postgres/storage.yaml +++ b/deploy/helm/templates/postgres/storage.yaml @@ -1,5 +1,5 @@ -apiVersion: v1 {{- if eq .Values.postgresdb.storage.type "manual" }} +apiVersion: v1 kind: PersistentVolume metadata: name: {{ .Values.postgresdb.storage.pv.name }} @@ -16,6 +16,7 @@ spec: path: {{ .Values.postgresdb.storage.pv.hostPath }} --- {{- end }} +apiVersion: v1 kind: PersistentVolumeClaim metadata: name: {{ .Values.postgresdb.storage.pvc.name }} diff --git a/deploy/helm/values-pv.yaml b/deploy/helm/values-pv.yaml index ed0cbd05..42df92fd 100644 --- a/deploy/helm/values-pv.yaml +++ b/deploy/helm/values-pv.yaml @@ -1,192 +1,4 @@ -# Default values for crapi. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -jwtSecret: crapi -enableLog4j: true -enableShellInjection: true -imagePullPolicy: Always -apiGatewayServiceUrl: https://api.mypremiumdealership.com -apiGatewayServiceInstall: true -apiGatewayPassword: -tlsEnabled: false -jwtExpiration: 604800000 -logLevel: INFO - -waitForK8sResources: - enabled: True - image: groundnuty/k8s-wait-for:v2.0 - imagePullPolicy: IfNotPresent - -web: - name: crapi-web - image: crapi/crapi-web - replicaCount: 1 - port: 80 - sslPort: 443 - service: - name: crapi-web - labels: - app: crapi-web - nodePort: 30080 - sslNodePort: 30443 - config: - name: crapi-web-configmap - labels: - app: crapi-web - deploymentLabels: - app: crapi-web - podLabels: - app: crapi-web - deploymentSelectorMatchLabels: - app: crapi-web - serviceSelectorLabels: - app: crapi-web - -identity: - name: crapi-identity - image: crapi/crapi-identity - port: 8080 - replicaCount: 1 - service: - name: crapi-identity - labels: - app: crapi-identity - jwtKeySecret: - name: jwt-key-secret - file: keys/jwks.json - labels: - app: crapi-identity - config: - name: crapi-identity-configmap - labels: - app: crapi-identity - postgresDbDriver: postgresql - appName: "crapi-identity" - mailhogDomain: "example.com" - smtpHost: "smtp.example.com" - smtpPort: 587 - smtpEmail: "user@example.com" - smtpPass: "xxxxxxxxxxxxxx" - smtpFrom: "no-reply@example.com" - smtpAuth: true - smtpStartTLS: true - keyStoreType: PKCS12 - keyStore: classpath:certs/server.p12 - keyStorePassword: passw0rd - keyPassword: passw0rd - keyAlias: identity - deploymentLabels: - app: crapi-identity - podLabels: - app: crapi-identity - deploymentSelectorMatchLabels: - app: crapi-identity - serviceSelectorLabels: - app: crapi-identity - -community: - name: crapi-community - image: crapi/crapi-community - port: 8087 - replicaCount: 1 - service: - name: crapi-community - labels: - app: crapi-community - config: - name: crapi-community-configmap - labels: - app: crapi-community - postgresDbDriver: postgres - mongoDbDriver: mongodb - deploymentLabels: - app: crapi-community - podLabels: - app: crapi-community - deploymentSelectorMatchLabels: - app: crapi-community - serviceSelectorLabels: - app: crapi-community - -workshop: - name: crapi-workshop - image: crapi/crapi-workshop - port: 8000 - replicaCount: 1 - service: - name: crapi-workshop - labels: - app: crapi-workshop - config: - name: crapi-workshop-configmap - labels: - app: crapi-workshop - postgresDbDriver: postgres - mongoDbDriver: mongodb - secretKey: crapi - deploymentLabels: - app: crapi-workshop - podLabels: - app: crapi-workshop - deploymentSelectorMatchLabels: - app: crapi-workshop - serviceSelectorLabels: - app: crapi-workshop - -mailhog: - name: mailhog - image: crapi/mailhog - webPort: 8025 - smtpPort: 1025 - replicaCount: 1 - minReadySeconds: 10 - progressDeadlineSeconds: 600 - namespace: crapi - smtpService: - name: mailhog - labels: - app: mailhog - webService: - name: mailhog-web - labels: - app: mailhog - nodePort: 30025 - config: - name: mailhog-configmap - labels: - app: mailhog - mailhogStorage: mongodb - deploymentLabels: - app: mailhog - podLabels: - app: mailhog - podAnnotations: - sidecar.traceable.ai/inject: "false" - deploymentSelectorMatchLabels: - app: mailhog - serviceSelectorLabels: - app: mailhog - mongodb: - name: mongodb - image: mongo - version: 5.0 - imagePullPolicy: IfNotPresent - port: 27017 - replicaCount: 1 - service: - name: mongodb - labels: - app: mongodb - config: - name: mongodb-config - labels: - app: mongodb - mongoUser: admin - mongoPassword: crapisecretpassword - mongoDbName: crapi - mongoUri: "admin:crapisecretpassword@mongodb:27017" storage: type: "manual" pv: @@ -194,45 +6,19 @@ mongodb: labels: app: mongodb resources: - rstorage: 2Gi + storage: 2Gi hostPath: /mnt/test accessModes: ReadWriteOnce - # type: "default" - # pvc: - # name: mongodb-pv-claim - # labels: - # app: mongodb - # accessModes: ReadWriteOnce - # resources: - # requests: - # storage: 2Gi - serviceSelectorLabels: - app: mongodb - podLabels: - app: mongodb - statefulsetLabels: - app: mongodb - statefulsetSelectorMatchLabels: - app: mongodb + pvc: + name: mongodb-pv-claim + labels: + app: mongodb + accessModes: ReadWriteOnce + resources: + requests: + storage: 2Gi postgresdb: - name: postgresdb - image: postgres - version: 14 - imagePullPolicy: IfNotPresent - port: 5432 - replicaCount: 1 - service: - name: postgresdb - labels: - app: postgresdb - config: - name: postgres-config - labels: - app: postgresdb - postgresUser: admin - postgresPassword: crapisecretpassword - postgresDbName: crapi storage: type: "manual" pv: @@ -243,42 +29,11 @@ postgresdb: storage: 2Gi hostPath: /mnt/test accessModes: ReadWriteOnce - # type: "default" - # pvc: - # name: postgres-pv-claim - # labels: - # app: postgresdb - # accessModes: ReadWriteOnce - # resources: - # requests: - # storage: 2Gi - serviceSelectorLabels: - app: postgresdb - podLabels: - app: postgresdb - statefulsetLabels: - app: postgresdb - statefulsetSelectorMatchLabels: - app: postgresdb - -apiGatewayService: - name: gateway-service - image: crapi/gateway-service - port: 443 - replicaCount: 1 - service: - name: "gateway-service" - labels: - app: gateway-service - config: - name: gateway-service - labels: - app: gateway-service - deploymentLabels: - app: gateway-service - podLabels: - app: gateway-service - deploymentSelectorMatchLabels: - app: gateway-service - serviceSelectorLabels: - app: gateway-service + pvc: + name: postgres-pv-claim + labels: + app: postgresdb + accessModes: ReadWriteOnce + resources: + requests: + storage: 2Gi \ No newline at end of file From c6abc6758a3bc35e1619c89a62421a95750272c5 Mon Sep 17 00:00:00 2001 From: soujanyanmbri <54130357+soujanyanmbri@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:56:29 +0530 Subject: [PATCH 07/10] remove comments --- deploy/helm/values.yaml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index 8b02f6ab..1328c398 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -188,14 +188,6 @@ mongodb: mongoDbName: crapi mongoUri: "admin:crapisecretpassword@mongodb:27017" storage: - # type: "manual" - # pv: - # name: mongodb-pv - # labels: - # app: mongodb - # resources: - # rstorage: 2Gi - # hostPath: /mnt/test type: "default" pvc: name: mongodb-pv-claim @@ -232,14 +224,6 @@ postgresdb: postgresPassword: crapisecretpassword postgresDbName: crapi storage: - # type: "manual" - # pv: - # name: postgres-pv - # labels: - # app: postgresdb - # resources: - # storage: 2Gi - # hostPath: /mnt/test type: "default" pvc: name: postgres-pv-claim From 8982962eebced6f40fdda54966e3211b34444873 Mon Sep 17 00:00:00 2001 From: soujanyanmbri <54130357+soujanyanmbri@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:30:29 +0530 Subject: [PATCH 08/10] Update Readme, revert comments --- .github/workflows/pr-build.yml | 12 ++++++------ deploy/helm/values-pv.yaml | 2 -- deploy/helm/values.yaml | 16 ++++++++++++++++ docs/setup.md | 10 +++++++++- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 6bbc533b..daaf519c 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -249,14 +249,14 @@ jobs: coverage report coverage xml -o coverage.xml - - name: Publish Coverage for workshop - uses: orgoro/coverage@v3.2 - with: - coverageFile: services/workshop/coverage.xml - token: ${{ secrets.GITHUB_TOKEN }} + # - name: Publish Coverage for workshop + # uses: orgoro/coverage@v3.2 + # with: + # coverageFile: services/workshop/coverage.xml + # token: ${{ secrets.GITHUB_TOKEN }} - name: node prettier run: | cd services/web npm install - npm run lint + npm run lint \ No newline at end of file diff --git a/deploy/helm/values-pv.yaml b/deploy/helm/values-pv.yaml index 42df92fd..bf353e14 100644 --- a/deploy/helm/values-pv.yaml +++ b/deploy/helm/values-pv.yaml @@ -13,7 +13,6 @@ mongodb: name: mongodb-pv-claim labels: app: mongodb - accessModes: ReadWriteOnce resources: requests: storage: 2Gi @@ -28,7 +27,6 @@ postgresdb: resources: storage: 2Gi hostPath: /mnt/test - accessModes: ReadWriteOnce pvc: name: postgres-pv-claim labels: diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index 1328c398..7708b1b8 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -188,6 +188,14 @@ mongodb: mongoDbName: crapi mongoUri: "admin:crapisecretpassword@mongodb:27017" storage: + # type: "manual" + # pv: + # name: mongodb-pv + # labels: + # app: mongodb + # resources: + # storage: 2Gi + # hostPath: /mnt/test type: "default" pvc: name: mongodb-pv-claim @@ -224,6 +232,14 @@ postgresdb: postgresPassword: crapisecretpassword postgresDbName: crapi storage: + # type: "manual" + # pv: + # name: postgres-pv + # labels: + # app: postgresdb + # resources: + # storage: 2Gi + # hostPath: /mnt/test type: "default" pvc: name: postgres-pv-claim diff --git a/docs/setup.md b/docs/setup.md index edee1d2f..00b21c66 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -114,13 +114,21 @@ You can change the smtp configuration if required however all emails with domain ``` git clone [REPOSITORY-URL] ``` - 2. Install the helm chart + + Inorder to add persistent volume and configure the hostPath (To manually mount the data to a specific location), Update values-pv.yaml and use it to install helm charts. + ``` + cd deploy/helm + + helm install --namespace crapi crapi . --values values-pv.yaml + ``` + Otherwise install the helm chart normally. ``` cd deploy/helm helm install --namespace crapi crapi . --values values.yaml ``` + 3. If using minikube, create a tunnel to initialize the LoadBalancers ``` minikube tunnel --alsologtostderr From 7d4cae8a21ce280f3bfbb5e3bd4a96831a67721e Mon Sep 17 00:00:00 2001 From: soujanyanmbri <54130357+soujanyanmbri@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:38:57 +0530 Subject: [PATCH 09/10] Update docs --- docs/setup.md | 3 ++- docs/troubleshooting.md | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/setup.md b/docs/setup.md index 00b21c66..0a0f8f78 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -116,7 +116,8 @@ You can change the smtp configuration if required however all emails with domain ``` 2. Install the helm chart - Inorder to add persistent volume and configure the hostPath (To manually mount the data to a specific location), Update values-pv.yaml and use it to install helm charts. + Inorder to manually mount the data to a specific location, hostPath should be updated in values-pv.yaml, and used to install the helm charts. + ``` cd deploy/helm diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index bb1ac8f2..135e577e 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -110,3 +110,16 @@ systemctl cat docker.service It will tell you where the docker service file is located. Then edit `/lib/systemd/system/docker.service` with your favorite text editor: append `NetworkManager-wait-online.service` to line 4 (that line should start with the word `After=`) Then run `systemctl daemon-reload` to update your changes to the service file. + +--- + +**5. Problem:** Issues while using hostPath to manually mount the data: + +ERROR: 0/1 nodes are available: pod has unbound immediate PersistentVolumeClaims. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling + +To fix this issue, delete the existing persistent volumes, and start clean. +```Shell +❯ kubectl get pv + +❯ kubectl delete pv {pv_names} +``` \ No newline at end of file From c9b4442f52bd86bceba48096c4c39df2cccbbe26 Mon Sep 17 00:00:00 2001 From: soujanyanmbri <54130357+soujanyanmbri@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:40:36 +0530 Subject: [PATCH 10/10] Revert PR Build --- .github/workflows/pr-build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index daaf519c..1513ff0f 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -249,11 +249,11 @@ jobs: coverage report coverage xml -o coverage.xml - # - name: Publish Coverage for workshop - # uses: orgoro/coverage@v3.2 - # with: - # coverageFile: services/workshop/coverage.xml - # token: ${{ secrets.GITHUB_TOKEN }} + - name: Publish Coverage for workshop + uses: orgoro/coverage@v3.2 + with: + coverageFile: services/workshop/coverage.xml + token: ${{ secrets.GITHUB_TOKEN }} - name: node prettier run: |