Skip to content

Commit

Permalink
use a distinct deployment template for rsyncd to be able to set its r…
Browse files Browse the repository at this point in the history
…eplica count independently from mirrorbits deployment
  • Loading branch information
lemeurherve committed Aug 22, 2023
1 parent 1822a82 commit b483454
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 50 deletions.
64 changes: 64 additions & 0 deletions charts/mirrorbits/templates/deployment.rsyncd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{ if and .Values.rsyncd.service.enabled .Values.repository.persistentVolumeClaim.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mirrorbits.fullname" . }}
labels:
{{ include "mirrorbits.labels" . | indent 4 }}
spec:
replicas: {{ .Values.replicaCount.rsyncd }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "mirrorbits.name" . }}-rsyncd
app.kubernetes.io/instance: {{ .Release.Name }}-rsyncd
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "mirrorbits.name" . }}-rsyncd
app.kubernetes.io/instance: {{ .Release.Name }}-rsyncd
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "mirrorbits.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: rsyncd
image: "{{ .Values.image.rsyncd.repository }}:{{ .Values.image.rsyncd.tag }}"
imagePullPolicy: {{ .Values.image.rsyncd.pullPolicy }}
ports:
- name: rsyncd
containerPort: 873
protocol: TCP
livenessProbe:
tcpSocket:
port: 873
readinessProbe:
tcpSocket:
port: 873
resources:
{{- toYaml .Values.rsyncd.resources | nindent 12 }}
volumeMounts:
- name: binary
mountPath: /srv/repo
readOnly: true

{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: binary
persistentVolumeClaim:
claimName: {{ .Values.repository.name | default (printf "%s-binary" (include "mirrorbits.fullname" .)) }}
{{- end }}
23 changes: 0 additions & 23 deletions charts/mirrorbits/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,6 @@ spec:
envFrom:
- secretRef:
name: {{ include "mirrorbits.fullname" . }}-geoipupdate
{{ if .Values.rsyncd.service.enabled -}}
- name: rsyncd
image: "{{ .Values.image.rsyncd.repository }}:{{ .Values.image.rsyncd.tag }}"
imagePullPolicy: {{ .Values.image.rsyncd.pullPolicy }}
ports:
- name: rsyncd
containerPort: 873
protocol: TCP
livenessProbe:
tcpSocket:
port: 873
readinessProbe:
tcpSocket:
port: 873
resources:
{{- toYaml .Values.rsyncd.resources | nindent 12 }}
volumeMounts:
{{- if .Values.repository.persistentVolumeClaim.enabled }}
- name: binary
mountPath: /srv/repo
readOnly: true
{{- end }}
{{- end }}
initContainers:
# we need to ensure the geoip data is in place before mirrorbits starts
- name: geoipupdate-init
Expand Down
2 changes: 1 addition & 1 deletion charts/mirrorbits/templates/service.rsyncd.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.rsyncd.service.enabled -}}
{{- if and .Values.rsyncd.service.enabled .Values.repository.persistentVolumeClaim.enabled -}}
apiVersion: v1
kind: Service
metadata:
Expand Down
41 changes: 31 additions & 10 deletions charts/mirrorbits/tests/custom_values_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ values:
templates:
- deployment.yaml
- deployment.files.yaml
- deployment.rsyncd.yaml
- ingress.yaml
- ingress.rsyncd.yaml
- secret.yaml # Direct dependency of deployment.yaml
- secret.yaml # Direct dependency of deployment(.*).yaml
- service.files.yaml
- service.rsyncd.yaml
tests:
Expand Down Expand Up @@ -100,30 +101,47 @@ tests:
- equal:
path: spec.template.spec.containers[*].imagePullPolicy
value: Always
- it: should define a rsyncd container if rsyncd service is enabled
template: deployment.yaml
- it: should create rsyncd deployment if rsyncd service is enabled and PVC is enabled
template: deployment.rsyncd.yaml
set:
rsyncd:
service:
enabled: true
repository:
persistentVolumeClaim:
enabled: true
asserts:
- contains:
path: spec.template.spec.containers
content:
name: rsyncd
any: true # Ignores any other values within the found content
- it: should create rsyncd service only if rsyncd service is enabled
- hasDocuments:
count: 1
- isKind:
of: Deployment
- it: should create rsyncd deployment if only rsyncd service is enabled
template: deployment.rsyncd.yaml
set:
rsyncd:
service:
enabled: true
repository:
persistentVolumeClaim:
enabled: false
asserts:
- hasDocuments:
count: 0
- it: should create rsyncd service if rsyncd service and PVC are enabled
template: service.rsyncd.yaml
set:
rsyncd:
service:
enabled: true
repository:
persistentVolumeClaim:
enabled: true
asserts:
- hasDocuments:
count: 1
- isKind:
of: Service
- it: should create rsyncd ingress only if rsyncd ingress and service are enabled
- it: should create rsyncd ingress if rsyncd ingress & service and PVC are enabled
template: ingress.rsyncd.yaml
set:
rsyncd:
Expand All @@ -136,6 +154,9 @@ tests:
paths:
- path: /
pathType: IfNotPresent
repository:
persistentVolumeClaim:
enabled: true
asserts:
- hasDocuments:
count: 1
Expand Down
24 changes: 8 additions & 16 deletions charts/mirrorbits/tests/defaults_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ values:
- ../values.yaml
- secrets_default_values.yaml
templates:
- deployment.files.yaml
- deployment.yaml
- deployment.files.yaml
- deployment.rsyncd.yaml
- ingress.yaml
- ingress.rsyncd.yaml
- secret.yaml # Direct dependency of deployment.yaml
- secret.yaml # Direct dependency of deployment(.*).yaml
- service.files.yaml
- service.rsyncd.yaml
tests:
Expand All @@ -26,6 +27,11 @@ tests:
asserts:
- hasDocuments:
count: 0
- it: should not create any rsyncd deployment by default
template: deployment.rsyncd.yaml
asserts:
- hasDocuments:
count: 0
- it: should create ingress with pathType set to Prefix by default
template: ingress.yaml
set:
Expand Down Expand Up @@ -85,17 +91,3 @@ tests:
- equal:
path: "spec.template.spec.containers[*].imagePullPolicy"
value: IfNotPresent
- it: should define the default "mirrorbits" deployment with default imagePullPolicy and without any rsyncd container
template: deployment.yaml
asserts:
- hasDocuments:
count: 1
- isKind:
of: Deployment
- equal:
path: spec.template.spec.containers[*].imagePullPolicy
value: IfNotPresent
- notContains:
path: spec.template.spec.containers
content:
name: rsyncd
1 change: 1 addition & 0 deletions charts/mirrorbits/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
replicaCount:
mirrorbits: 1
files: 1
rsyncd: 1
image:
mirrorbits:
repository: jenkinsciinfra/mirrorbits
Expand Down

0 comments on commit b483454

Please sign in to comment.