-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PodDisruptionBudget to Atlassian DC Helm Charts (#636)
* Add PodDisruptionBudget * Rename pdb property * Update docs --------- Co-authored-by: Yevhen Ivantsov <[email protected]>
- Loading branch information
Showing
17 changed files
with
264 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{- if .Values.podDisruptionBudget.enabled }} | ||
apiVersion: policy/v1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: {{ include "common.names.fullname" . }} | ||
labels: | ||
{{- include "common.labels.commonLabels" . | nindent 4 }} | ||
{{- with .Values.podDisruptionBudget.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- with .Values.podDisruptionBudget.annotations }} | ||
annotations: | ||
{{- range $key, $value := . }} | ||
{{ $key }}: {{ $value | quote }} | ||
{{- end }} | ||
{{- end }} | ||
spec: | ||
{{- with .Values.podDisruptionBudget.maxUnavailable }} | ||
maxUnavailable: {{ . }} | ||
{{- else }} | ||
minAvailable: {{ .Values.podDisruptionBudget.minAvailable | default 0 }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
{{- include "common.labels.selectorLabels" . | nindent 6 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{- if .Values.podDisruptionBudget.enabled }} | ||
apiVersion: policy/v1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: {{ include "common.names.fullname" . }} | ||
labels: | ||
{{- include "common.labels.commonLabels" . | nindent 4 }} | ||
{{- with .Values.podDisruptionBudget.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- with .Values.podDisruptionBudget.annotations }} | ||
annotations: | ||
{{- range $key, $value := . }} | ||
{{ $key }}: {{ $value | quote }} | ||
{{- end }} | ||
{{- end }} | ||
spec: | ||
{{- with .Values.podDisruptionBudget.maxUnavailable }} | ||
maxUnavailable: {{ . }} | ||
{{- else }} | ||
minAvailable: {{ .Values.podDisruptionBudget.minAvailable | default 0 }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
{{- include "common.labels.selectorLabels" . | nindent 6 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{- if .Values.podDisruptionBudget.enabled }} | ||
apiVersion: policy/v1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: {{ include "common.names.fullname" . }} | ||
labels: | ||
{{- include "common.labels.commonLabels" . | nindent 4 }} | ||
{{- with .Values.podDisruptionBudget.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- with .Values.podDisruptionBudget.annotations }} | ||
annotations: | ||
{{- range $key, $value := . }} | ||
{{ $key }}: {{ $value | quote }} | ||
{{- end }} | ||
{{- end }} | ||
spec: | ||
{{- with .Values.podDisruptionBudget.maxUnavailable }} | ||
maxUnavailable: {{ . }} | ||
{{- else }} | ||
minAvailable: {{ .Values.podDisruptionBudget.minAvailable | default 0 }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
{{- include "common.labels.selectorLabels" . | nindent 6 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{- if .Values.podDisruptionBudget.enabled }} | ||
apiVersion: policy/v1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: {{ include "common.names.fullname" . }} | ||
labels: | ||
{{- include "common.labels.commonLabels" . | nindent 4 }} | ||
{{- with .Values.podDisruptionBudget.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- with .Values.podDisruptionBudget.annotations }} | ||
annotations: | ||
{{- range $key, $value := . }} | ||
{{ $key }}: {{ $value | quote }} | ||
{{- end }} | ||
{{- end }} | ||
spec: | ||
{{- with .Values.podDisruptionBudget.maxUnavailable }} | ||
maxUnavailable: {{ . }} | ||
{{- else }} | ||
minAvailable: {{ .Values.podDisruptionBudget.minAvailable | default 0 }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
{{- include "common.labels.selectorLabels" . | nindent 6 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{- if .Values.podDisruptionBudget.enabled }} | ||
apiVersion: policy/v1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: {{ include "common.names.fullname" . }} | ||
labels: | ||
{{- include "common.labels.commonLabels" . | nindent 4 }} | ||
{{- with .Values.podDisruptionBudget.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- with .Values.podDisruptionBudget.annotations }} | ||
annotations: | ||
{{- range $key, $value := . }} | ||
{{ $key }}: {{ $value | quote }} | ||
{{- end }} | ||
{{- end }} | ||
spec: | ||
{{- with .Values.podDisruptionBudget.maxUnavailable }} | ||
maxUnavailable: {{ . }} | ||
{{- else }} | ||
minAvailable: {{ .Values.podDisruptionBudget.minAvailable | default 0 }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
{{- include "common.labels.selectorLabels" . | nindent 6 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package test; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.TestInfo; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EnumSource; | ||
import test.helm.Helm; | ||
import test.model.*; | ||
|
||
import java.util.Map; | ||
|
||
import static test.jackson.JsonNodeAssert.assertThat; | ||
|
||
public class PodDisruptionBudgetTest { | ||
|
||
private Helm helm; | ||
|
||
@BeforeEach | ||
void initHelm(TestInfo testInfo) { | ||
helm = new Helm(testInfo); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE) | ||
void pod_disruption_budget_enabled_min_available(Product product) throws Exception { | ||
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( | ||
"podDisruptionBudget.enabled", "true", | ||
"podDisruptionBudget.minAvailable", "1" | ||
)); | ||
|
||
KubeResource pdb = resources.get(Kind.PodDisruptionBudget, product.getHelmReleaseName()); | ||
assertThat(pdb.getSpec().get("minAvailable")).hasValueEqualTo(1); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE) | ||
void pod_disruption_budget_min_available_max_unavailable(Product product) throws Exception { | ||
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( | ||
"podDisruptionBudget.enabled", "true", | ||
"podDisruptionBudget.minAvailable", "1", | ||
"podDisruptionBudget.maxUnavailable", "2" | ||
)); | ||
|
||
// assert that when both mixAvailable and maxUnavailable are defined, only maxUnavailable is set in pdb | ||
KubeResource pdb = resources.get(Kind.PodDisruptionBudget, product.getHelmReleaseName()); | ||
assertThat(pdb.getSpec().get("maxUnavailable")).hasValueEqualTo(2); | ||
assertThat(pdb.getSpec().path("minAvailable")).isEmpty(); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE) | ||
void pod_disruption_budget_annotations(Product product) throws Exception { | ||
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( | ||
"podDisruptionBudget.enabled", "true", | ||
"podDisruptionBudget.minAvailable", "1", | ||
"podDisruptionBudget.annotations.foo", "bar" | ||
)); | ||
|
||
KubeResource pdb = resources.get(Kind.PodDisruptionBudget, product.getHelmReleaseName()); | ||
assertThat(pdb.getAnnotations().path("foo")).hasTextEqualTo("bar"); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE) | ||
void pod_disruption_budget_labels(Product product) throws Exception { | ||
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( | ||
"podDisruptionBudget.enabled", "true", | ||
"podDisruptionBudget.minAvailable", "1", | ||
"podDisruptionBudget.labels.foo", "bar" | ||
)); | ||
|
||
KubeResource pdb = resources.get(Kind.PodDisruptionBudget, product.getHelmReleaseName()); | ||
assertThat(pdb.getMetadata().path("labels").path("foo")).hasTextEqualTo("bar"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters