From ad608c93acee325bde3573fd643b142cfc2470a5 Mon Sep 17 00:00:00 2001 From: Iain Sproat <68657+iainsproat@users.noreply.github.com> Date: Fri, 21 Jun 2024 15:11:04 +0100 Subject: [PATCH 1/2] feat(preview-service): allow metrics port to be configured --- packages/preview-service/bin/www | 2 +- .../templates/preview_service/deployment.yml | 5 +++++ .../templates/preview_service/service.yml | 2 +- utils/helm/speckle-server/values.schema.json | 10 ++++++++++ utils/helm/speckle-server/values.yaml | 4 ++++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/preview-service/bin/www b/packages/preview-service/bin/www index c075d2132e..aff48a6394 100755 --- a/packages/preview-service/bin/www +++ b/packages/preview-service/bin/www @@ -83,7 +83,7 @@ function onError(error) { function onListening() { const addr = server.address() - const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port + const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr?.port serverLogger.info('Listening on ' + bind) startPreviewService() diff --git a/utils/helm/speckle-server/templates/preview_service/deployment.yml b/utils/helm/speckle-server/templates/preview_service/deployment.yml index 9d022d955b..e723f0faa8 100644 --- a/utils/helm/speckle-server/templates/preview_service/deployment.yml +++ b/utils/helm/speckle-server/templates/preview_service/deployment.yml @@ -76,6 +76,11 @@ spec: value: "/postgres-certificate/ca-certificate.crt" {{- end }} + {{- if .Values.preview_service.monitoring.metricsPort -}} + - name: PROMETHEUS_METRICS_PORT + value: {{ .Values.preview_service.monitoring.metricsPort | quote }} + {{- end -}} + {{- if .Values.preview_service.affinity }} affinity: {{- include "speckle.renderTpl" (dict "value" .Values.preview_service.affinity "context" $) | nindent 8 }} {{- end }} diff --git a/utils/helm/speckle-server/templates/preview_service/service.yml b/utils/helm/speckle-server/templates/preview_service/service.yml index 37f423fa70..41d1fc579e 100644 --- a/utils/helm/speckle-server/templates/preview_service/service.yml +++ b/utils/helm/speckle-server/templates/preview_service/service.yml @@ -12,5 +12,5 @@ spec: ports: - protocol: TCP name: web - port: 9094 + port: {{ .Values.preview_service.monitoring.metricsPort }} targetPort: metrics diff --git a/utils/helm/speckle-server/values.schema.json b/utils/helm/speckle-server/values.schema.json index 5720b2887c..7952f20846 100644 --- a/utils/helm/speckle-server/values.schema.json +++ b/utils/helm/speckle-server/values.schema.json @@ -1601,6 +1601,16 @@ "description": "The Docker image to be used for the Speckle Preview Service component. If blank, defaults to speckle/speckle-preview-service:{{ .Values.docker_image_tag }}. If provided, this value should be the full path including tag. The docker_image_tag value will be ignored.", "default": "" }, + "monitoring": { + "type": "object", + "properties": { + "metricsPort": { + "type": "string", + "description": "The port on which the metrics server will be exposed. Defaults to 9094 if left blank.", + "default": "" + } + } + }, "requests": { "type": "object", "properties": { diff --git a/utils/helm/speckle-server/values.yaml b/utils/helm/speckle-server/values.yaml index 7e82021672..bed6826c62 100644 --- a/utils/helm/speckle-server/values.yaml +++ b/utils/helm/speckle-server/values.yaml @@ -1022,6 +1022,10 @@ preview_service: ## image: '' + monitoring: + ## @param preview_service.monitoring.metricsPort The port on which the metrics server will be exposed. Defaults to 9094 if left blank. + metricsPort: '' # blank to use default of 9094 + requests: ## @param preview_service.requests.cpu The CPU that should be available on a node when scheduling this pod. ## ref: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ From 3ea25c12930f99731d1b2d6a9c595bdd03dde0bd Mon Sep 17 00:00:00 2001 From: Iain Sproat <68657+iainsproat@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:05:37 +0100 Subject: [PATCH 2/2] Allow configurable port --- .../templates/preview_service/deployment.yml | 13 +++++++------ utils/helm/speckle-server/values.schema.json | 9 +++++++-- utils/helm/speckle-server/values.yaml | 7 +++++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/utils/helm/speckle-server/templates/preview_service/deployment.yml b/utils/helm/speckle-server/templates/preview_service/deployment.yml index e723f0faa8..f7cf8ed581 100644 --- a/utils/helm/speckle-server/templates/preview_service/deployment.yml +++ b/utils/helm/speckle-server/templates/preview_service/deployment.yml @@ -25,7 +25,7 @@ spec: ports: - name: metrics - containerPort: 9094 + containerPort: {{ .Values.preview_service.monitoring.metricsPort }} protocol: TCP livenessProbe: @@ -62,6 +62,12 @@ spec: {{- end }} env: + - name: PORT + value: {{ .Values.preview_service.port | quote }} + + - name: PROMETHEUS_METRICS_PORT + value: {{ .Values.preview_service.monitoring.metricsPort | quote }} + - name: PG_CONNECTION_STRING valueFrom: secretKeyRef: @@ -76,11 +82,6 @@ spec: value: "/postgres-certificate/ca-certificate.crt" {{- end }} - {{- if .Values.preview_service.monitoring.metricsPort -}} - - name: PROMETHEUS_METRICS_PORT - value: {{ .Values.preview_service.monitoring.metricsPort | quote }} - {{- end -}} - {{- if .Values.preview_service.affinity }} affinity: {{- include "speckle.renderTpl" (dict "value" .Values.preview_service.affinity "context" $) | nindent 8 }} {{- end }} diff --git a/utils/helm/speckle-server/values.schema.json b/utils/helm/speckle-server/values.schema.json index 7952f20846..ac2c5940fb 100644 --- a/utils/helm/speckle-server/values.schema.json +++ b/utils/helm/speckle-server/values.schema.json @@ -1601,13 +1601,18 @@ "description": "The Docker image to be used for the Speckle Preview Service component. If blank, defaults to speckle/speckle-preview-service:{{ .Values.docker_image_tag }}. If provided, this value should be the full path including tag. The docker_image_tag value will be ignored.", "default": "" }, + "port": { + "type": "string", + "description": "The port on which the Preview Service will run. This is not exposed, but used within its own local network within the pod.", + "default": "3001" + }, "monitoring": { "type": "object", "properties": { "metricsPort": { "type": "string", - "description": "The port on which the metrics server will be exposed. Defaults to 9094 if left blank.", - "default": "" + "description": "The port on which the metrics server will be exposed.", + "default": "9094" } } }, diff --git a/utils/helm/speckle-server/values.yaml b/utils/helm/speckle-server/values.yaml index bed6826c62..5e8342780b 100644 --- a/utils/helm/speckle-server/values.yaml +++ b/utils/helm/speckle-server/values.yaml @@ -1022,9 +1022,12 @@ preview_service: ## image: '' + ## @param preview_service.port The port on which the Preview Service will run. This is not exposed, but used within its own local network within the pod. + port: '3001' + monitoring: - ## @param preview_service.monitoring.metricsPort The port on which the metrics server will be exposed. Defaults to 9094 if left blank. - metricsPort: '' # blank to use default of 9094 + ## @param preview_service.monitoring.metricsPort The port on which the metrics server will be exposed. + metricsPort: '9094' requests: ## @param preview_service.requests.cpu The CPU that should be available on a node when scheduling this pod.