Skip to content

Commit

Permalink
Merge pull request jenkins-infra#807 from smerle33/PDB/ACP
Browse files Browse the repository at this point in the history
feat(artifact-caching-proxy): add PodDisruptionBudget
  • Loading branch information
dduportal authored Sep 28, 2023
2 parents d0f5324 + 67ad006 commit 5bc0cbb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/artifact-caching-proxy/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v2
description: artifact-caching-proxy is a Nginx caching proxy in front of repo.jenkins-ci.org
name: artifact-caching-proxy
type: application
version: 0.14.0
version: 0.15.0
18 changes: 18 additions & 0 deletions charts/artifact-caching-proxy/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if (gt (int .Values.replicaCount) 1) }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ include "artifact-caching-proxy.fullname" . }}
labels:
{{- include "artifact-caching-proxy.labels" . | nindent 4 }}
spec:
{{- with .Values.poddisruptionbudget.minAvailable }}
minAvailable: {{ . }}
{{- end }}
{{- with .Values.poddisruptionbudget.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
selector:
matchLabels:
{{- include "artifact-caching-proxy.selectorLabels" . | nindent 6 }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/artifact-caching-proxy/tests/custom_values_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ suite: Tests with custom values
templates:
- ingress-health.yaml
- ingress.yaml
- pdb.yaml
tests:
- it: Should set a custom health check path when specified by values
template: ingress.yaml
Expand Down Expand Up @@ -50,3 +51,19 @@ tests:
path: metadata.annotations
value:
a-custom/annotation: "hello world"

- it: should ensure the pdb has correct spec
template: pdb.yaml
set:
replicaCount: 2
poddisruptionbudget.minAvailable: 2
poddisruptionbudget.maxUnavailable: 1
asserts:
- isKind:
of: PodDisruptionBudget
- equal:
path: spec.minAvailable
value: 2
- equal:
path: spec.selector.matchLabels['app.kubernetes.io/name']
value: "artifact-caching-proxy"
12 changes: 12 additions & 0 deletions charts/artifact-caching-proxy/tests/defaults_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ templates:
- nginx-proxy-configmap.yaml
- nginx-default-configmap.yaml
- statefulset.yaml
- pdb.yaml
tests:
- it: should not generate any ingress with default values
template: ingress.yaml
Expand Down Expand Up @@ -36,3 +37,14 @@ tests:
of: StatefulSet
- notExists:
path: spec.affinity
- equal:
path: metadata.labels["app.kubernetes.io/name"]
value: artifact-caching-proxy
- equal:
path: metadata.labels["app.kubernetes.io/managed-by"]
value: Helm
- it: should not generate any pdb with default values
template: pdb.yaml
asserts:
- hasDocuments:
count: 0

0 comments on commit 5bc0cbb

Please sign in to comment.