Skip to content

Commit

Permalink
SCALE-104: Make container name configurable (#661)
Browse files Browse the repository at this point in the history
* Make container name configurable

* Fix var name

* Fix unit test name

* Fix comments

---------

Co-authored-by: Yevhen Ivantsov <[email protected]>
  • Loading branch information
bianchi2 and Yevhen Ivantsov authored Sep 8, 2023
1 parent ae884d9 commit 8dfab26
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/main/charts/bamboo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Kubernetes: `>=1.21.x-0`
| bamboo.sysadminCredentials.usernameSecretKey | string | `"username"` | The key in the Kubernetes Secret that contains the sysadmin username |
| bamboo.topologySpreadConstraints | list | `[]` | Defines topology spread constraints for Bamboo pods. See details: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/ |
| bamboo.unattendedSetup | bool | `true` | To skip the setup wizard post deployment set this property to 'true' and ensure values for all 'REQUIRED' and 'UNATTENDED-SETUP' stanzas (see banner of this file) have been supplied. For release 1.0.0 this value is by default set to 'true' and should not be changed. |
| bamboo.useHelmReleaseNameAsContainerName | bool | `false` | Whether the main container should acquire helm release name. By default the container name is `bamboo` which corresponds to the name of the Helm Chart. |
| database.credentials.passwordSecretKey | string | `"password"` | The key ('password') in the Secret used to store the database login password |
| database.credentials.secretName | string | `nil` | from-literal=password=<password>' https://kubernetes.io/docs/concepts/configuration/secret/#opaque-secrets |
| database.credentials.usernameSecretKey | string | `"username"` | The key ('username') in the Secret used to store the database login username |
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/bamboo/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spec:
{{- end }}
{{- include "common.jmx.initContainer" . | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
- name: {{ if .Values.bamboo.useHelmReleaseNameAsContainerName}}{{ include "common.names.fullname" . }}{{ else }}{{ .Chart.Name }}{{ end }}
image: {{ include "bamboo.image" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
Expand Down
4 changes: 4 additions & 0 deletions src/main/charts/bamboo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ ingress:
#
bamboo:

# -- Whether the main container should acquire helm release name. By default the container name is `bamboo` which corresponds to the name of the Helm Chart.
#
useHelmReleaseNameAsContainerName: false

# -- To skip the setup wizard post deployment set this property to 'true' and
# ensure values for all 'REQUIRED' and 'UNATTENDED-SETUP' stanzas
# (see banner of this file) have been supplied.
Expand Down
1 change: 1 addition & 0 deletions src/main/charts/bitbucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Kubernetes: `>=1.21.x-0`
| bitbucket.sysadminCredentials.secretName | string | `nil` | The name of the Kubernetes Secret that contains the Bitbucket sysadmin credentials If specified, then these will be automatically populated during Bitbucket setup. Otherwise, they will need to be provided via the browser after initial startup. |
| bitbucket.sysadminCredentials.usernameSecretKey | string | `"username"` | The key in the Kubernetes Secret that contains the sysadmin username |
| bitbucket.topologySpreadConstraints | list | `[]` | Defines topology spread constraints for Bitbucket pods. See details: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/ |
| bitbucket.useHelmReleaseNameAsContainerName | bool | `false` | Whether the main container should acquire helm release name. By default the container name is `bitbucket` which corresponds to the name of the Helm Chart. |
| database.credentials.passwordSecretKey | string | `"password"` | The key ('password') in the Secret used to store the database login password |
| database.credentials.secretName | string | `nil` | from-literal=password=<password>' https://kubernetes.io/docs/concepts/configuration/secret/#opaque-secrets |
| database.credentials.usernameSecretKey | string | `"username"` | The key ('username') in the Secret used to store the database login username |
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/bitbucket/templates/statefulset-mesh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
runAsUser: 0 # make sure we run as root to avoid permission denied
{{- end }}
containers:
- name: bitbucket-mesh
- name: {{ if .Values.bitbucket.useHelmReleaseNameAsContainerName}}{{ include "common.names.fullname" . }}-mesh{{ else }}{{ .Chart.Name }}-mesh{{ end }}
image: {{ .Values.bitbucket.mesh.image.repository }}:{{ .Values.bitbucket.mesh.image.tag }}
imagePullPolicy: {{ .Values.bitbucket.mesh.image.pullPolicy }}
ports:
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/bitbucket/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ spec:
{{- end }}
{{- include "common.jmx.initContainer" . | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
- name: {{ if .Values.bitbucket.useHelmReleaseNameAsContainerName}}{{ include "common.names.fullname" . }}{{ else }}{{ .Chart.Name }}{{ end }}
image: {{ include "bitbucket.image" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
Expand Down
4 changes: 4 additions & 0 deletions src/main/charts/bitbucket/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ ingress:
#
bitbucket:

# -- Whether the main container should acquire helm release name. By default the container name is `bitbucket` which corresponds to the name of the Helm Chart.
#
useHelmReleaseNameAsContainerName: false

# K8s Service configuration
#
service:
Expand Down
1 change: 1 addition & 0 deletions src/main/charts/confluence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Kubernetes: `>=1.21.x-0`
| confluence.tomcatConfig.generateByHelm | bool | `false` | Mount server.xml as a ConfigMap. Override configuration elements if necessary |
| confluence.topologySpreadConstraints | list | `[]` | Defines topology spread constraints for Confluence pods. See details: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/ |
| confluence.umask | string | `"0022"` | The umask used by the Confluence process when it creates new files. The default is 0022. This gives the new files: - read/write permissions for the Confluence user - read permissions for everyone else. |
| confluence.useHelmReleaseNameAsContainerName | bool | `false` | Whether the main container should acquire helm release name. By default the container name is `confluence` which corresponds to the name of the Helm Chart. |
| database.credentials.passwordSecretKey | string | `"password"` | The key ('password') in the Secret used to store the database login password |
| database.credentials.secretName | string | `nil` | from-literal=password=<password>' https://kubernetes.io/docs/concepts/configuration/secret/#opaque-secrets |
| database.credentials.usernameSecretKey | string | `"username"` | The key ('username') in the Secret used to store the database login username |
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/confluence/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
{{- end }}
{{- include "common.jmx.initContainer" . | nindent 8 }}
containers:
- name: confluence
- name: {{ if .Values.confluence.useHelmReleaseNameAsContainerName}}{{ include "common.names.fullname" . }}{{ else }}{{ .Chart.Name }}{{ end }}
image: {{ include "confluence.image" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
Expand Down
4 changes: 4 additions & 0 deletions src/main/charts/confluence/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,10 @@ ingress:
#
confluence:

# -- Whether the main container should acquire helm release name. By default the container name is `confluence` which corresponds to the name of the Helm Chart.
#
useHelmReleaseNameAsContainerName: false

# K8s Confluence Service configuration
#
service:
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 @@ -75,6 +75,7 @@ Kubernetes: `>=1.21.x-0`
| crowd.startupProbe.periodSeconds | int | `5` | How often (in seconds) the Crowd container startup probe will run |
| crowd.topologySpreadConstraints | list | `[]` | Defines topology spread constraints for Crowd pods. See details: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/ |
| crowd.umask | string | `"0022"` | The umask used by the Crowd process when it creates new files. The default is 0022. This gives the new files: - read/write permissions for the Crowd user - read permissions for everyone else. |
| crowd.useHelmReleaseNameAsContainerName | bool | `false` | Whether the main container should acquire helm release name. By default the container name is `crowd` which corresponds to the name of the Helm Chart. |
| fluentd.command | string | `nil` | The command used to start Fluentd. If not supplied the default command will be used: "fluentd -c /fluentd/etc/fluent.conf -v" Note: The custom command can be free-form, however pay particular attention to the process that should ultimately be left running in the container. This process should be invoked with 'exec' so that signals are appropriately propagated to it, for instance SIGTERM. An example of how such a command may look is: "<command 1> && <command 2> && exec <primary command>" |
| fluentd.customConfigFile | bool | `false` | Set to 'true' if a custom config (see 'configmap-fluentd.yaml' for default) should be used for Fluentd. If enabled this config must be supplied via the 'fluentdCustomConfig' property below. |
| fluentd.elasticsearch.enabled | bool | `true` | Set to 'true' if Fluentd should send all log events to an Elasticsearch service. |
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/crowd/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
{{- end }}
{{- include "common.jmx.initContainer" . | nindent 8 }}
containers:
- name: crowd
- name: {{ if .Values.crowd.useHelmReleaseNameAsContainerName}}{{ include "common.names.fullname" . }}{{ else }}{{ .Chart.Name }}{{ end }}
image: {{ include "crowd.image" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
Expand Down
4 changes: 4 additions & 0 deletions src/main/charts/crowd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ serviceAccount:
#
crowd:

# -- Whether the main container should acquire helm release name. By default the container name is `crowd` which corresponds to the name of the Helm Chart.
#
useHelmReleaseNameAsContainerName: false

# K8s Crowd Service configuration
#
service:
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 @@ -119,6 +119,7 @@ Kubernetes: `>=1.21.x-0`
| jira.tomcatConfig.customServerXml | string | `""` | Custom server.xml to be mounted into /opt/atlassian/jira/conf |
| jira.tomcatConfig.generateByHelm | bool | `false` | Mount server.xml as a ConfigMap. Override configuration elements if necessary |
| jira.topologySpreadConstraints | list | `[]` | Defines topology spread constraints for Jira pods. See details: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/ |
| jira.useHelmReleaseNameAsContainerName | bool | `false` | Whether the main container should acquire helm release name. The default, the container name is jira (Helm chart name) |
| monitoring.exposeJmxMetrics | bool | `false` | Expose JMX metrics with jmx_exporter https://github.com/prometheus/jmx_exporter |
| monitoring.fetchJmxExporterJar | bool | `true` | Fetch jmx_exporter jar from the image. If set to false make sure to manually copy the jar to shared home and provide an absolute path in jmxExporterCustomJarLocation |
| monitoring.grafana.createDashboards | bool | `false` | Create ConfigMaps with Grafana dashboards |
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/jira/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
{{- end }}
{{- include "common.jmx.initContainer" . | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
- name: {{ if .Values.jira.useHelmReleaseNameAsContainerName}}{{ include "common.names.fullname" . }}{{ else }}{{ .Chart.Name }}{{ end }}
image: {{ include "jira.image" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
Expand Down
6 changes: 5 additions & 1 deletion src/main/charts/jira/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ ingress:
#
jira:

# -- Whether the main container should acquire helm release name. The default, the container name is jira (Helm chart name)
#
useHelmReleaseNameAsContainerName: false

# K8s Service configuration
#
service:
Expand Down Expand Up @@ -798,7 +802,7 @@ monitoring:
# -- Expose JMX metrics with jmx_exporter https://github.com/prometheus/jmx_exporter
#
exposeJmxMetrics: false

# -- Annotations added to the jmx service
#
jmxServiceAnnotations: {}
Expand Down
20 changes: 20 additions & 0 deletions src/test/java/test/ContainersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,24 @@ void additionalContainers(Product product) throws Exception {
final var icontainer = statefulSet.getContainer("my_container");
assertThat(icontainer.get("image")).hasTextEqualTo("my_image");
}

@ParameterizedTest
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE)
void defaultContainerNames(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of());
final var statefulSet = resources.getStatefulSet(product.getHelmReleaseName());
final var containerName = statefulSet.getContainer().get("name");
assertThat(containerName).hasTextEqualTo(product.name());
}

@ParameterizedTest
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE)
void containerNamesAsHelmReleaseName(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
product.name() + ".useHelmReleaseNameAsContainerName", "true"
));
final var statefulSet = resources.getStatefulSet(product.getHelmReleaseName());
final var containerName = statefulSet.getContainer().get("name");
assertThat(containerName).hasTextEqualTo(product.getHelmReleaseName());
}
}

0 comments on commit 8dfab26

Please sign in to comment.