This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-9452-a915d6b7099a2dec7f37ffa3b91d22c77a00841b in repository https://gitbox.apache.org/repos/asf/texera.git
commit 68e1f384ac12f353f7184e48e4699c5e99eb0b5d Author: Xinyuan Lin <[email protected]> AuthorDate: Mon Nov 16 22:06:47 2026 +0000 refactor(k8s): share Helm resource templates (#9452) ### What changes were proposed in this PR? Share templates for nine release Services, the five observability workloads and their Services and claims, and the PostgreSQL and RustFS local volumes and claims. Service settings, workload specs, and persistence enablement and defaults stay with their callers. The change removes 261 net lines across 17 chart files. ### Any related issues, documentation, discussions? Closes #9451. ### How was this PR tested? Ran `bash bin/k8s/tests/test_helm_values.sh` and `helm lint bin/k8s -f <profile.yaml>` with default, NodePort, observability, and local persistence values. Compared baseline and branch renders using Helm 3.17.3 and identical chart dependencies: ```sh helm template audit-defaults bin/k8s -n ns-defaults -f defaults.yaml helm template audit-services-nodeport bin/k8s -n ns-services-nodeport -f services-NodePort.yaml helm template audit-observability-all bin/k8s -n ns-observability-all -f observability-all.yaml helm template audit-persistence-2 bin/k8s -n ns-persistence-2 -f persistence-2.yaml ``` The fixture values make generated credentials deterministic and exercise named ports, observability enablement, and local volume binding. All 31 profiles matched across 3,880 rendered resources, including the development and AWS values. Deliberately changing the Service target port, claim access mode, or Deployment strategy produced the expected differences. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Codex (GPT-6) --- bin/k8s/templates/base/_helpers.tpl | 162 +++++++++++++++++++++ .../access-control-service-service.yaml | 14 +- .../base/agent-service/agent-service-service.yaml | 14 +- .../config-service/config-service-service.yaml | 14 +- .../base/file-service/file-service-service.yaml | 19 +-- .../templates/base/litellm/litellm-service.yaml | 14 +- .../notebook-migration-service-service.yaml | 14 +- bin/k8s/templates/base/observability/grafana.yaml | 41 +----- bin/k8s/templates/base/observability/jaeger.yaml | 46 +----- bin/k8s/templates/base/observability/loki.yaml | 61 +------- .../base/observability/otel-collector.yaml | 47 +----- .../base/observability/victoriametrics.yaml | 61 +------- .../base/postgresql/postgresql-persistence.yaml | 61 +------- .../base/webserver/webserver-service.yaml | 19 +-- .../workflow-compiling-service-service.yaml | 19 +-- .../workflow-computing-unit-manager-service.yaml | 18 +-- bin/k8s/templates/on-prem/rustfs-persistence.yaml | 61 +------- 17 files changed, 212 insertions(+), 473 deletions(-) diff --git a/bin/k8s/templates/base/_helpers.tpl b/bin/k8s/templates/base/_helpers.tpl index 8f31082385..f7e724ff8a 100644 --- a/bin/k8s/templates/base/_helpers.tpl +++ b/bin/k8s/templates/base/_helpers.tpl @@ -103,6 +103,83 @@ append the uid to it, so a bare value would render "http://<origin>jupyter/7". * {{- printf "/%s" (trimAll "/" .Values.jupyterPool.basePath) -}} {{- end -}} +{{/* Start a release-scoped Deployment; the caller supplies the pod spec. */}} +{{- define "texera.deploymentHeader" -}} +{{- $app := printf "%s-" .release.Name -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ $app }}{{ .name }} + namespace: {{ .release.Namespace }} + labels: + app: {{ $app }}{{ .name }} +spec: + replicas: {{ .replicas }} + {{- if .recreate }} + # Single writer bound to one RWO volume; never run two at once. + strategy: + type: Recreate + {{- end }} + selector: + matchLabels: + app: {{ $app }}{{ .name }} + template: + metadata: + labels: + app: {{ $app }}{{ .name }} +{{- end -}} + +{{- define "texera.observability.containerSecurityContext" -}} +securityContext: + {{- if . }} + readOnlyRootFilesystem: true + {{- end }} + allowPrivilegeEscalation: false + capabilities: + drop: ["ALL"] +{{- end -}} + +{{- define "texera.observability.service" -}} +{{- $app := printf "%s-%s" .release.Name .app -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ $app }} + namespace: {{ .release.Namespace }} + labels: + app: {{ $app }} +spec: + type: ClusterIP + selector: + app: {{ $app }} + ports: + {{- range .ports }} + - name: {{ .name }} + protocol: TCP + port: {{ .port }} + targetPort: {{ .port }} + {{- end }} +{{- end -}} + +{{- define "texera.observability.dataClaim" -}} +{{- $app := printf "%s-%s" .release.Name .app -}} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ $app }}-data + namespace: {{ .release.Namespace }} + labels: + app: {{ $app }} +spec: + accessModes: ["ReadWriteOnce"] + {{- if .storage.storageClass }} + storageClassName: {{ .storage.storageClass }} + {{- end }} + resources: + requests: + storage: {{ .storage.storage }} +{{- end -}} + {{/* Grafana datasource provisioning body. Kept as a helper so the Deployment's checksum/config annotation can hash just this content; hashing the template that holds the annotation would make it reference itself and recurse. */}} @@ -181,3 +258,88 @@ compactor: retention_enabled: true delete_request_store: filesystem {{- end -}} +{{- define "texera.releaseService" -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ .name }}-svc + namespace: {{ .release.Namespace }} +spec: + type: {{ .serviceType }} + selector: + app: {{ .release.Name }}-{{ .name }} + ports: + {{- if .portName }} + - name: {{ .portName }} + protocol: TCP + {{- else }} + - protocol: TCP + {{- end }} + port: {{ .port }} + targetPort: {{ .port }} + {{- if .useNodePort }} + # if service type is set to NodePort, include nodePort attribute + {{- if eq .serviceType "NodePort" }} + nodePort: {{ .nodePort }} + {{- end }} + {{- end }} +{{- end -}} + +{{- define "texera.localPersistence" -}} +{{- $hostBasePath := .hostBasePath }} +{{- $name := .name }} +{{- $persistence := .persistence }} +{{- $volumeName := printf "%s-data-pv" $name }} +{{- $claimName := printf "%s-data-pvc" $name }} +{{- $storageClass := $persistence.storageClass | default "local-path" }} +{{- $size := $persistence.size | default .defaultSize }} +{{- $hostPath := printf "%s/%s/%s" $hostBasePath $.root.Release.Name $name }} + +{{/* Only create PV for local-path storage class */}} +{{- if and (eq $storageClass "local-path") (ne $hostBasePath "") }} +apiVersion: v1 +kind: PersistentVolume +metadata: + name: {{ $volumeName }} + {{- if not $.root.Values.persistence.removeAfterUninstall }} + annotations: + "helm.sh/resource-policy": keep + {{- end }} + labels: + type: local + app: {{ $.root.Release.Name }} + component: {{ $name }} +spec: + storageClassName: {{ $storageClass }} + capacity: + storage: {{ $size }} + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + hostPath: + path: {{ $hostPath }} +--- +{{- end }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ $claimName }} + namespace: {{ $.root.Release.Namespace }} + {{- if not $.root.Values.persistence.removeAfterUninstall }} + annotations: + "helm.sh/resource-policy": keep + {{- end }} + labels: + app: {{ $.root.Release.Name }} + component: {{ $name }} +spec: + storageClassName: {{ $storageClass }} + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ $size }} + {{- if and (eq $storageClass "local-path") (ne $hostBasePath "") }} + volumeName: {{ $volumeName }} + {{- end }} +{{- end }} diff --git a/bin/k8s/templates/base/access-control-service/access-control-service-service.yaml b/bin/k8s/templates/base/access-control-service/access-control-service-service.yaml index 4c2137456a..f04b9a88d2 100644 --- a/bin/k8s/templates/base/access-control-service/access-control-service-service.yaml +++ b/bin/k8s/templates/base/access-control-service/access-control-service-service.yaml @@ -15,16 +15,4 @@ # specific language governing permissions and limitations # under the License. -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.accessControlService.name }}-svc - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.accessControlService.service.type }} - selector: - app: {{ .Release.Name }}-{{ .Values.accessControlService.name }} - ports: - - protocol: TCP - port: {{ .Values.accessControlService.service.port }} - targetPort: {{ .Values.accessControlService.service.port }} +{{ include "texera.releaseService" (dict "release" .Release "name" .Values.accessControlService.name "serviceType" .Values.accessControlService.service.type "port" .Values.accessControlService.service.port) }} diff --git a/bin/k8s/templates/base/agent-service/agent-service-service.yaml b/bin/k8s/templates/base/agent-service/agent-service-service.yaml index 581716bf80..204bb2fa75 100644 --- a/bin/k8s/templates/base/agent-service/agent-service-service.yaml +++ b/bin/k8s/templates/base/agent-service/agent-service-service.yaml @@ -16,17 +16,5 @@ # under the License. {{- if .Values.agentService.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.agentService.name }}-svc - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.agentService.service.type }} - selector: - app: {{ .Release.Name }}-{{ .Values.agentService.name }} - ports: - - protocol: TCP - port: {{ .Values.agentService.service.port }} - targetPort: {{ .Values.agentService.service.port }} +{{ include "texera.releaseService" (dict "release" .Release "name" .Values.agentService.name "serviceType" .Values.agentService.service.type "port" .Values.agentService.service.port) }} {{- end }} diff --git a/bin/k8s/templates/base/config-service/config-service-service.yaml b/bin/k8s/templates/base/config-service/config-service-service.yaml index 8ae32f774f..ab9afa2d20 100644 --- a/bin/k8s/templates/base/config-service/config-service-service.yaml +++ b/bin/k8s/templates/base/config-service/config-service-service.yaml @@ -15,16 +15,4 @@ # specific language governing permissions and limitations # under the License. -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.configService.name }}-svc - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.configService.service.type }} - selector: - app: {{ .Release.Name }}-{{ .Values.configService.name }} - ports: - - protocol: TCP - port: {{ .Values.configService.service.port }} - targetPort: {{ .Values.configService.service.port }} \ No newline at end of file +{{ include "texera.releaseService" (dict "release" .Release "name" .Values.configService.name "serviceType" .Values.configService.service.type "port" .Values.configService.service.port) }} diff --git a/bin/k8s/templates/base/file-service/file-service-service.yaml b/bin/k8s/templates/base/file-service/file-service-service.yaml index f4eaf6796b..b0780dd200 100644 --- a/bin/k8s/templates/base/file-service/file-service-service.yaml +++ b/bin/k8s/templates/base/file-service/file-service-service.yaml @@ -15,21 +15,4 @@ # specific language governing permissions and limitations # under the License. -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.fileService.name }}-svc - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.fileService.service.type }} - selector: - app: {{ .Release.Name }}-{{ .Values.fileService.name }} - ports: - - name: api-port - protocol: TCP - port: {{ .Values.fileService.service.port }} - targetPort: {{ .Values.fileService.service.port }} - # if service type is set to NodePort, include nodePort attribute - {{- if eq .Values.fileService.service.type "NodePort" }} - nodePort: {{ .Values.fileService.service.nodePort }} - {{- end }} \ No newline at end of file +{{ include "texera.releaseService" (dict "release" .Release "name" .Values.fileService.name "serviceType" .Values.fileService.service.type "port" .Values.fileService.service.port "nodePort" .Values.fileService.service.nodePort "portName" "api-port" "useNodePort" true) }} diff --git a/bin/k8s/templates/base/litellm/litellm-service.yaml b/bin/k8s/templates/base/litellm/litellm-service.yaml index 875bdd08f1..74411ac45e 100644 --- a/bin/k8s/templates/base/litellm/litellm-service.yaml +++ b/bin/k8s/templates/base/litellm/litellm-service.yaml @@ -16,17 +16,5 @@ # under the License. {{- if .Values.litellm.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.litellm.name }}-svc - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.litellm.service.type }} - selector: - app: {{ .Release.Name }}-{{ .Values.litellm.name }} - ports: - - protocol: TCP - port: {{ .Values.litellm.service.port }} - targetPort: {{ .Values.litellm.service.port }} +{{ include "texera.releaseService" (dict "release" .Release "name" .Values.litellm.name "serviceType" .Values.litellm.service.type "port" .Values.litellm.service.port) }} {{- end }} diff --git a/bin/k8s/templates/base/notebook-migration-service/notebook-migration-service-service.yaml b/bin/k8s/templates/base/notebook-migration-service/notebook-migration-service-service.yaml index d13a2d4799..e5b1bafe93 100644 --- a/bin/k8s/templates/base/notebook-migration-service/notebook-migration-service-service.yaml +++ b/bin/k8s/templates/base/notebook-migration-service/notebook-migration-service-service.yaml @@ -15,17 +15,5 @@ # specific language governing permissions and limitations # under the License. {{- if .Values.notebookMigrationService.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.notebookMigrationService.name }}-svc - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.notebookMigrationService.service.type }} - selector: - app: {{ .Release.Name }}-{{ .Values.notebookMigrationService.name }} - ports: - - protocol: TCP - port: {{ .Values.notebookMigrationService.service.port }} - targetPort: {{ .Values.notebookMigrationService.service.port }} +{{ include "texera.releaseService" (dict "release" .Release "name" .Values.notebookMigrationService.name "serviceType" .Values.notebookMigrationService.service.type "port" .Values.notebookMigrationService.service.port) }} {{- end }} diff --git a/bin/k8s/templates/base/observability/grafana.yaml b/bin/k8s/templates/base/observability/grafana.yaml index 36b1e05fe3..cc0c7a8d56 100644 --- a/bin/k8s/templates/base/observability/grafana.yaml +++ b/bin/k8s/templates/base/observability/grafana.yaml @@ -37,22 +37,7 @@ data: datasources.yaml: | {{- include "texera.observability.grafanaDatasources" . | nindent 4 }} --- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ .Release.Name }}-grafana - namespace: {{ .Release.Namespace }} - labels: - app: {{ .Release.Name }}-grafana -spec: - replicas: 1 - selector: - matchLabels: - app: {{ .Release.Name }}-grafana - template: - metadata: - labels: - app: {{ .Release.Name }}-grafana +{{ include "texera.deploymentHeader" (dict "release" .Release "name" "grafana" "replicas" 1) }} annotations: # Roll the pod when the provisioned datasources change. checksum/config: {{ include "texera.observability.grafanaDatasources" . | sha256sum }} @@ -65,10 +50,7 @@ spec: - name: grafana image: {{ .Values.observability.grafana.image }} imagePullPolicy: {{ .Values.texeraImages.pullPolicy }} - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: ["ALL"] + {{- include "texera.observability.containerSecurityContext" false | nindent 10 }} env: # Admin login. Override for any environment reachable beyond # an internal port-forward. @@ -106,20 +88,7 @@ spec: - name: data emptyDir: {} --- -apiVersion: v1 -kind: Service -metadata: - name: {{ .Release.Name }}-grafana - namespace: {{ .Release.Namespace }} - labels: - app: {{ .Release.Name }}-grafana -spec: - type: ClusterIP - selector: - app: {{ .Release.Name }}-grafana - ports: - - name: http - protocol: TCP - port: {{ .Values.observability.grafana.port }} - targetPort: {{ .Values.observability.grafana.port }} +{{ include "texera.observability.service" (dict "release" .Release "app" "grafana" "ports" (list + (dict "name" "http" "port" .Values.observability.grafana.port) +)) }} {{- end }} diff --git a/bin/k8s/templates/base/observability/jaeger.yaml b/bin/k8s/templates/base/observability/jaeger.yaml index 2821a97773..685ea50085 100644 --- a/bin/k8s/templates/base/observability/jaeger.yaml +++ b/bin/k8s/templates/base/observability/jaeger.yaml @@ -23,22 +23,7 @@ under the License. # otlpPort). In-memory storage: a restart wipes traces, same as the # single-node compose. Swap in a persistent storage backend for # multi-node / production use. -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ .Release.Name }}-jaeger - namespace: {{ .Release.Namespace }} - labels: - app: {{ .Release.Name }}-jaeger -spec: - replicas: 1 - selector: - matchLabels: - app: {{ .Release.Name }}-jaeger - template: - metadata: - labels: - app: {{ .Release.Name }}-jaeger +{{ include "texera.deploymentHeader" (dict "release" .Release "name" "jaeger" "replicas" 1) }} spec: securityContext: runAsNonRoot: true @@ -46,10 +31,7 @@ spec: - name: jaeger image: {{ .Values.observability.traces.image }} imagePullPolicy: {{ .Values.texeraImages.pullPolicy }} - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: ["ALL"] + {{- include "texera.observability.containerSecurityContext" false | nindent 10 }} ports: - name: query containerPort: {{ .Values.observability.traces.queryPort }} @@ -58,24 +40,8 @@ spec: resources: {{- toYaml .Values.observability.traces.resources | nindent 12 }} --- -apiVersion: v1 -kind: Service -metadata: - name: {{ .Release.Name }}-jaeger - namespace: {{ .Release.Namespace }} - labels: - app: {{ .Release.Name }}-jaeger -spec: - type: ClusterIP - selector: - app: {{ .Release.Name }}-jaeger - ports: - - name: query - protocol: TCP - port: {{ .Values.observability.traces.queryPort }} - targetPort: {{ .Values.observability.traces.queryPort }} - - name: otlp-grpc - protocol: TCP - port: {{ .Values.observability.traces.otlpPort }} - targetPort: {{ .Values.observability.traces.otlpPort }} +{{ include "texera.observability.service" (dict "release" .Release "app" "jaeger" "ports" (list + (dict "name" "query" "port" .Values.observability.traces.queryPort) + (dict "name" "otlp-grpc" "port" .Values.observability.traces.otlpPort) +)) }} {{- end }} diff --git a/bin/k8s/templates/base/observability/loki.yaml b/bin/k8s/templates/base/observability/loki.yaml index d26ca944e2..4c0e7eb823 100644 --- a/bin/k8s/templates/base/observability/loki.yaml +++ b/bin/k8s/templates/base/observability/loki.yaml @@ -34,41 +34,9 @@ data: config.yaml: | {{- include "texera.observability.lokiConfig" . | nindent 4 }} --- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: {{ .Release.Name }}-loki-data - namespace: {{ .Release.Namespace }} - labels: - app: {{ .Release.Name }}-loki -spec: - accessModes: ["ReadWriteOnce"] - {{- if .Values.observability.logs.storageClass }} - storageClassName: {{ .Values.observability.logs.storageClass }} - {{- end }} - resources: - requests: - storage: {{ .Values.observability.logs.storage }} +{{ include "texera.observability.dataClaim" (dict "release" .Release "app" "loki" "storage" .Values.observability.logs) }} --- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ .Release.Name }}-loki - namespace: {{ .Release.Namespace }} - labels: - app: {{ .Release.Name }}-loki -spec: - replicas: 1 - # Single writer bound to one RWO volume; never run two at once. - strategy: - type: Recreate - selector: - matchLabels: - app: {{ .Release.Name }}-loki - template: - metadata: - labels: - app: {{ .Release.Name }}-loki +{{ include "texera.deploymentHeader" (dict "release" .Release "name" "loki" "replicas" 1 "recreate" true) }} annotations: # Roll the pod when the rendered config changes. checksum/config: {{ include "texera.observability.lokiConfig" . | sha256sum }} @@ -82,11 +50,7 @@ spec: image: {{ .Values.observability.logs.image }} imagePullPolicy: {{ .Values.texeraImages.pullPolicy }} args: ["-config.file=/etc/loki/config.yaml"] - securityContext: - readOnlyRootFilesystem: true - allowPrivilegeEscalation: false - capabilities: - drop: ["ALL"] + {{- include "texera.observability.containerSecurityContext" true | nindent 10 }} ports: - name: http containerPort: {{ .Values.observability.logs.port }} @@ -117,20 +81,7 @@ spec: - name: tmp emptyDir: {} --- -apiVersion: v1 -kind: Service -metadata: - name: {{ .Release.Name }}-loki - namespace: {{ .Release.Namespace }} - labels: - app: {{ .Release.Name }}-loki -spec: - type: ClusterIP - selector: - app: {{ .Release.Name }}-loki - ports: - - name: http - protocol: TCP - port: {{ .Values.observability.logs.port }} - targetPort: {{ .Values.observability.logs.port }} +{{ include "texera.observability.service" (dict "release" .Release "app" "loki" "ports" (list + (dict "name" "http" "port" .Values.observability.logs.port) +)) }} {{- end }} diff --git a/bin/k8s/templates/base/observability/otel-collector.yaml b/bin/k8s/templates/base/observability/otel-collector.yaml index 89c537317d..d4455566cd 100644 --- a/bin/k8s/templates/base/observability/otel-collector.yaml +++ b/bin/k8s/templates/base/observability/otel-collector.yaml @@ -22,22 +22,7 @@ under the License. # k8s counterpart of the docker-compose otel-collector service. The # receiver Ports are exposed only on the ClusterIP Service (no Ingress), # mirroring the loopback-only posture of the compose deployment. -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ .Release.Name }}-otel-collector - namespace: {{ .Release.Namespace }} - labels: - app: {{ .Release.Name }}-otel-collector -spec: - replicas: 1 - selector: - matchLabels: - app: {{ .Release.Name }}-otel-collector - template: - metadata: - labels: - app: {{ .Release.Name }}-otel-collector +{{ include "texera.deploymentHeader" (dict "release" .Release "name" "otel-collector" "replicas" 1) }} annotations: # Roll the pod when the rendered config changes. checksum/config: {{ include (print $.Template.BasePath "/base/observability/otel-collector-configmap.yaml") . | sha256sum }} @@ -51,11 +36,7 @@ spec: image: {{ .Values.observability.collector.image }} imagePullPolicy: {{ .Values.texeraImages.pullPolicy }} args: ["--config=/etc/otelcol-contrib/config.yaml"] - securityContext: - readOnlyRootFilesystem: true - allowPrivilegeEscalation: false - capabilities: - drop: ["ALL"] + {{- include "texera.observability.containerSecurityContext" true | nindent 10 }} ports: - name: otlp-grpc containerPort: {{ .Values.observability.collector.grpcPort }} @@ -72,24 +53,8 @@ spec: configMap: name: {{ .Release.Name }}-otel-collector-config --- -apiVersion: v1 -kind: Service -metadata: - name: {{ .Release.Name }}-otel-collector - namespace: {{ .Release.Namespace }} - labels: - app: {{ .Release.Name }}-otel-collector -spec: - type: ClusterIP - selector: - app: {{ .Release.Name }}-otel-collector - ports: - - name: otlp-grpc - protocol: TCP - port: {{ .Values.observability.collector.grpcPort }} - targetPort: {{ .Values.observability.collector.grpcPort }} - - name: otlp-http - protocol: TCP - port: {{ .Values.observability.collector.httpPort }} - targetPort: {{ .Values.observability.collector.httpPort }} +{{ include "texera.observability.service" (dict "release" .Release "app" "otel-collector" "ports" (list + (dict "name" "otlp-grpc" "port" .Values.observability.collector.grpcPort) + (dict "name" "otlp-http" "port" .Values.observability.collector.httpPort) +)) }} {{- end }} diff --git a/bin/k8s/templates/base/observability/victoriametrics.yaml b/bin/k8s/templates/base/observability/victoriametrics.yaml index 5a6a1ea97b..7e2ba427b1 100644 --- a/bin/k8s/templates/base/observability/victoriametrics.yaml +++ b/bin/k8s/templates/base/observability/victoriametrics.yaml @@ -21,41 +21,9 @@ under the License. # VictoriaMetrics: metrics store, k8s counterpart of the docker-compose # victoriametrics service. Accepts Prometheus remote-write from the # collector; MetricsQL query API on the same port. -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: {{ .Release.Name }}-victoriametrics-data - namespace: {{ .Release.Namespace }} - labels: - app: {{ .Release.Name }}-victoriametrics -spec: - accessModes: ["ReadWriteOnce"] - {{- if .Values.observability.metrics.storageClass }} - storageClassName: {{ .Values.observability.metrics.storageClass }} - {{- end }} - resources: - requests: - storage: {{ .Values.observability.metrics.storage }} +{{ include "texera.observability.dataClaim" (dict "release" .Release "app" "victoriametrics" "storage" .Values.observability.metrics) }} --- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ .Release.Name }}-victoriametrics - namespace: {{ .Release.Namespace }} - labels: - app: {{ .Release.Name }}-victoriametrics -spec: - replicas: 1 - # Single writer bound to one RWO volume; never run two at once. - strategy: - type: Recreate - selector: - matchLabels: - app: {{ .Release.Name }}-victoriametrics - template: - metadata: - labels: - app: {{ .Release.Name }}-victoriametrics +{{ include "texera.deploymentHeader" (dict "release" .Release "name" "victoriametrics" "replicas" 1 "recreate" true) }} spec: securityContext: runAsNonRoot: true @@ -69,11 +37,7 @@ spec: - "-storageDataPath=/data" - "-retentionPeriod={{ .Values.observability.metrics.retentionPeriod }}" - "-httpListenAddr=:{{ .Values.observability.metrics.port }}" - securityContext: - readOnlyRootFilesystem: true - allowPrivilegeEscalation: false - capabilities: - drop: ["ALL"] + {{- include "texera.observability.containerSecurityContext" true | nindent 10 }} ports: - name: http containerPort: {{ .Values.observability.metrics.port }} @@ -93,20 +57,7 @@ spec: persistentVolumeClaim: claimName: {{ .Release.Name }}-victoriametrics-data --- -apiVersion: v1 -kind: Service -metadata: - name: {{ .Release.Name }}-victoriametrics - namespace: {{ .Release.Namespace }} - labels: - app: {{ .Release.Name }}-victoriametrics -spec: - type: ClusterIP - selector: - app: {{ .Release.Name }}-victoriametrics - ports: - - name: http - protocol: TCP - port: {{ .Values.observability.metrics.port }} - targetPort: {{ .Values.observability.metrics.port }} +{{ include "texera.observability.service" (dict "release" .Release "app" "victoriametrics" "ports" (list + (dict "name" "http" "port" .Values.observability.metrics.port) +)) }} {{- end }} diff --git a/bin/k8s/templates/base/postgresql/postgresql-persistence.yaml b/bin/k8s/templates/base/postgresql/postgresql-persistence.yaml index edff7463b4..fe50f544e8 100644 --- a/bin/k8s/templates/base/postgresql/postgresql-persistence.yaml +++ b/bin/k8s/templates/base/postgresql/postgresql-persistence.yaml @@ -20,59 +20,10 @@ {{- $hostBasePath := .Values.persistence.postgresqlHostLocalPath }} {{- if .Values.postgresql.primary.persistence.enabled }} -{{- $name := "postgresql" }} -{{- $persistence := .Values.postgresql.primary.persistence }} -{{- $volumeName := printf "%s-data-pv" $name }} -{{- $claimName := printf "%s-data-pvc" $name }} -{{- $storageClass := $persistence.storageClass | default "local-path" }} -{{- $size := $persistence.size | default "10Gi" }} -{{- $hostPath := printf "%s/%s/%s" $hostBasePath $.Release.Name $name }} - -{{/* Only create PV for local-path storage class */}} -{{- if and (eq $storageClass "local-path") (ne $hostBasePath "") }} -apiVersion: v1 -kind: PersistentVolume -metadata: - name: {{ $volumeName }} - {{- if not $.Values.persistence.removeAfterUninstall }} - annotations: - "helm.sh/resource-policy": keep - {{- end }} - labels: - type: local - app: {{ $.Release.Name }} - component: {{ $name }} -spec: - storageClassName: {{ $storageClass }} - capacity: - storage: {{ $size }} - accessModes: - - ReadWriteOnce - persistentVolumeReclaimPolicy: Retain - hostPath: - path: {{ $hostPath }} ---- +{{ include "texera.localPersistence" (dict + "root" $ + "name" "postgresql" + "persistence" .Values.postgresql.primary.persistence + "hostBasePath" $hostBasePath + "defaultSize" "10Gi") }} {{- end }} -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: {{ $claimName }} - namespace: {{ $.Release.Namespace }} - {{- if not $.Values.persistence.removeAfterUninstall }} - annotations: - "helm.sh/resource-policy": keep - {{- end }} - labels: - app: {{ $.Release.Name }} - component: {{ $name }} -spec: - storageClassName: {{ $storageClass }} - accessModes: - - ReadWriteOnce - resources: - requests: - storage: {{ $size }} - {{- if and (eq $storageClass "local-path") (ne $hostBasePath "") }} - volumeName: {{ $volumeName }} - {{- end }} -{{- end }} \ No newline at end of file diff --git a/bin/k8s/templates/base/webserver/webserver-service.yaml b/bin/k8s/templates/base/webserver/webserver-service.yaml index 43375cb0e7..0ed1f98a6a 100644 --- a/bin/k8s/templates/base/webserver/webserver-service.yaml +++ b/bin/k8s/templates/base/webserver/webserver-service.yaml @@ -15,21 +15,4 @@ # specific language governing permissions and limitations # under the License. -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.webserver.name }}-svc - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.webserver.service.type }} - selector: - app: {{ .Release.Name }}-{{ .Values.webserver.name }} - ports: - - name: api-port - protocol: TCP - port: {{ .Values.webserver.service.port }} - targetPort: {{ .Values.webserver.service.port }} - # if service type is set to NodePort, include nodePort attribute - {{- if eq .Values.webserver.service.type "NodePort" }} - nodePort: {{ .Values.webserver.service.nodePort }} - {{- end }} \ No newline at end of file +{{ include "texera.releaseService" (dict "release" .Release "name" .Values.webserver.name "serviceType" .Values.webserver.service.type "port" .Values.webserver.service.port "nodePort" .Values.webserver.service.nodePort "portName" "api-port" "useNodePort" true) }} diff --git a/bin/k8s/templates/base/workflow-compiling-service/workflow-compiling-service-service.yaml b/bin/k8s/templates/base/workflow-compiling-service/workflow-compiling-service-service.yaml index d08f51eafa..1c75e2328e 100644 --- a/bin/k8s/templates/base/workflow-compiling-service/workflow-compiling-service-service.yaml +++ b/bin/k8s/templates/base/workflow-compiling-service/workflow-compiling-service-service.yaml @@ -15,21 +15,4 @@ # specific language governing permissions and limitations # under the License. -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.workflowCompilingService.name }}-svc - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.workflowCompilingService.service.type }} - selector: - app: {{ .Release.Name }}-{{ .Values.workflowCompilingService.name }} - ports: - - name: api-port - protocol: TCP - port: {{ .Values.workflowCompilingService.service.port }} - targetPort: {{ .Values.workflowCompilingService.service.port }} - # if service type is set to NodePort, include nodePort attribute - {{- if eq .Values.workflowCompilingService.service.type "NodePort" }} - nodePort: {{ .Values.workflowCompilingService.service.nodePort }} - {{- end }} \ No newline at end of file +{{ include "texera.releaseService" (dict "release" .Release "name" .Values.workflowCompilingService.name "serviceType" .Values.workflowCompilingService.service.type "port" .Values.workflowCompilingService.service.port "nodePort" .Values.workflowCompilingService.service.nodePort "portName" "api-port" "useNodePort" true) }} diff --git a/bin/k8s/templates/base/workflow-computing-unit-manager/workflow-computing-unit-manager-service.yaml b/bin/k8s/templates/base/workflow-computing-unit-manager/workflow-computing-unit-manager-service.yaml index a3fac71226..a0f7cc7bf1 100644 --- a/bin/k8s/templates/base/workflow-computing-unit-manager/workflow-computing-unit-manager-service.yaml +++ b/bin/k8s/templates/base/workflow-computing-unit-manager/workflow-computing-unit-manager-service.yaml @@ -15,20 +15,4 @@ # specific language governing permissions and limitations # under the License. -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.workflowComputingUnitManager.name }}-svc - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.workflowComputingUnitManager.service.type }} - selector: - app: {{ .Release.Name }}-{{ .Values.workflowComputingUnitManager.name }} - ports: - - protocol: TCP - port: {{ .Values.workflowComputingUnitManager.service.port }} - targetPort: {{ .Values.workflowComputingUnitManager.service.port }} - # if service type is set to NodePort, include nodePort attribute - {{- if eq .Values.workflowComputingUnitManager.service.type "NodePort" }} - nodePort: {{ .Values.workflowComputingUnitManager.service.nodePort }} - {{- end }} \ No newline at end of file +{{ include "texera.releaseService" (dict "release" .Release "name" .Values.workflowComputingUnitManager.name "serviceType" .Values.workflowComputingUnitManager.service.type "port" .Values.workflowComputingUnitManager.service.port "nodePort" .Values.workflowComputingUnitManager.service.nodePort "useNodePort" true) }} diff --git a/bin/k8s/templates/on-prem/rustfs-persistence.yaml b/bin/k8s/templates/on-prem/rustfs-persistence.yaml index dd0ce7cac8..771246ffa5 100644 --- a/bin/k8s/templates/on-prem/rustfs-persistence.yaml +++ b/bin/k8s/templates/on-prem/rustfs-persistence.yaml @@ -20,59 +20,10 @@ {{- $hostBasePath := .Values.persistence.rustfsHostLocalPath }} {{- if and .Values.rustfs.enabled .Values.rustfs.persistence.enabled }} -{{- $name := "rustfs" }} -{{- $persistence := .Values.rustfs.persistence }} -{{- $volumeName := printf "%s-data-pv" $name }} -{{- $claimName := printf "%s-data-pvc" $name }} -{{- $storageClass := $persistence.storageClass | default "local-path" }} -{{- $size := $persistence.size | default "20Gi" }} -{{- $hostPath := printf "%s/%s/%s" $hostBasePath $.Release.Name $name }} - -{{/* Only create PV for local-path storage class */}} -{{- if and (eq $storageClass "local-path") (ne $hostBasePath "") }} -apiVersion: v1 -kind: PersistentVolume -metadata: - name: {{ $volumeName }} - {{- if not $.Values.persistence.removeAfterUninstall }} - annotations: - "helm.sh/resource-policy": keep - {{- end }} - labels: - type: local - app: {{ $.Release.Name }} - component: {{ $name }} -spec: - storageClassName: {{ $storageClass }} - capacity: - storage: {{ $size }} - accessModes: - - ReadWriteOnce - persistentVolumeReclaimPolicy: Retain - hostPath: - path: {{ $hostPath }} ---- +{{ include "texera.localPersistence" (dict + "root" $ + "name" "rustfs" + "persistence" .Values.rustfs.persistence + "hostBasePath" $hostBasePath + "defaultSize" "20Gi") }} {{- end }} -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: {{ $claimName }} - namespace: {{ $.Release.Namespace }} - {{- if not $.Values.persistence.removeAfterUninstall }} - annotations: - "helm.sh/resource-policy": keep - {{- end }} - labels: - app: {{ $.Release.Name }} - component: {{ $name }} -spec: - storageClassName: {{ $storageClass }} - accessModes: - - ReadWriteOnce - resources: - requests: - storage: {{ $size }} - {{- if and (eq $storageClass "local-path") (ne $hostBasePath "") }} - volumeName: {{ $volumeName }} - {{- end }} -{{- end }} \ No newline at end of file
