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

Support annotations on volumeClaimTemplates #23433

Merged
merged 1 commit into from
May 3, 2022
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
4 changes: 4 additions & 0 deletions chart/templates/redis/redis-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ spec:
volumeClaimTemplates:
- metadata:
name: redis-db
{{- if .Values.redis.persistence.annotations }}
annotations:
{{- toYaml .Values.redis.persistence.annotations | nindent 10 }}
{{- end }}
spec:
{{- if .Values.redis.persistence.storageClassName }}
storageClassName: {{ .Values.redis.persistence.storageClassName }}
Expand Down
4 changes: 4 additions & 0 deletions chart/templates/scheduler/scheduler-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ spec:
volumeClaimTemplates:
- metadata:
name: logs
{{- if .Values.workers.persistence.annotations }}
annotations:
{{- toYaml .Values.workers.persistence.annotations | nindent 10 }}
{{- end }}
spec:
{{- if .Values.workers.persistence.storageClassName }}
storageClassName: {{ .Values.workers.persistence.storageClassName }}
Expand Down
4 changes: 4 additions & 0 deletions chart/templates/workers/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ spec:
volumeClaimTemplates:
- metadata:
name: logs
{{- if .Values.workers.persistence.annotations }}
annotations:
{{- toYaml .Values.workers.persistence.annotations | nindent 10 }}
{{- end }}
spec:
{{- if .Values.workers.persistence.storageClassName }}
storageClassName: {{ .Values.workers.persistence.storageClassName }}
Expand Down
16 changes: 16 additions & 0 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,14 @@
"description": "Execute init container to chown log directory. This is currently only needed in kind, due to usage of local-path provisioner.",
"type": "boolean",
"default": false
},
"annotations": {
"description": "Annotations to add to worker volumes.",
"type": "object",
"default": {},
"additionalProperties": {
"type": "string"
}
}
}
},
Expand Down Expand Up @@ -3689,6 +3697,14 @@
"null"
],
"default": null
},
"annotations": {
"description": "Annotations to add to redis volumes.",
"type": "object",
"default": {},
"additionalProperties": {
"type": "string"
}
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ workers:
# This is currently only needed in kind, due to usage
# of local-path provisioner.
fixPermissions: false
# Annotations to add to worker volumes
annotations: {}

kerberosSidecar:
# Enable kerberos sidecar
Expand Down Expand Up @@ -1305,6 +1307,8 @@ redis:
size: 1Gi
# If using a custom storageClass, pass name ref to all statefulSets here
storageClassName:
# Annotations to add to redis volumes
annotations: {}

resources: {}
# limits:
Expand Down
7 changes: 7 additions & 0 deletions tests/charts/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,10 @@ def test_should_set_correct_helm_hooks_weight(self):
)
annotations = jmespath.search("metadata.annotations", docs[0])
assert annotations["helm.sh/hook-weight"] == "0"

def test_persistence_volume_annotations(self):
docs = render_chart(
values={"redis": {"persistence": {"annotations": {"foo": "bar"}}}},
show_only=["templates/redis/redis-statefulset.yaml"],
)
assert {"foo": "bar"} == jmespath.search("spec.volumeClaimTemplates[0].metadata.annotations", docs[0])
7 changes: 7 additions & 0 deletions tests/charts/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,3 +530,10 @@ def test_log_groomer_resources(self):
"memory": "2Gi",
},
} == jmespath.search("spec.template.spec.containers[1].resources", docs[0])

def test_persistence_volume_annotations(self):
docs = render_chart(
values={"executor": "LocalExecutor", "workers": {"persistence": {"annotations": {"foo": "bar"}}}},
show_only=["templates/scheduler/scheduler-deployment.yaml"],
)
assert {"foo": "bar"} == jmespath.search("spec.volumeClaimTemplates[0].metadata.annotations", docs[0])
7 changes: 7 additions & 0 deletions tests/charts/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,3 +529,10 @@ def test_log_groomer_resources(self):
"memory": "2Gi",
},
} == jmespath.search("spec.template.spec.containers[1].resources", docs[0])

def test_persistence_volume_annotations(self):
docs = render_chart(
values={"workers": {"persistence": {"annotations": {"foo": "bar"}}}},
show_only=["templates/workers/worker-deployment.yaml"],
)
assert {"foo": "bar"} == jmespath.search("spec.volumeClaimTemplates[0].metadata.annotations", docs[0])