From e8597b80e817d0e35123a0a3d8cfa5ba2ef45b01 Mon Sep 17 00:00:00 2001 From: prafull01 Date: Tue, 24 Sep 2024 23:07:26 +0530 Subject: [PATCH] Allow changing of grpc and http ports from single placeholder --- build/templates/README.md | 8 ++++---- build/templates/values.yaml | 10 ++++++---- cockroachdb/README.md | 8 ++++---- cockroachdb/templates/statefulset.yaml | 16 ++++++++++++++++ cockroachdb/values.yaml | 10 ++++++---- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/build/templates/README.md b/build/templates/README.md index d81414f0..8050d8bc 100644 --- a/build/templates/README.md +++ b/build/templates/README.md @@ -307,8 +307,8 @@ For details see the [`values.yaml`](values.yaml) file. | `conf.locality` | Locality attribute for this deployment | `""` | | `conf.single-node` | Disable CockroachDB clustering (standalone mode) | `no` | | `conf.sql-audit-dir` | Directory for SQL audit log | `""` | -| `conf.port` | CockroachDB primary serving port in Pods | `26257` | -| `conf.http-port` | CockroachDB HTTP port in Pods | `8080` | +| `conf.port` | WARNING this parameter is deprecated and will be removed in future version. Use `service.ports.grpc.internal.port` instead | `""` | +| `conf.http-port` | WARNING this parameter is deprecated and will be removed in future version. Use `service.ports.http.port` instead | `""` | | `conf.path` | CockroachDB data directory mount path | `cockroach-data` | | `conf.store.enabled` | Enable store configuration for CockroachDB | `false` | | `conf.store.type` | CockroachDB storage type | `""` | @@ -347,9 +347,9 @@ For details see the [`values.yaml`](values.yaml) file. | `statefulset.terminationGracePeriodSeconds` | Termination grace period for CRDB statefulset pods | `300` | | `service.ports.grpc.external.port` | CockroachDB primary serving port in Services | `26257` | | `service.ports.grpc.external.name` | CockroachDB primary serving port name in Services | `grpc` | -| `service.ports.grpc.internal.port` | CockroachDB inter-communication port in Services | `26257` | +| `service.ports.grpc.internal.port` | CockroachDB inter-communication port in Pods and Services | `26257` | | `service.ports.grpc.internal.name` | CockroachDB inter-communication port name in Services | `grpc-internal` | -| `service.ports.http.port` | CockroachDB HTTP port in Services | `8080` | +| `service.ports.http.port` | CockroachDB HTTP port in Pods and Services | `8080` | | `service.ports.http.name` | CockroachDB HTTP port name in Services | `http` | | `service.public.type` | Public Service type | `ClusterIP` | | `service.public.labels` | Additional labels of public Service | `{"app.kubernetes.io/component": "cockroachdb"}` | diff --git a/build/templates/values.yaml b/build/templates/values.yaml index a8f9fb86..2af8a2a2 100644 --- a/build/templates/values.yaml +++ b/build/templates/values.yaml @@ -147,11 +147,11 @@ conf: # If non-empty, create a SQL audit log in the specified directory. sql-audit-dir: "" - # CockroachDB's port to listen to inter-communications and client connections. - port: 26257 + # WARNING this parameter is deprecated and will be removed in a future version. Use `.service.ports.grpc.internal.port` instead + port: "" - # CockroachDB's port to listen to HTTP requests. - http-port: 8080 + # WARNING this parameter is deprecated and will be removed in a future version. Use `.service.ports.http.port` instead + http-port: "" # CockroachDB's data mount path. path: cockroach-data @@ -303,10 +303,12 @@ service: # If the port number is different than `external.port`, then it will be # named as `internal.name` in Service. internal: + # CockroachDB's port to listen to inter-communications and client connections. port: 26257 # If using Istio set it to `cockroach`. name: grpc-internal http: + # CockroachDB's port to listen to HTTP requests. port: 8080 name: http diff --git a/cockroachdb/README.md b/cockroachdb/README.md index 15fd252e..4fa75d64 100644 --- a/cockroachdb/README.md +++ b/cockroachdb/README.md @@ -308,8 +308,8 @@ For details see the [`values.yaml`](values.yaml) file. | `conf.locality` | Locality attribute for this deployment | `""` | | `conf.single-node` | Disable CockroachDB clustering (standalone mode) | `no` | | `conf.sql-audit-dir` | Directory for SQL audit log | `""` | -| `conf.port` | CockroachDB primary serving port in Pods | `26257` | -| `conf.http-port` | CockroachDB HTTP port in Pods | `8080` | +| `conf.port` | WARNING this parameter is deprecated and will be removed in future version. Use `service.ports.grpc.internal.port` instead | `""` | +| `conf.http-port` | WARNING this parameter is deprecated and will be removed in future version. Use `service.ports.http.port` instead | `""` | | `conf.path` | CockroachDB data directory mount path | `cockroach-data` | | `conf.store.enabled` | Enable store configuration for CockroachDB | `false` | | `conf.store.type` | CockroachDB storage type | `""` | @@ -348,9 +348,9 @@ For details see the [`values.yaml`](values.yaml) file. | `statefulset.terminationGracePeriodSeconds` | Termination grace period for CRDB statefulset pods | `300` | | `service.ports.grpc.external.port` | CockroachDB primary serving port in Services | `26257` | | `service.ports.grpc.external.name` | CockroachDB primary serving port name in Services | `grpc` | -| `service.ports.grpc.internal.port` | CockroachDB inter-communication port in Services | `26257` | +| `service.ports.grpc.internal.port` | CockroachDB inter-communication port in Pods and Services | `26257` | | `service.ports.grpc.internal.name` | CockroachDB inter-communication port name in Services | `grpc-internal` | -| `service.ports.http.port` | CockroachDB HTTP port in Services | `8080` | +| `service.ports.http.port` | CockroachDB HTTP port in Pods and Services | `8080` | | `service.ports.http.name` | CockroachDB HTTP port name in Services | `http` | | `service.public.type` | Public Service type | `ClusterIP` | | `service.public.labels` | Additional labels of public Service | `{"app.kubernetes.io/component": "cockroachdb"}` | diff --git a/cockroachdb/templates/statefulset.yaml b/cockroachdb/templates/statefulset.yaml index b1f26fae..43a1f594 100644 --- a/cockroachdb/templates/statefulset.yaml +++ b/cockroachdb/templates/statefulset.yaml @@ -202,8 +202,16 @@ spec: {{- with .Values.conf.attrs }} --attrs={{ join `:` . }} {{- end }} + {{- if index .Values.conf `http-port` }} --http-port={{ index .Values.conf `http-port` | int64 }} + {{- else }} + --http-port={{ index .Values.service.ports.http.port | int64 }} + {{- end }} + {{ if .Values.conf.port }} --port={{ .Values.conf.port | int64 }} + {{- else }} + --port={{ .Values.service.ports.grpc.internal.port | int64 }} + {{- end }} --cache={{ .Values.conf.cache }} {{- with index .Values.conf `max-disk-temp-storage` }} --max-disk-temp-storage={{ . }} @@ -241,10 +249,18 @@ spec: {{- end }} ports: - name: grpc + {{ if .Values.conf.port }} containerPort: {{ .Values.conf.port | int64 }} + {{- else }} + containerPort: {{ .Values.service.ports.grpc.internal.port | int64 }} + {{- end }} protocol: TCP - name: http + {{- if index .Values.conf `http-port` }} containerPort: {{ index .Values.conf `http-port` | int64 }} + {{- else }} + containerPort: {{ index .Values.service.ports.http.port | int64 }} + {{- end }} protocol: TCP volumeMounts: - name: datadir diff --git a/cockroachdb/values.yaml b/cockroachdb/values.yaml index 592d3ec3..5ebdf00f 100644 --- a/cockroachdb/values.yaml +++ b/cockroachdb/values.yaml @@ -148,11 +148,11 @@ conf: # If non-empty, create a SQL audit log in the specified directory. sql-audit-dir: "" - # CockroachDB's port to listen to inter-communications and client connections. - port: 26257 + # WARNING this parameter is deprecated and will be removed in a future version. Use `.service.ports.grpc.internal.port` instead + port: "" - # CockroachDB's port to listen to HTTP requests. - http-port: 8080 + # WARNING this parameter is deprecated and will be removed in a future version. Use `.service.ports.http.port` instead + http-port: "" # CockroachDB's data mount path. path: cockroach-data @@ -304,10 +304,12 @@ service: # If the port number is different than `external.port`, then it will be # named as `internal.name` in Service. internal: + # CockroachDB's port to listen to inter-communications and client connections. port: 26257 # If using Istio set it to `cockroach`. name: grpc-internal http: + # CockroachDB's port to listen to HTTP requests. port: 8080 name: http