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

Add s3 backups to Helm values #907

Merged
merged 3 commits into from
Nov 14, 2024
Merged
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
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
Loading