diff --git a/charts/gateway/Chart.yaml b/charts/gateway/Chart.yaml index ee218c2..afc2b6c 100644 --- a/charts/gateway/Chart.yaml +++ b/charts/gateway/Chart.yaml @@ -14,7 +14,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.2.53 +version: 0.2.54 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/gateway/README.md b/charts/gateway/README.md index 725c0fa..087220f 100644 --- a/charts/gateway/README.md +++ b/charts/gateway/README.md @@ -192,7 +192,8 @@ The command removes all the Kubernetes components associated with the chart and | gateway.labelsOverride | object | `{}` | Override default labels assigned to API7 Gateway gateway resources | | gateway.livenessProbe | object | `{}` | kubernetes liveness probe. | | gateway.readinessProbe | object | `{}` | kubernetes readiness probe, we will provide a probe based on tcpSocket to gateway's HTTP port by default. | -| gateway.stream | object | `{"enabled":false,"only":false,"tcp":[],"udp":[]}` | API7 Gateway service settings for stream. L4 proxy (TCP/UDP) | +| gateway.stream | object | `{"autoAssignNodePort":false,"enabled":false,"only":false,"tcp":[],"udp":[]}` | API7 Gateway service settings for stream. L4 proxy (TCP/UDP) | +| gateway.stream.autoAssignNodePort | bool | `false` | Whether to set nodePort to the same value as the TCP/UDP port when gateway.type is NodePort, make sure the nodePort to be in the valid NodePort range of kubernetes service. | | gateway.tls | object | `{"additionalContainerPorts":[],"certCAFilename":"","containerPort":9443,"enabled":true,"existingCASecret":"","fallbackSNI":"","http2":{"enabled":true},"ip":"0.0.0.0","nodePort":null,"servicePort":443,"sslProtocols":"TLSv1.2 TLSv1.3"}` | API7 Gateway service settings for tls | | gateway.tls.additionalContainerPorts | list | `[]` | Support multiple https ports, See [Configuration](https://github.com/apache/apisix/blob/0bc65ea9acd726f79f80ae0abd8f50b7eb172e3d/conf/config-default.yaml#L99) | | gateway.tls.certCAFilename | string | `""` | Filename be used in the gateway.tls.existingCASecret | @@ -234,7 +235,7 @@ The command removes all the Kubernetes components associated with the chart and | serviceAccount.annotations | object | `{}` | | | serviceAccount.create | bool | `false` | | | serviceAccount.name | string | `""` | | -| serviceMonitor | object | `{"annotations":{},"containerPort":9091,"enabled":false,"interval":"15s","labels":{},"metricPrefix":"apisix_","name":"","namespace":"","path":"/apisix/prometheus/metrics"}` | Observability configuration. ref: https://apisix.apache.org/docs/apisix/plugins/prometheus/ | +| serviceMonitor | object | `{"annotations":{},"containerPort":9091,"enabled":false,"interval":"15s","labels":{},"metricPrefix":"apisix_","name":"","namespace":"","nodePort":null,"path":"/apisix/prometheus/metrics"}` | Observability configuration. ref: https://apisix.apache.org/docs/apisix/plugins/prometheus/ | | serviceMonitor.annotations | object | `{}` | @param serviceMonitor.annotations ServiceMonitor annotations | | serviceMonitor.containerPort | int | `9091` | container port where the metrics are exposed | | serviceMonitor.enabled | bool | `false` | Enable or disable API7 Gateway serviceMonitor | @@ -243,6 +244,7 @@ The command removes all the Kubernetes components associated with the chart and | serviceMonitor.metricPrefix | string | `"apisix_"` | prefix of the metrics | | serviceMonitor.name | string | `""` | name of the serviceMonitor, by default, it is the same as the apisix fullname | | serviceMonitor.namespace | string | `""` | namespace where the serviceMonitor is deployed, by default, it is the same as the namespace of the apisix | +| serviceMonitor.nodePort | int | `nil` | The nodePort of kubernetes service, only used if gateway.type is NodePort. If not set, a random port will be assigned by Kubernetes. | | serviceMonitor.path | string | `"/apisix/prometheus/metrics"` | path of the metrics endpoint | | soapProxy.enabled | bool | `false` | Enable or disable the SOAP proxy, this component is disabled by default, when use soap-proxy plugin in API7, you need to enable this component. | | soapProxy.image.pullPolicy | string | `"IfNotPresent"` | SOAP proxy image pull policy | diff --git a/charts/gateway/templates/service-gateway.yaml b/charts/gateway/templates/service-gateway.yaml index e3cfc13..04eba1a 100644 --- a/charts/gateway/templates/service-gateway.yaml +++ b/charts/gateway/templates/service-gateway.yaml @@ -77,6 +77,9 @@ spec: - name: prometheus port: {{ .Values.serviceMonitor.containerPort }} targetPort: {{ .Values.serviceMonitor.containerPort }} + {{- if (and (eq .Values.gateway.type "NodePort") (not (empty .Values.serviceMonitor.nodePort))) }} + nodePort: {{ .Values.serviceMonitor.nodePort }} + {{- end }} protocol: TCP {{- end }} {{- if .Values.api7ee.status_endpoint.enabled }} @@ -94,12 +97,23 @@ spec: {{- if kindIs "map" $port }} port: {{ splitList ":" ($port.addr | toString) | last }} targetPort: {{ splitList ":" ($port.addr | toString) | last }} - {{- if (and (eq $global.Values.gateway.type "NodePort") (not (empty $port.nodePort))) }} + {{- if eq $global.Values.gateway.type "NodePort" }} + {{- if $global.Values.gateway.stream.autoAssignNodePort }} + nodePort: {{ splitList ":" ($port.addr | toString) | last }} + {{- else }} + {{- if not (empty $port.nodePort) }} nodePort: {{ $port.nodePort }} {{- end }} + {{- end }} + {{- end }} {{- else }} port: {{ $port }} targetPort: {{ $port }} + {{- if eq $global.Values.gateway.type "NodePort" }} + {{- if $global.Values.gateway.stream.autoAssignNodePort }} + nodePort: {{ $port }} + {{- end }} + {{- end }} {{- end }} {{- end }} {{- end }} @@ -110,12 +124,23 @@ spec: {{- if kindIs "map" $port }} port: {{ splitList ":" ($port.addr | toString) | last }} targetPort: {{ splitList ":" ($port.addr | toString) | last }} - {{- if (and (eq $global.Values.gateway.type "NodePort") (not (empty $port.nodePort))) }} + {{- if eq $global.Values.gateway.type "NodePort" }} + {{- if $global.Values.gateway.stream.autoAssignNodePort }} + nodePort: {{ splitList ":" ($port.addr | toString) | last }} + {{- else }} + {{- if not (empty $port.nodePort) }} nodePort: {{ $port.nodePort }} {{- end }} + {{- end }} + {{- end }} {{- else }} port: {{ $port }} targetPort: {{ $port }} + {{- if eq $global.Values.gateway.type "NodePort" }} + {{- if $global.Values.gateway.stream.autoAssignNodePort }} + nodePort: {{ $port }} + {{- end }} + {{- end }} {{- end }} {{- end }} {{- end }} diff --git a/charts/gateway/values.yaml b/charts/gateway/values.yaml index 08ad251..7f555f9 100644 --- a/charts/gateway/values.yaml +++ b/charts/gateway/values.yaml @@ -358,6 +358,8 @@ gateway: stream: enabled: false only: false + # -- Whether to set nodePort to the same value as the TCP/UDP port when gateway.type is NodePort, make sure the nodePort to be in the valid NodePort range of kubernetes service. + autoAssignNodePort: false tcp: [] # - addr: 192.168.31.10:5432 # - addr: 3302 @@ -592,6 +594,8 @@ serviceMonitor: metricPrefix: apisix_ # -- container port where the metrics are exposed containerPort: 9091 + # -- (int) The nodePort of kubernetes service, only used if gateway.type is NodePort. If not set, a random port will be assigned by Kubernetes. + nodePort: # -- @param serviceMonitor.labels ServiceMonitor extra labels labels: {} # -- @param serviceMonitor.annotations ServiceMonitor annotations