Skip to content

Commit

Permalink
Add s3 backups to Helm values (#907)
Browse files Browse the repository at this point in the history
* Add s3 backups to Helm values

* Add s3 backups to Helm values

* Add s3 backups to Helm values

---------

Co-authored-by: Yevhen Ivantsov <yivantsov@atlassian.com>
  • Loading branch information
bianchi2 and Yevhen Ivantsov authored Nov 14, 2024
1 parent 394e63f commit f86fb92
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 23 deletions.
10 changes: 10 additions & 0 deletions src/main/charts/jira/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,16 @@ volumeClaimTemplates:
value: {{ .Values.jira.s3Storage.attachments.endpointOverride | quote }}
{{- end }}
{{- end }}
{{- if and .Values.jira.s3Storage.backups.bucketName .Values.jira.s3Storage.backups.bucketRegion }}
- name: ATL_S3BACKUPS_BUCKET_NAME
value: {{ .Values.jira.s3Storage.backups.bucketName | quote }}
- name: ATL_S3BACKUPS_REGION
value: {{ .Values.jira.s3Storage.backups.bucketRegion | quote }}
{{- if .Values.jira.s3Storage.backups.endpointOverride }}
- name: ATL_S3BACKUPS_ENDPOINT_OVERRIDE
value: {{ .Values.jira.s3Storage.backups.endpointOverride | quote }}
{{- end }}
{{- end }}
{{- end }}

{{- define "jira.databaseEnvVars" -}}
Expand Down
15 changes: 15 additions & 0 deletions src/main/charts/jira/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,21 @@ jira:
#
endpointOverride:

backups:
# -- Bucket name to store backups. If a bucket name and region (see below) are defined, Jira will automatically
# use AWS S3 to store backups. Only bucket name is required, not the full arn.
# If you provide the same bucket name for both avatars and backups, they will be stored in the same bucket
#
bucketName:

# -- AWS region where the S3 bucket is located.
#
bucketRegion:

# -- Override the default AWS API endpoint with a custom one
#
endpointOverride:

# Data Center clustering
#
clustering:
Expand Down
52 changes: 29 additions & 23 deletions src/test/java/test/JiraS3EnabledTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import test.helm.Helm;
import test.model.Product;

import java.util.List;
import java.util.Map;

class JiraS3EnabledTest {
Expand All @@ -17,38 +18,43 @@ void initHelm(TestInfo testInfo) {
helm = new Helm(testInfo);
}

private static final List<String> STORAGE_TYPES = List.of("avatars", "attachments", "backups");

@ParameterizedTest
@EnumSource(value = Product.class, names = {"jira"})
void jira_s3_avatars_storage_env_vars(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
product + ".s3Storage.avatars.bucketName", "my-bucket",
product + ".s3Storage.avatars.bucketRegion", "my-region"
));
void s3_storage_env_vars(Product product) throws Exception {
for (String storageType : STORAGE_TYPES) {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
product + ".s3Storage." + storageType + ".bucketName", "my-bucket",
product + ".s3Storage." + storageType + ".bucketRegion", "my-region"
));

resources.getStatefulSet(product.getHelmReleaseName())
.getContainer()
.getEnv()
.assertHasValue("ATL_S3AVATARS_BUCKET_NAME", "my-bucket")
.assertHasValue("ATL_S3AVATARS_REGION", "my-region")
.assertDoesNotHaveAnyOf("ATL_S3AVATARS_ENDPOINT_OVERRIDE");
resources.getStatefulSet(product.getHelmReleaseName())
.getContainer()
.getEnv()
.assertHasValue("ATL_S3" + storageType.toUpperCase() + "_BUCKET_NAME", "my-bucket")
.assertHasValue("ATL_S3" + storageType.toUpperCase() + "_REGION", "my-region")
.assertDoesNotHaveAnyOf("ATL_S3" + storageType.toUpperCase() + "_ENDPOINT_OVERRIDE");
}
}

@ParameterizedTest
@EnumSource(value = Product.class, names = {"jira"})
void jira_s3_avatars_storage_endpoint_override(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
product + ".s3Storage.avatars.bucketName", "my-bucket",
product + ".s3Storage.avatars.bucketRegion", "my-region",
product + ".s3Storage.avatars.endpointOverride", "http://minio.svc.cluster.local"
));
void s3_storage_endpoint_override(Product product) throws Exception {
for (String storageType : STORAGE_TYPES) {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
product + ".s3Storage." + storageType + ".bucketName", "my-bucket",
product + ".s3Storage." + storageType + ".bucketRegion", "my-region",
product + ".s3Storage." + storageType + ".endpointOverride", "http://minio.svc.cluster.local"
));

resources.getStatefulSet(product.getHelmReleaseName())
.getContainer()
.getEnv()
.assertHasValue("ATL_S3AVATARS_BUCKET_NAME", "my-bucket")
.assertHasValue("ATL_S3AVATARS_REGION", "my-region")
.assertHasValue("ATL_S3AVATARS_ENDPOINT_OVERRIDE", "http://minio.svc.cluster.local");
resources.getStatefulSet(product.getHelmReleaseName())
.getContainer()
.getEnv()
.assertHasValue("ATL_S3" + storageType.toUpperCase() + "_BUCKET_NAME", "my-bucket")
.assertHasValue("ATL_S3" + storageType.toUpperCase() + "_REGION", "my-region")
.assertHasValue("ATL_S3" + storageType.toUpperCase() + "_ENDPOINT_OVERRIDE", "http://minio.svc.cluster.local");
}
}

@ParameterizedTest
Expand Down
4 changes: 4 additions & 0 deletions src/test/resources/expected_helm_output/jira/output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ data:
bucketName: null
bucketRegion: null
endpointOverride: null
backups:
bucketName: null
bucketRegion: null
endpointOverride: null
securityContext:
fsGroup: 2001
securityContextEnabled: true
Expand Down

1 comment on commit f86fb92

@eduardoalvarenga
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error in Bamboo Specs

📜 View error logs

Please sign in to comment.