Skip to content
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

Make it possible to set nodePort in services #931

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/charts/bamboo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Kubernetes: `>=1.21.x-0`
| bamboo.service.annotations | object | `{}` | Additional annotations to apply to the Service |
| bamboo.service.contextPath | string | `nil` | The Tomcat context path that Bamboo will use. The ATL_TOMCAT_CONTEXTPATH will be set automatically. |
| bamboo.service.loadBalancerIP | string | `nil` | Use specific loadBalancerIP. Only applies to service type LoadBalancer. |
| bamboo.service.nodePort | string | `nil` | NodePort for Bamboo service |
| bamboo.service.port | int | `80` | The port on which the Bamboo K8s Service will listen for http traffic |
| 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 |
| bamboo.service.sessionAffinityConfig | object | `{"clientIP":{"timeoutSeconds":null}}` | Session affinity configuration |
Expand Down
3 changes: 3 additions & 0 deletions src/main/charts/bamboo/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ spec:
targetPort: http
protocol: TCP
name: http
{{- if and (eq .Values.bamboo.service.type "NodePort") .Values.bamboo.service.nodePort}}
nodePort: {{ .Values.bamboo.service.nodePort }}
{{- end }}
selector:
{{- include "common.labels.selectorLabels" . | nindent 4 }}
4 changes: 4 additions & 0 deletions src/main/charts/bamboo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,10 @@ bamboo:
#
type: ClusterIP

# -- NodePort for Bamboo service
#
nodePort:

# -- 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
Expand Down
5 changes: 4 additions & 1 deletion src/main/charts/bitbucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,23 @@ Kubernetes: `>=1.21.x-0`
| bitbucket.service.annotations | object | `{}` | Additional annotations to apply to the Service |
| bitbucket.service.contextPath | string | `nil` | The context path that Bitbucket will use. |
| bitbucket.service.loadBalancerIP | string | `nil` | Use specific loadBalancerIP. Only applies to service type LoadBalancer. |
| bitbucket.service.nodePort | string | `nil` | NodePort for Bitbucket service |
| bitbucket.service.port | int | `80` | The port on which the Bitbucket K8s HTTP Service will listen |
| 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 |
| bitbucket.service.sessionAffinityConfig | object | `{"clientIP":{"timeoutSeconds":null}}` | Session affinity configuration |
| 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). |
| bitbucket.service.sshNodePort | string | `nil` | SSH NodePort for Bitbucket service |
| bitbucket.service.sshPort | int | `7999` | The port on which the Bitbucket K8s SSH Service will listen |
| bitbucket.service.type | string | `"ClusterIP"` | The type of K8s service to use for Bitbucket |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| bitbucket.sshService.annotations | object | `{}` | Annotations for the SSH service. Useful if a load balancer controller needs extra annotations. |
| bitbucket.sshService.enabled | bool | `false` | Set to 'true' if an additional SSH Service should be created |
| 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. |
| bitbucket.sshService.loadBalancerIP | string | `nil` | Use specific loadBalancerIP. Only applies to service type LoadBalancer. |
| bitbucket.sshService.nodePort | string | `nil` | NodePort for Bitbucket ssh service |
| bitbucket.sshService.port | int | `22` | Port to expose the SSH service on. |
| bitbucket.sshService.type | string | `"LoadBalancer"` | SSH Service type |
| bitbucket.startupProbe.enabled | bool | `false` | Whether to apply the startupProbe check to pod. |
Expand Down
6 changes: 6 additions & 0 deletions src/main/charts/bitbucket/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ spec:
targetPort: http
protocol: TCP
name: http
{{- if and (eq .Values.bitbucket.service.type "NodePort") .Values.bitbucket.service.nodePort}}
nodePort: {{ .Values.bitbucket.service.nodePort }}
{{- end }}
- port: {{ .Values.bitbucket.service.sshPort }}
targetPort: ssh
protocol: TCP
name: ssh
{{- if and (eq .Values.bitbucket.service.type "NodePort") .Values.bitbucket.service.sshNodePort}}
nodePort: {{ .Values.bitbucket.service.sshNodePort }}
{{- end }}
{{- if not .Values.bitbucket.hazelcastService.enabled }}
- port: {{ .Values.bitbucket.ports.hazelcast }}
targetPort: hazelcast
Expand Down
12 changes: 12 additions & 0 deletions src/main/charts/bitbucket/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,14 @@ bitbucket:
#
type: ClusterIP

# -- NodePort for Bitbucket service
#
nodePort:

# -- SSH NodePort for Bitbucket service
#
sshNodePort:

# -- 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
Expand Down Expand Up @@ -593,6 +601,10 @@ bitbucket:
#
type: LoadBalancer

# -- NodePort for Bitbucket ssh service
#
nodePort:

# -- Use specific loadBalancerIP. Only applies to service type LoadBalancer.
#
loadBalancerIP:
Expand Down
2 changes: 2 additions & 0 deletions src/main/charts/confluence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Kubernetes: `>=1.21.x-0`
| confluence.service.annotations | object | `{}` | Additional annotations to apply to the Service |
| confluence.service.contextPath | string | `nil` | The Tomcat context path that Confluence will use. The ATL_TOMCAT_CONTEXTPATH will be set automatically. |
| confluence.service.loadBalancerIP | string | `nil` | Use specific loadBalancerIP. Only applies to service type LoadBalancer. |
| confluence.service.nodePort | string | `nil` | NodePort for Confluence service |
| confluence.service.port | int | `80` | The port on which the Confluence K8s Service will listen |
| 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 |
| confluence.service.sessionAffinityConfig | object | `{"clientIP":{"timeoutSeconds":null}}` | Session affinity configuration |
Expand Down Expand Up @@ -223,6 +224,7 @@ Kubernetes: `>=1.21.x-0`
| synchrony.securityContextEnabled | bool | `true` | |
| synchrony.service.annotations | object | `{}` | Annotations to apply to Synchrony Service |
| synchrony.service.loadBalancerIP | string | `nil` | Use specific loadBalancerIP. Only applies to service type LoadBalancer. |
| synchrony.service.nodePort | string | `nil` | NodePort for Synchrony service |
| synchrony.service.port | int | `80` | The port on which the Synchrony K8s Service will listen |
| synchrony.service.type | string | `"ClusterIP"` | The type of K8s service to use for Synchrony |
| 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. |
Expand Down
3 changes: 3 additions & 0 deletions src/main/charts/confluence/templates/service-synchrony.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ spec:
targetPort: http
protocol: TCP
name: http
{{- if and (eq .Values.synchrony.service.type "NodePort") .Values.synchrony.service.nodePort}}
nodePort: {{ .Values.synchrony.service.nodePort }}
{{- end }}
- port: {{ .Values.synchrony.ports.hazelcast }}
targetPort: hazelcast
protocol: TCP
Expand Down
3 changes: 3 additions & 0 deletions src/main/charts/confluence/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ spec:
targetPort: http
protocol: TCP
name: http
{{- if and (eq .Values.confluence.service.type "NodePort") .Values.confluence.service.nodePort}}
nodePort: {{ .Values.confluence.service.nodePort }}
{{- end }}
{{- if not .Values.confluence.hazelcastService.enabled }}
- port: {{ .Values.confluence.ports.hazelcast }}
targetPort: hazelcast
Expand Down
8 changes: 8 additions & 0 deletions src/main/charts/confluence/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,10 @@ confluence:
#
type: ClusterIP

# -- NodePort for Confluence service
#
nodePort:

# -- 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
Expand Down Expand Up @@ -1209,6 +1213,10 @@ synchrony:
#
type: ClusterIP

# -- NodePort for Synchrony service
#
nodePort:

# -- Use specific loadBalancerIP. Only applies to service type LoadBalancer.
#
loadBalancerIP:
Expand Down
1 change: 1 addition & 0 deletions src/main/charts/crowd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Kubernetes: `>=1.21.x-0`
| crowd.service.annotations | object | `{}` | Additional annotations to apply to the Service |
| crowd.service.contextPath | string | `"/crowd"` | The Tomcat context path that Crowd will use. The ATL_TOMCAT_CONTEXTPATH will be set automatically. |
| crowd.service.loadBalancerIP | string | `nil` | Use specific loadBalancerIP. Only applies to service type LoadBalancer. |
| crowd.service.nodePort | string | `nil` | NodePort for Crowd service |
| crowd.service.port | int | `80` | The port on which the Crowd K8s Service will listen |
| crowd.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 |
| crowd.service.sessionAffinityConfig | object | `{"clientIP":{"timeoutSeconds":null}}` | Session affinity configuration |
Expand Down
3 changes: 3 additions & 0 deletions src/main/charts/crowd/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ spec:
targetPort: http
protocol: TCP
name: http
{{- if and (eq .Values.crowd.service.type "NodePort") .Values.crowd.service.nodePort}}
nodePort: {{ .Values.crowd.service.nodePort }}
{{- end }}
selector:
{{- include "common.labels.selectorLabels" . | nindent 4 }}
4 changes: 4 additions & 0 deletions src/main/charts/crowd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ crowd:
#
type: ClusterIP

# -- NodePort for Crowd service
#
nodePort:

# -- 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
Expand Down
1 change: 1 addition & 0 deletions src/main/charts/jira/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Kubernetes: `>=1.21.x-0`
| jira.service.annotations | object | `{}` | Additional annotations to apply to the Service |
| jira.service.contextPath | string | `nil` | The Tomcat context path that Jira will use. The ATL_TOMCAT_CONTEXTPATH will be set automatically. |
| jira.service.loadBalancerIP | string | `nil` | Use specific loadBalancerIP. Only applies to service type LoadBalancer. |
| jira.service.nodePort | string | `nil` | NodePort for Jira service |
| jira.service.port | int | `80` | The port on which the Jira K8s Service will listen |
| jira.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 |
| jira.service.sessionAffinityConfig | object | `{"clientIP":{"timeoutSeconds":null}}` | Session affinity configuration |
Expand Down
3 changes: 3 additions & 0 deletions src/main/charts/jira/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ spec:
targetPort: http
protocol: TCP
name: http
{{- if and (eq .Values.jira.service.type "NodePort") .Values.jira.service.nodePort}}
nodePort: {{ .Values.jira.service.nodePort }}
{{- end }}
selector:
{{- include "common.labels.selectorLabels" . | nindent 4 }}
4 changes: 4 additions & 0 deletions src/main/charts/jira/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,10 @@ jira:
#
type: ClusterIP

# -- NodePort for Jira service
#
nodePort:

# -- 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
Expand Down
17 changes: 16 additions & 1 deletion src/test/java/test/ServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ void initHelm(TestInfo testInfo) {
void service_port_type(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
product + ".service.port", "1234",
product + ".service.type", "NodePort"
product + ".service.type", "NodePort",
product + ".service.nodePort", "30001",
product + ".service.sshNodePort", "30002",
"synchrony.enabled", "true"

));

final var service = resources.get(Kind.Service, Service.class, product.getHelmReleaseName());
Expand All @@ -39,6 +43,17 @@ void service_port_type(Product product) throws Exception {
.hasTextEqualTo("NodePort");
assertThat(service.getPort("http"))
.hasValueSatisfying(node -> assertThat(node.path("port")).hasValueEqualTo(1234));
assertThat(service.getPort("http"))
.hasValueSatisfying(node -> assertThat(node.path("nodePort")).hasValueEqualTo(30001));
if (product.name().equals("bitbucket")) {
assertThat(service.getPort("ssh"))
.hasValueSatisfying(node -> assertThat(node.path("nodePort")).hasValueEqualTo(30002));
}
if (product.name().equals("confluence")) {
final var synchronyService = resources.get(Kind.Service, Service.class, product.getHelmReleaseName());
assertThat(synchronyService.getPort("http"))
.hasValueSatisfying(node -> assertThat(node.path("nodePort")).hasValueEqualTo(30001));
}
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
template:
metadata:
annotations:
checksum/config-jvm: 7840cc3e79fba7837aee076a182650b787c8f53f1919ec199b7adc3e7b1abccb
checksum/config-jvm: 8587a9721b627f0dfd7a359dbee53d0a010f75d293f03f5a160104dc9d15101a
labels:
app.kubernetes.io/name: bamboo-agent
app.kubernetes.io/instance: unittest-bamboo-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ data:
annotations: {}
contextPath: null
loadBalancerIP: null
nodePort: null
port: 80
sessionAffinity: None
sessionAffinityConfig:
Expand Down Expand Up @@ -450,7 +451,7 @@ spec:
template:
metadata:
annotations:
checksum/config-jvm: 3adff5bd3002b33d2f9ede62864902898e58a0ede65de2c485424c36e855f629
checksum/config-jvm: c41bc799b8b23af6a3170c4635ef9fa71edb855f1d47e25eaa8e8acfa9ca43e1
labels:
helm.sh/chart: bamboo-1.22.1
app.kubernetes.io/name: bamboo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,13 @@ data:
annotations: {}
contextPath: null
loadBalancerIP: null
nodePort: null
port: 80
sessionAffinity: None
sessionAffinityConfig:
clientIP:
timeoutSeconds: null
sshNodePort: null
sshPort: 7999
type: ClusterIP
setPermissions: true
Expand All @@ -249,6 +251,7 @@ data:
enabled: false
host: null
loadBalancerIP: null
nodePort: null
port: 22
type: LoadBalancer
startupProbe:
Expand Down Expand Up @@ -593,7 +596,7 @@ spec:
template:
metadata:
annotations:
checksum/config-jvm: 325d0f8b0fb850d725ad0e9b17f9ffb5afe1e87176215d4c59afaa987034fbc4
checksum/config-jvm: 2749f9462255f51e691b5c20440ba6926c4e36eede24448f852a4c9b9f3293fc
labels:
app.kubernetes.io/name: bitbucket-mesh
app.kubernetes.io/instance: unittest-bitbucket
Expand Down Expand Up @@ -714,7 +717,7 @@ spec:
template:
metadata:
annotations:
checksum/config-jvm: 904ee5cdf24aa3f20010c1bd0a75de5c1755f2b4a68fb2361e1e36e8b8464eec
checksum/config-jvm: 769b21f2174a73dca3bd26f10a6ebcf67d6c70b9481a618d4d0808d6e40799d2
labels:
helm.sh/chart: bitbucket-1.22.1
app.kubernetes.io/name: bitbucket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ data:
annotations: {}
contextPath: null
loadBalancerIP: null
nodePort: null
port: 80
sessionAffinity: None
sessionAffinityConfig:
Expand Down Expand Up @@ -362,6 +363,7 @@ data:
service:
annotations: {}
loadBalancerIP: null
nodePort: null
port: 80
type: ClusterIP
setPermissions: true
Expand Down Expand Up @@ -637,7 +639,7 @@ spec:
template:
metadata:
annotations:
checksum/config-jvm: 0be7e4380d8a71217f79c8ea3e714e9bbc003d9eb19cfe363980fe2f04087fbf
checksum/config-jvm: 12b2bf4a8a471b4be5acc06995810c8331609e8aa3f237e44dd62e27888f85df
labels:
helm.sh/chart: confluence-1.22.1
app.kubernetes.io/name: confluence
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/expected_helm_output/crowd/output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ data:
annotations: {}
contextPath: /crowd
loadBalancerIP: null
nodePort: null
port: 80
sessionAffinity: None
sessionAffinityConfig:
Expand Down Expand Up @@ -374,7 +375,7 @@ spec:
template:
metadata:
annotations:
checksum/config-jvm: 87bf8a70efc8e508ac8cef16c7ec7ed9a4383fbd561d0775996a538f82bda1ef
checksum/config-jvm: 959bd1ffef2f05dc8025f24a6c7e5af1d8c91b90d88d64f7b9e22b80d3553ec3
labels:
helm.sh/chart: crowd-1.22.1
app.kubernetes.io/name: crowd
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/expected_helm_output/jira/output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ data:
annotations: {}
contextPath: null
loadBalancerIP: null
nodePort: null
port: 80
sessionAffinity: None
sessionAffinityConfig:
Expand Down Expand Up @@ -401,7 +402,7 @@ spec:
template:
metadata:
annotations:
checksum/config-jvm: 9874e836468ba673419d9305856e7570c1c7e752338d664e62b9d32180107b9a
checksum/config-jvm: 3294c8cdaf5ff4579163b6eaad63d6ce37838bc0101e7b903b1d2913c5a882a9
labels:
helm.sh/chart: jira-1.22.1
app.kubernetes.io/name: jira
Expand Down
Loading