Skip to content

Commit d05e942

Browse files
authored
Make it possible to set nodePort in services (#931)
* Make it possible to set nodePort in services * Fix copy-pasted comment * Define nodeport for synchrony svc * Fix unit tests * Add docs --------- Co-authored-by: Yevhen Ivantsov <[email protected]>
1 parent 4eed1d9 commit d05e942

File tree

23 files changed

+87
-3
lines changed

23 files changed

+87
-3
lines changed

docs/docs/userguide/CONFIGURATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jira:
5656
timeoutSeconds: 10800
5757
```
5858
59-
The service port will be exposed on a random port from the ephemeral port range (`30000`-`32767`) on all worker nodes. You can provision a LoadBalancer with `443` or `80` (or both) listeners that will forward traffic to the node port (you can get service node port by running `kubectl describe $service -n $namespace`). Both LoadBalancer and Kubernetes service should be configured to maintain session affinity. LoadBalancer session affinity should be configured as per instructions for your Kubernetes/cloud provider. Service session affinity is configured by overriding the default Helm chart values (see the above example). Make sure you configure networking rules to allow the LoadBalancer to communicate with the Kubernetes cluster worker node on the node port.
59+
The service port will be exposed on a random port from the ephemeral port range (`30000`-`32767`) on all worker nodes. It is possible to explicitly set NodePort in `service.nodePort` (make sure it's not reserved for any existing service in the cluster). You can provision a LoadBalancer with `443` or `80` (or both) listeners that will forward traffic to the node port (you can get service node port by running `kubectl describe $service -n $namespace`). Both LoadBalancer and Kubernetes service should be configured to maintain session affinity. LoadBalancer session affinity should be configured as per instructions for your Kubernetes/cloud provider. Service session affinity is configured by overriding the default Helm chart values (see the above example). Make sure you configure networking rules to allow the LoadBalancer to communicate with the Kubernetes cluster worker node on the node port.
6060

6161
!!!tip
6262
For more information about Kubernetes service session affinity, see [Kubernetes documentation](https://kubernetes.io/docs/reference/networking/virtual-ips/#session-affinity){.external}.

src/main/charts/bamboo/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Kubernetes: `>=1.21.x-0`
8787
| bamboo.service.annotations | object | `{}` | Additional annotations to apply to the Service |
8888
| bamboo.service.contextPath | string | `nil` | The Tomcat context path that Bamboo will use. The ATL_TOMCAT_CONTEXTPATH will be set automatically. |
8989
| bamboo.service.loadBalancerIP | string | `nil` | Use specific loadBalancerIP. Only applies to service type LoadBalancer. |
90+
| bamboo.service.nodePort | string | `nil` | Only applicable if service.type is NodePort. NodePort for Bamboo service |
9091
| bamboo.service.port | int | `80` | The port on which the Bamboo K8s Service will listen for http traffic |
9192
| bamboo.service.sessionAffinity | string | `"None"` | Session affinity type. If you want to make sure that connections from a particular client are passed to the same pod each time, set sessionAffinity to ClientIP. See: https://kubernetes.io/docs/reference/networking/virtual-ips/#session-affinity |
9293
| bamboo.service.sessionAffinityConfig | object | `{"clientIP":{"timeoutSeconds":null}}` | Session affinity configuration |

src/main/charts/bamboo/templates/service.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ spec:
2424
targetPort: http
2525
protocol: TCP
2626
name: http
27+
{{- if and (eq .Values.bamboo.service.type "NodePort") .Values.bamboo.service.nodePort}}
28+
nodePort: {{ .Values.bamboo.service.nodePort }}
29+
{{- end }}
2730
selector:
2831
{{- include "common.labels.selectorLabels" . | nindent 4 }}

src/main/charts/bamboo/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,10 @@ bamboo:
568568
#
569569
type: ClusterIP
570570

571+
# -- Only applicable if service.type is NodePort. NodePort for Bamboo service
572+
#
573+
nodePort:
574+
571575
# -- Session affinity type. If you want to make sure that connections from a particular client
572576
# are passed to the same pod each time, set sessionAffinity to ClientIP.
573577
# See: https://kubernetes.io/docs/reference/networking/virtual-ips/#session-affinity

src/main/charts/bitbucket/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,23 @@ Kubernetes: `>=1.21.x-0`
122122
| bitbucket.service.annotations | object | `{}` | Additional annotations to apply to the Service |
123123
| bitbucket.service.contextPath | string | `nil` | The context path that Bitbucket will use. |
124124
| bitbucket.service.loadBalancerIP | string | `nil` | Use specific loadBalancerIP. Only applies to service type LoadBalancer. |
125+
| bitbucket.service.nodePort | string | `nil` | Only applicable if service.type is NodePort. NodePort for Bitbucket service |
125126
| bitbucket.service.port | int | `80` | The port on which the Bitbucket K8s HTTP Service will listen |
126127
| bitbucket.service.sessionAffinity | string | `"None"` | Session affinity type. If you want to make sure that connections from a particular client are passed to the same pod each time, set sessionAffinity to ClientIP. See: https://kubernetes.io/docs/reference/networking/virtual-ips/#session-affinity |
127128
| bitbucket.service.sessionAffinityConfig | object | `{"clientIP":{"timeoutSeconds":null}}` | Session affinity configuration |
128129
| bitbucket.service.sessionAffinityConfig.clientIP.timeoutSeconds | string | `nil` | Specifies the seconds of ClientIP type session sticky time. The value must be > 0 && <= 86400 (for 1 day) if ServiceAffinity == "ClientIP". Default value is 10800 (for 3 hours). |
130+
| bitbucket.service.sshNodePort | string | `nil` | SSH Only applicable if service.type is NodePort. NodePort for Bitbucket service |
129131
| bitbucket.service.sshPort | int | `7999` | The port on which the Bitbucket K8s SSH Service will listen |
130132
| bitbucket.service.type | string | `"ClusterIP"` | The type of K8s service to use for Bitbucket |
131133
| bitbucket.setPermissions | bool | `true` | Boolean to define whether to set local home directory permissions on startup of Bitbucket container. Set to 'false' to disable this behaviour. |
132134
| bitbucket.shutdown.command | string | `"/shutdown-wait.sh"` | By default pods will be stopped via a [preStop hook](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/), using a script supplied by the Docker image. If any other shutdown behaviour is needed it can be achieved by overriding this value. Note that the shutdown command needs to wait for the application shutdown completely before exiting; see [the default command](https://bitbucket.org/atlassian-docker/docker-atlassian-bitbucket-server/src/master/shutdown-wait.sh) for details. |
133135
| bitbucket.shutdown.terminationGracePeriodSeconds | int | `35` | The termination grace period for pods during shutdown. This should be set to the Bitbucket internal grace period (default 30 seconds), plus a small buffer to allow the JVM to fully terminate. |
134-
| bitbucket.sshService | object | `{"annotations":{},"enabled":false,"host":null,"loadBalancerIP":null,"port":22,"type":"LoadBalancer"}` | Enable or disable an additional service for exposing SSH for external access. Disable when the SSH service is exposed through the ingress controller, or enable if the ingress controller does not support TCP. |
136+
| bitbucket.sshService | object | `{"annotations":{},"enabled":false,"host":null,"loadBalancerIP":null,"nodePort":null,"port":22,"type":"LoadBalancer"}` | Enable or disable an additional service for exposing SSH for external access. Disable when the SSH service is exposed through the ingress controller, or enable if the ingress controller does not support TCP. |
135137
| bitbucket.sshService.annotations | object | `{}` | Annotations for the SSH service. Useful if a load balancer controller needs extra annotations. |
136138
| bitbucket.sshService.enabled | bool | `false` | Set to 'true' if an additional SSH Service should be created |
137139
| bitbucket.sshService.host | string | `nil` | The hostname of the SSH service. If set, it'll be used to configure the SSH base URL for the application. |
138140
| bitbucket.sshService.loadBalancerIP | string | `nil` | Use specific loadBalancerIP. Only applies to service type LoadBalancer. |
141+
| bitbucket.sshService.nodePort | string | `nil` | Only applicable if service.type is NodePort. NodePort for Bitbucket ssh service |
139142
| bitbucket.sshService.port | int | `22` | Port to expose the SSH service on. |
140143
| bitbucket.sshService.type | string | `"LoadBalancer"` | SSH Service type |
141144
| bitbucket.startupProbe.enabled | bool | `false` | Whether to apply the startupProbe check to pod. |

src/main/charts/bitbucket/templates/service.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ spec:
2525
targetPort: http
2626
protocol: TCP
2727
name: http
28+
{{- if and (eq .Values.bitbucket.service.type "NodePort") .Values.bitbucket.service.nodePort}}
29+
nodePort: {{ .Values.bitbucket.service.nodePort }}
30+
{{- end }}
2831
- port: {{ .Values.bitbucket.service.sshPort }}
2932
targetPort: ssh
3033
protocol: TCP
3134
name: ssh
35+
{{- if and (eq .Values.bitbucket.service.type "NodePort") .Values.bitbucket.service.sshNodePort}}
36+
nodePort: {{ .Values.bitbucket.service.sshNodePort }}
37+
{{- end }}
3238
{{- if not .Values.bitbucket.hazelcastService.enabled }}
3339
- port: {{ .Values.bitbucket.ports.hazelcast }}
3440
targetPort: hazelcast

src/main/charts/bitbucket/values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,14 @@ bitbucket:
542542
#
543543
type: ClusterIP
544544

545+
# -- Only applicable if service.type is NodePort. NodePort for Bitbucket service
546+
#
547+
nodePort:
548+
549+
# -- SSH Only applicable if service.type is NodePort. NodePort for Bitbucket service
550+
#
551+
sshNodePort:
552+
545553
# -- Session affinity type. If you want to make sure that connections from a particular client
546554
# are passed to the same pod each time, set sessionAffinity to ClientIP.
547555
# See: https://kubernetes.io/docs/reference/networking/virtual-ips/#session-affinity
@@ -593,6 +601,10 @@ bitbucket:
593601
#
594602
type: LoadBalancer
595603

604+
# -- Only applicable if service.type is NodePort. NodePort for Bitbucket ssh service
605+
#
606+
nodePort:
607+
596608
# -- Use specific loadBalancerIP. Only applies to service type LoadBalancer.
597609
#
598610
loadBalancerIP:

src/main/charts/confluence/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Kubernetes: `>=1.21.x-0`
8888
| confluence.service.annotations | object | `{}` | Additional annotations to apply to the Service |
8989
| confluence.service.contextPath | string | `nil` | The Tomcat context path that Confluence will use. The ATL_TOMCAT_CONTEXTPATH will be set automatically. |
9090
| confluence.service.loadBalancerIP | string | `nil` | Use specific loadBalancerIP. Only applies to service type LoadBalancer. |
91+
| confluence.service.nodePort | string | `nil` | Only applicable if service.type is NodePort. NodePort for Confluence service |
9192
| confluence.service.port | int | `80` | The port on which the Confluence K8s Service will listen |
9293
| confluence.service.sessionAffinity | string | `"None"` | Session affinity type. If you want to make sure that connections from a particular client are passed to the same pod each time, set sessionAffinity to ClientIP. See: https://kubernetes.io/docs/reference/networking/virtual-ips/#session-affinity |
9394
| confluence.service.sessionAffinityConfig | object | `{"clientIP":{"timeoutSeconds":null}}` | Session affinity configuration |
@@ -223,6 +224,7 @@ Kubernetes: `>=1.21.x-0`
223224
| synchrony.securityContextEnabled | bool | `true` | |
224225
| synchrony.service.annotations | object | `{}` | Annotations to apply to Synchrony Service |
225226
| synchrony.service.loadBalancerIP | string | `nil` | Use specific loadBalancerIP. Only applies to service type LoadBalancer. |
227+
| synchrony.service.nodePort | string | `nil` | Only applicable if service.type is NodePort. NodePort for Synchrony service |
226228
| synchrony.service.port | int | `80` | The port on which the Synchrony K8s Service will listen |
227229
| synchrony.service.type | string | `"ClusterIP"` | The type of K8s service to use for Synchrony |
228230
| synchrony.setPermissions | bool | `true` | Boolean to define whether to set synchrony home directory permissions on startup of Synchrony container. Set to 'false' to disable this behaviour. |

src/main/charts/confluence/templates/service-synchrony.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ spec:
2626
targetPort: http
2727
protocol: TCP
2828
name: http
29+
{{- if and (eq .Values.synchrony.service.type "NodePort") .Values.synchrony.service.nodePort}}
30+
nodePort: {{ .Values.synchrony.service.nodePort }}
31+
{{- end }}
2932
- port: {{ .Values.synchrony.ports.hazelcast }}
3033
targetPort: hazelcast
3134
protocol: TCP

src/main/charts/confluence/templates/service.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ spec:
2424
targetPort: http
2525
protocol: TCP
2626
name: http
27+
{{- if and (eq .Values.confluence.service.type "NodePort") .Values.confluence.service.nodePort}}
28+
nodePort: {{ .Values.confluence.service.nodePort }}
29+
{{- end }}
2730
{{- if not .Values.confluence.hazelcastService.enabled }}
2831
- port: {{ .Values.confluence.ports.hazelcast }}
2932
targetPort: hazelcast

0 commit comments

Comments
 (0)