-
Notifications
You must be signed in to change notification settings - Fork 4
feat: support specify node port for gateway service #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| {{- $global := . -}} | ||
| {{- if .Values.apisix.enabled }} | ||
| apiVersion: v1 | ||
| kind: Service | ||
|
|
@@ -41,30 +42,36 @@ spec: | |
| - name: apisix-gateway | ||
| port: {{ .Values.gateway.http.servicePort }} | ||
| targetPort: {{ .Values.gateway.http.containerPort }} | ||
| {{- if (and (eq .Values.gateway.type "NodePort") (not (empty .Values.gateway.http.nodePort))) }} | ||
| {{- if (and (eq .Values.gateway.type "NodePort") (not (empty .Values.gateway.http.nodePort))) }} | ||
| nodePort: {{ .Values.gateway.http.nodePort }} | ||
| {{- end }} | ||
| {{- end }} | ||
| protocol: TCP | ||
| {{- end }} | ||
| {{- range .Values.gateway.http.additionalContainerPorts }} | ||
| - name: apisix-gateway-{{ .port | toString }} | ||
| port: {{ .port }} | ||
| targetPort: {{ .port }} | ||
| {{- if (and (eq $global.Values.gateway.type "NodePort") (not (empty .nodePort))) }} | ||
| nodePort: {{ .nodePort }} | ||
| {{- end }} | ||
| protocol: TCP | ||
| {{- end }} | ||
| {{- if or .Values.gateway.tls.enabled }} | ||
| - name: apisix-gateway-tls | ||
| port: {{ .Values.gateway.tls.servicePort }} | ||
| targetPort: {{ .Values.gateway.tls.containerPort }} | ||
| {{- if (and (eq .Values.gateway.type "NodePort") (not (empty .Values.gateway.tls.nodePort))) }} | ||
| {{- if (and (eq .Values.gateway.type "NodePort") (not (empty .Values.gateway.tls.nodePort))) }} | ||
| nodePort: {{ .Values.gateway.tls.nodePort }} | ||
| {{- end }} | ||
| {{- end }} | ||
| protocol: TCP | ||
| {{- end }} | ||
| {{- range .Values.gateway.tls.additionalContainerPorts }} | ||
| - name: apisix-gateway-tls-{{ .port | toString }} | ||
| port: {{ .port }} | ||
| targetPort: {{ .port }} | ||
| {{- if (and (eq $global.Values.gateway.type "NodePort") (not (empty .nodePort))) }} | ||
| nodePort: {{ .nodePort }} | ||
| {{- end }} | ||
|
Comment on lines
68
to
+74
|
||
| {{- end }} | ||
| {{- if .Values.serviceMonitor.enabled }} | ||
| - name: prometheus | ||
|
|
@@ -83,23 +90,33 @@ spec: | |
| {{- if (gt (len .tcp) 0) }} | ||
| {{- range $index, $port := .tcp }} | ||
| - name: proxy-tcp-{{ $index | toString }} | ||
| protocol: TCP | ||
| {{- if kindIs "map" $port }} | ||
| port: {{ splitList ":" ($port.addr | toString) | last }} | ||
| targetPort: {{ splitList ":" ($port.addr | toString) | last }} | ||
| protocol: TCP | ||
| {{- if (and (eq $global.Values.gateway.type "NodePort") (not (empty $port.nodePort))) }} | ||
| nodePort: {{ $port.nodePort }} | ||
| {{- end }} | ||
| {{- else }} | ||
| port: {{ $port }} | ||
| targetPort: {{ $port }} | ||
| protocol: TCP | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- if (gt (len .udp) 0) }} | ||
| {{- range $index, $port := .udp }} | ||
| - name: proxy-udp-{{ $index | toString }} | ||
| protocol: UDP | ||
| {{- 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))) }} | ||
| nodePort: {{ $port.nodePort }} | ||
| {{- end }} | ||
| {{- else }} | ||
| port: {{ $port }} | ||
| targetPort: {{ $port }} | ||
| protocol: UDP | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -309,12 +309,15 @@ gateway: | |
| ip: 0.0.0.0 | ||
| servicePort: 80 | ||
| containerPort: 9080 | ||
| # -- (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: | ||
| # hostPort: 9080 | ||
| # backlog: 1024 # sets the backlog parameter in the listen() call that limits, the maximum length for the queue of pending connections. By default, backlog is set to -1 on FreeBSD, DragonFly BSD, and macOS, and to 511 on other platforms. | ||
| # -- Support multiple http ports, See [Configuration](https://github.com/apache/apisix/blob/0bc65ea9acd726f79f80ae0abd8f50b7eb172e3d/conf/config-default.yaml#L24) | ||
| additionalContainerPorts: [] | ||
| # - port: 9081 | ||
| # hostPort: 9081 | ||
| # nodePort: 31081 | ||
| # enable_http2: true # If not set, the default value is `false`. | ||
|
Comment on lines
318
to
321
|
||
| # backlog: 1024 | ||
| # - ip: 127.0.0.2 # Specific IP, If not set, the default value is `0.0.0.0`. | ||
|
|
@@ -329,13 +332,16 @@ gateway: | |
| ip: 0.0.0.0 | ||
| servicePort: 443 | ||
| containerPort: 9443 | ||
| # -- (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: | ||
| # hostPort: 9443 | ||
| # backlog: 1024 | ||
| # -- Support multiple https ports, See [Configuration](https://github.com/apache/apisix/blob/0bc65ea9acd726f79f80ae0abd8f50b7eb172e3d/conf/config-default.yaml#L99) | ||
| additionalContainerPorts: [] | ||
| # - ip: 127.0.0.3 # Specific IP, If not set, the default value is `0.0.0.0`. | ||
| # port: 9445 | ||
| # hostPort: 9445 | ||
| # nodePort: 31045 | ||
| # enable_http2: true | ||
| # backlog: 1024 | ||
| # -- Specifies the name of Secret contains trusted CA certificates in the PEM format used to verify the certificate when APISIX needs to do SSL/TLS handshaking with external services (e.g. etcd) | ||
|
|
@@ -353,7 +359,13 @@ gateway: | |
| enabled: false | ||
| only: false | ||
| tcp: [] | ||
| # - addr: 192.168.31.10:5432 | ||
| # - addr: 3302 | ||
| # nodePort: 31302 | ||
| udp: [] | ||
| # - addr: 192.168.31.10:53 | ||
| # - addr: 5353 | ||
| # nodePort: 31353 | ||
| # -- Using ingress access API7 Gateway service | ||
| ingress: | ||
| enabled: false | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inside the
range .Values.gateway.http.additionalContainerPorts,.becomes the per-port map, so.Values.gateway.typeis out of scope and will cause template rendering errors whenadditionalContainerPortsis non-empty. Use the root context instead (e.g.$.Values.gateway.typeor the already-defined$global.Values.gateway.type).