From 7cf9f542813b339766f32a91f5d23bf77f0286c5 Mon Sep 17 00:00:00 2001 From: AlePini Date: Tue, 25 Mar 2025 11:48:33 +0100 Subject: [PATCH 1/7] feat: hardcode paths and name in service --- charts/shc/templates/service.yaml | 34 +++++++++++++++---------------- charts/shc/values.yaml | 12 ----------- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/charts/shc/templates/service.yaml b/charts/shc/templates/service.yaml index ac42c88..76d8692 100644 --- a/charts/shc/templates/service.yaml +++ b/charts/shc/templates/service.yaml @@ -1,10 +1,10 @@ # templates/service.yaml -apiVersion: {{ .Values.service.apiVersion }} +apiVersion: v1 kind: Service metadata: - name: {{ .Values.service.name }} + name: {{ .Release.Name }}-community labels: - app: {{ .Values.service.app }} + app: {{ .Release.Name }}-community annotations: {{- if and (eq .Values.service.type "LoadBalancer") (.Values.service.cloud.provider | default "gke" | eq "gke") }} networking.gke.io/load-balancer-type: "External" @@ -29,26 +29,26 @@ spec: ports: {{- if .Values.community.config.community.enableSubpathBasedAccess }} - - port: {{ .Values.service.ports.subpath.port }} - targetPort: {{ .Values.service.ports.subpath.targetPort }} + - name: subpath protocol: TCP - name: {{ .Values.service.ports.subpath.name }} + port: {{ .Values.service.ports.subpath.port }} + targetPort: {{ .Values.service.ports.subpath.targetPort }} {{- else }} - - port: {{ .Values.service.ports.frontend.port }} + - name: frontend + protocol: TCP + port: {{ .Values.service.ports.frontend.port }} targetPort: {{ .Values.service.ports.frontend.targetPort }} - protocol: {{ .Values.service.ports.frontend.protocol }} - name: {{ .Values.service.ports.frontend.name }} - - port: {{ .Values.service.ports.admin.port }} + - name: admin + protocol: TCP + port: {{ .Values.service.ports.admin.port }} targetPort: {{ .Values.service.ports.admin.targetPort }} - protocol: {{ .Values.service.ports.admin.protocol }} - name: {{ .Values.service.ports.admin.name }} - - port: {{ .Values.service.ports.backend.port }} + - name: backend + protocol: TCP + port: {{ .Values.service.ports.backend.port }} targetPort: {{ .Values.service.ports.backend.targetPort }} - protocol: {{ .Values.service.ports.backend.protocol }} - name: {{ .Values.service.ports.backend.name }} {{- end }} - + selector: - app: {{ .Values.service.selector.app }} \ No newline at end of file + app: {{ .Release.Name }}-community diff --git a/charts/shc/values.yaml b/charts/shc/values.yaml index 4d812da..1a885dc 100644 --- a/charts/shc/values.yaml +++ b/charts/shc/values.yaml @@ -102,10 +102,6 @@ community: # Service configuration service: - apiVersion: v1 - name: hoppscotch-community - app: hoppscotch-community - # Dynamically set based on ingress type: "{{ .Values.service.ingress.enabled | ternary \"ClusterIP\" \"LoadBalancer\" }}" cloud: provider: "" # gke, aws, azure @@ -118,23 +114,15 @@ service: backend: port: 3170 targetPort: 3170 - protocol: TCP - name: backend frontend: port: 3000 targetPort: 3000 - protocol: TCP - name: frontend admin: port: 3100 targetPort: 3100 - protocol: TCP - name: admin subpath: port: 80 targetPort: 80 - protocol: TCP - name: subpath selector: app: hoppscotch-community From 00d6cd300c2e25407248fab011b342185b6839dd Mon Sep 17 00:00:00 2001 From: AlePini Date: Tue, 25 Mar 2025 12:03:36 +0100 Subject: [PATCH 2/7] fix: removed leftover --- charts/shc/values.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/charts/shc/values.yaml b/charts/shc/values.yaml index 1a885dc..5b9b5d1 100644 --- a/charts/shc/values.yaml +++ b/charts/shc/values.yaml @@ -123,8 +123,6 @@ service: subpath: port: 80 targetPort: 80 - selector: - app: hoppscotch-community # Ingress Configuration ingress: From ade63e8465881b1ac3e91607a8116428d8ec4bdc Mon Sep 17 00:00:00 2001 From: AlePini Date: Tue, 25 Mar 2025 15:13:21 +0100 Subject: [PATCH 3/7] feat: set ingress name same as service --- charts/shc/templates/ingress.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/charts/shc/templates/ingress.yaml b/charts/shc/templates/ingress.yaml index e655187..0a131be 100644 --- a/charts/shc/templates/ingress.yaml +++ b/charts/shc/templates/ingress.yaml @@ -3,7 +3,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: {{ .Values.service.name }} + name: {{ .Release.Name }}-community annotations: {{- if .Values.service.cloud.provider | eq "gke" }} networking.gke.io/load-balancer-type: "External" @@ -47,21 +47,21 @@ spec: pathType: Prefix backend: service: - name: {{ .Values.service.name }} + name: {{ .Release.Name }}-community port: number: {{ .Values.service.ports.subpath.port }} - path: /backend pathType: Prefix backend: service: - name: {{ .Values.service.name }} + name: {{ .Release.Name }}-community port: number: {{ .Values.service.ports.subpath.port }} - path: /admin pathType: Prefix backend: service: - name: {{ .Values.service.name }} + name: {{ .Release.Name }}-community port: number: {{ .Values.service.ports.subpath.port }} {{- else }} @@ -73,7 +73,7 @@ spec: pathType: Prefix backend: service: - name: {{ .Values.service.name }} + name: {{ .Release.Name }}-community port: number: 3000 @@ -84,7 +84,7 @@ spec: pathType: Prefix backend: service: - name: {{ .Values.service.name }} + name: {{ .Release.Name }}-community port: number: 3100 @@ -95,7 +95,7 @@ spec: pathType: Prefix backend: service: - name: {{ .Values.service.name }} + name: {{ .Release.Name }}-community port: number: 3170 {{- end }} From 41519e9af2e7aa865c622209afcabaa8b2975a27 Mon Sep 17 00:00:00 2001 From: AlePini Date: Tue, 25 Mar 2025 15:24:04 +0100 Subject: [PATCH 4/7] feat: simpler url configuration --- charts/shc/templates/configmap.yaml | 23 +++++++++++++++-------- charts/shc/values.yaml | 17 +++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/charts/shc/templates/configmap.yaml b/charts/shc/templates/configmap.yaml index 423b256..bab3d7a 100644 --- a/charts/shc/templates/configmap.yaml +++ b/charts/shc/templates/configmap.yaml @@ -33,14 +33,21 @@ data: DATA_ENCRYPTION_KEY: {{ .Values.community.config.authjwt.dataEncryptionKey | quote }} # URLs and Frontend Config - VITE_BASE_URL: {{ .Values.community.config.urls.base | quote }} - VITE_SHORTCODE_BASE_URL: {{ .Values.community.config.urls.shortcode | quote }} - VITE_ADMIN_URL: {{ .Values.community.config.urls.admin | quote }} - VITE_BACKEND_GQL_URL: {{ .Values.community.config.urls.backend.gql | quote }} - VITE_BACKEND_WS_URL: {{ .Values.community.config.urls.backend.ws | quote }} - VITE_BACKEND_API_URL: {{ .Values.community.config.urls.backend.api | quote }} - REDIRECT_URL: {{ .Values.community.config.urls.redirect | quote }} - WHITELISTED_ORIGINS: {{ .Values.community.config.urls.whitelistedOrigins | quote }} + {{ $protocol := .Values.community.config.urls.https | ternary "https" "http" -}} + {{- $base_url := printf "%s://%s" $protocol .Values.service.ingress.mainHost -}} + {{- $admin_url := printf "%s://%s" $protocol ( .Values.community.config.community.enableSubpathBasedAccess | ternary (printf "%s/admin" .Values.service.ingress.mainHost) .Values.service.ingress.adminHost ) -}} + {{- $backend_url := .Values.community.config.community.enableSubpathBasedAccess | ternary (printf "%s/backend" .Values.service.ingress.mainHost) .Values.service.ingress.backendHost -}} + {{- $http_backend_url := printf "%s://%s" $protocol $backend_url -}} + {{- $app_url := printf "app://%s" (.Values.service.ingress.mainHost | replace "." "_") -}} + + VITE_BASE_URL: {{ .Values.community.config.urls.base | default $base_url | quote }} + VITE_SHORTCODE_BASE_URL: {{ .Values.community.config.urls.shortcode | default $base_url | quote }} + REDIRECT_URL: {{ .Values.community.config.urls.base | default $base_url | quote }} + VITE_ADMIN_URL: {{ .Values.community.config.urls.admin | default $admin_url | quote }} + VITE_BACKEND_GQL_URL: {{ .Values.community.config.urls.backend.gql | default (printf "%s/graphql" $http_backend_url) | quote }} + VITE_BACKEND_WS_URL: {{ .Values.community.config.urls.backend.ws | default (printf "ws://%s/graphql" $backend_url) | quote }} + VITE_BACKEND_API_URL: {{ .Values.community.config.urls.backend.api | default (printf "%s/v1" $http_backend_url) | quote }} + WHITELISTED_ORIGINS: {{ printf "%s,%s,%s,%s,%s" $base_url $admin_url $http_backend_url $app_url (.Values.community.config.urls.whitelistedOrigins | default "") | quote }} # Google Auth GOOGLE_CLIENT_ID: {{ .Values.community.config.auth.google.clientId | quote }} diff --git a/charts/shc/values.yaml b/charts/shc/values.yaml index 5b9b5d1..f3f4cbe 100644 --- a/charts/shc/values.yaml +++ b/charts/shc/values.yaml @@ -61,15 +61,16 @@ community: dataEncryptionKey: "data encryption key with 32 char" urls: - base: "http://frontend.example.com" - shortcode: "http://frontend.example.com" - admin: "http://admin.example.com" + https: true + base: "" # "http://frontend.example.com" + shortcode: "" # "http://frontend.example.com" + admin: "" # "http://admin.example.com" backend: - gql: "http://backend.example.com/graphql" - ws: "ws://backend.example.com/graphql" - api: "http://backend.example.com/v1" - redirect: "http://frontend.example.com" - whitelistedOrigins: "http://backend.example.com,http://frontend.example.com,http://admin.example.com" + gql: "" # "http://backend.example.com/graphql" + ws: "" # "ws://backend.example.com/graphql" + api: "" # "http://backend.example.com/v1" + redirect: "" # "http://frontend.example.com" + whitelistedOrigins: "" # "http://backend.example.com,http://frontend.example.com,http://admin.example.com" auth: allowedProviders: "GOOGLE,MICROSOFT,GITHUB,EMAIL" From 48c9eaf4a865588e16549958bcf3f7e08907a706 Mon Sep 17 00:00:00 2001 From: AlePini Date: Thu, 27 Mar 2025 15:13:44 +0100 Subject: [PATCH 5/7] feat: use wss when ssl is enabled --- charts/shc/templates/configmap.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/shc/templates/configmap.yaml b/charts/shc/templates/configmap.yaml index bab3d7a..cfa1ae4 100644 --- a/charts/shc/templates/configmap.yaml +++ b/charts/shc/templates/configmap.yaml @@ -34,6 +34,7 @@ data: # URLs and Frontend Config {{ $protocol := .Values.community.config.urls.https | ternary "https" "http" -}} + {{ $wsprotocol := .Values.community.config.urls.https | ternary "wss" "ws" -}} {{- $base_url := printf "%s://%s" $protocol .Values.service.ingress.mainHost -}} {{- $admin_url := printf "%s://%s" $protocol ( .Values.community.config.community.enableSubpathBasedAccess | ternary (printf "%s/admin" .Values.service.ingress.mainHost) .Values.service.ingress.adminHost ) -}} {{- $backend_url := .Values.community.config.community.enableSubpathBasedAccess | ternary (printf "%s/backend" .Values.service.ingress.mainHost) .Values.service.ingress.backendHost -}} @@ -45,7 +46,7 @@ data: REDIRECT_URL: {{ .Values.community.config.urls.base | default $base_url | quote }} VITE_ADMIN_URL: {{ .Values.community.config.urls.admin | default $admin_url | quote }} VITE_BACKEND_GQL_URL: {{ .Values.community.config.urls.backend.gql | default (printf "%s/graphql" $http_backend_url) | quote }} - VITE_BACKEND_WS_URL: {{ .Values.community.config.urls.backend.ws | default (printf "ws://%s/graphql" $backend_url) | quote }} + VITE_BACKEND_WS_URL: {{ .Values.community.config.urls.backend.ws | default (printf "%s://%s/graphql" $wsprotocol $backend_url) | quote }} VITE_BACKEND_API_URL: {{ .Values.community.config.urls.backend.api | default (printf "%s/v1" $http_backend_url) | quote }} WHITELISTED_ORIGINS: {{ printf "%s,%s,%s,%s,%s" $base_url $admin_url $http_backend_url $app_url (.Values.community.config.urls.whitelistedOrigins | default "") | quote }} From b383f90b89a5ae65ffaf4cef68355269283a8aea Mon Sep 17 00:00:00 2001 From: AlePini Date: Thu, 27 Mar 2025 18:03:33 +0100 Subject: [PATCH 6/7] fix: updated app url in whitelist --- charts/shc/templates/configmap.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/shc/templates/configmap.yaml b/charts/shc/templates/configmap.yaml index cfa1ae4..ad72424 100644 --- a/charts/shc/templates/configmap.yaml +++ b/charts/shc/templates/configmap.yaml @@ -39,7 +39,8 @@ data: {{- $admin_url := printf "%s://%s" $protocol ( .Values.community.config.community.enableSubpathBasedAccess | ternary (printf "%s/admin" .Values.service.ingress.mainHost) .Values.service.ingress.adminHost ) -}} {{- $backend_url := .Values.community.config.community.enableSubpathBasedAccess | ternary (printf "%s/backend" .Values.service.ingress.mainHost) .Values.service.ingress.backendHost -}} {{- $http_backend_url := printf "%s://%s" $protocol $backend_url -}} - {{- $app_url := printf "app://%s" (.Values.service.ingress.mainHost | replace "." "_") -}} + {{- $url_underscore := (.Values.service.ingress.mainHost | replace "." "_") -}} + {{- $app_url := printf "app://%s,http://app.%s" $url_underscore $url_underscore -}} VITE_BASE_URL: {{ .Values.community.config.urls.base | default $base_url | quote }} VITE_SHORTCODE_BASE_URL: {{ .Values.community.config.urls.shortcode | default $base_url | quote }} From 545e5f24ed70f5156d8c9bca010d33a1e7dd0fc7 Mon Sep 17 00:00:00 2001 From: Jakob Stadlhuber Date: Thu, 10 Apr 2025 15:24:22 +0200 Subject: [PATCH 7/7] Set service type dynamically based on values (#1) Updated the service template to use `.Values.service.type` directly instead of a ternary operation. This change ensures better flexibility and aligns with user-defined configurations, particularly for LoadBalancer settings. --- charts/shc/templates/service.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/shc/templates/service.yaml b/charts/shc/templates/service.yaml index 76d8692..af0b1c9 100644 --- a/charts/shc/templates/service.yaml +++ b/charts/shc/templates/service.yaml @@ -20,9 +20,9 @@ metadata: service.kubernetes.io/load-balancer-type: "External" {{- end }} spec: - type: {{ ternary "ClusterIP" "LoadBalancer" .Values.service.ingress.enabled }} - - {{- if not .Values.service.ingress.enabled }} + type: {{ .Values.service.type }} + + {{- if eq .Values.service.type "LoadBalancer" }} loadBalancerIP: {{ .Values.global.externalIP }} externalTrafficPolicy: Cluster {{- end }}