Skip to content

Commit

Permalink
Make it possible to create a dedicated hazelcast svc
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevhen Ivantsov committed Oct 8, 2023
1 parent 347bf3a commit 322ec0c
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/charts/bitbucket/templates/service-hazelcast.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ if .Values.bitbucket.hazelcastService.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "common.names.fullname" . }}-hazelcast
labels:
{{- include "common.labels.commonLabels" . | nindent 4 }}
annotations:
{{- with .Values.bitbucket.hazelcastService.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.bitbucket.service.type }}
ports:
- port: {{ .Values.bitbucket.ports.hazelcast }}
targetPort: hazelcast
protocol: TCP
name: hazelcast
selector:
{{- include "common.labels.selectorLabels" . | nindent 4 }}
{{ end }}
2 changes: 2 additions & 0 deletions src/main/charts/bitbucket/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ spec:
targetPort: ssh
protocol: TCP
name: ssh
{{- if not .Values.bitbucket.hazelcastService.enabled }}
- port: {{ .Values.bitbucket.ports.hazelcast }}
targetPort: hazelcast
protocol: TCP
name: hazelcast
{{- end }}
selector:
{{- include "common.labels.selectorLabels" . | nindent 4 }}
20 changes: 20 additions & 0 deletions src/main/charts/bitbucket/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,26 @@ bitbucket:
#
annotations: {}

hazelcastService:

# -- Enable or disable an additional Hazelcast service Bitbucket nodes use to join a cluster
# It is recommended to create a separate Hazelcast service if Bitbucket service
# is of LoadBalancer type (e.g. NLB), i.e. not expose Hazelcast port at all
#
enabled: false

# -- The port on which the Bitbucket K8s Hazelcast Service will listen
#
port: 5701

# -- The type of the Hazelcast K8s service to use for Bitbucket
#
type: ClusterIP

# -- Additional annotations to apply to the Hazelcast Service
#
annotations: {}

# Standard K8s field that holds pod-level security attributes and common container settings.
# https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
# Do not populate when deploying to OpenShift, unless anyuid policy is attached to a service account.
Expand Down
21 changes: 21 additions & 0 deletions src/main/charts/confluence/templates/service-hazelcast.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ if .Values.confluence.hazelcastService.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "common.names.fullname" . }}-hazelcast
labels:
{{- include "common.labels.commonLabels" . | nindent 4 }}
annotations:
{{- with .Values.confluence.hazelcastService.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.confluence.service.type }}
ports:
- port: {{ .Values.confluence.ports.hazelcast }}
targetPort: hazelcast
protocol: TCP
name: hazelcast
selector:
{{- include "common.labels.selectorLabels" . | nindent 4 }}
{{ end }}
2 changes: 2 additions & 0 deletions src/main/charts/confluence/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ spec:
targetPort: http
protocol: TCP
name: http
{{- if not .Values.confluence.hazelcastService.enabled }}
- port: {{ .Values.confluence.ports.hazelcast }}
targetPort: hazelcast
protocol: TCP
name: hazelcast
{{- end }}
selector:
{{- include "common.labels.selectorLabels" . | nindent 4 }}
20 changes: 20 additions & 0 deletions src/main/charts/confluence/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,26 @@ confluence:
#
annotations: {}

hazelcastService:

# -- Enable or disable an additional Hazelcast service Confluence nodes use to join a cluster
# It is recommended to create a separate Hazelcast service if Confluence service
# is of LoadBalancer type (e.g. NLB), i.e. not expose Hazelcast port at all
#
enabled: false

# -- The port on which the Confluence K8s Hazelcast Service will listen
#
port: 5701

# -- The type of the Hazelcast K8s service to use for Confluence
#
type: ClusterIP

# -- Additional annotations to apply to the Hazelcast Service
#
annotations: {}

# Standard K8s field that holds pod-level security attributes and common container settings.
# https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
# Do not populate when deploying to OpenShift, unless anyuid policy is attached to a service account.
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/test/ServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,31 @@ void synchrony_service_custom_annotations(Product product) throws Exception {
"confluence", "qwerty-synchrony"
));
}

@ParameterizedTest
@EnumSource(value = Product.class, names = {"bitbucket", "confluence"})
void dedicated_hazelcast_service(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
product.name() + ".hazelcastService.enabled", "true"
));

final var hazelcastService = resources.get(Kind.Service, Service.class, product.getHelmReleaseName() + "-hazelcast");

assertThat(hazelcastService.getType()).hasTextEqualTo("ClusterIP");
assertThat(hazelcastService.getPort("hazelcast"))
.hasValueSatisfying(node -> assertThat(node.path("port")).hasValueEqualTo(5701));

final var service = resources.get(Kind.Service, Service.class, product.getHelmReleaseName());
assertThat(service.getPort("hazelcast")).isEmpty();
}

@ParameterizedTest
@EnumSource(value = Product.class, names = {"bitbucket", "confluence"})
void hazelcast_one_service(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of());

final var service = resources.get(Kind.Service, Service.class, product.getHelmReleaseName());
assertThat(service.getPort("hazelcast"))
.hasValueSatisfying(node -> assertThat(node.path("port")).hasValueEqualTo(5701));
}
}

0 comments on commit 322ec0c

Please sign in to comment.