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

Annotations and Labels #4

Merged
merged 4 commits into from
Dec 14, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/workload/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Create chart name and version as used by the chart label.
{{/*
Common labels
*/}}
{{- define "workload.labels" -}}
{{- define "workload.commonLabels" -}}
helm.sh/chart: {{ include "workload.chart" . }}
{{ include "workload.selectorLabels" . }}
{{- if .Chart.AppVersion }}
Expand Down
8 changes: 7 additions & 1 deletion charts/workload/templates/deployment.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide more context on this change? Why is it needed? what does it benefit?

Are you going to add to the conversion function in https://github.com/score-spec/score-helm/blob/main/internal/helm/convert.go#L42C8-L42C8 to enable this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide more context on this change? Why is it needed? what does it benefit?

I just updated the main description of this PR for the use cases. Let me know if you need more information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you going to add to the conversion function in https://github.com/score-spec/score-helm/blob/main/internal/helm/convert.go#L42C8-L42C8 to enable this?

Nop, it's not related to that. These labels and annotations are not part of the Score spec anyway.

This PR is about this workflow:

score-helm run \
	-f score.yaml \
	-o score-helm-values.yaml

helm install \
	test \
	--repo https://score-spec.github.io/score-helm-charts \
	workload \
	--values score-helm-values.yaml \
        --set "workload.containers.annotations.dapr\.io/enabled=true"

So just about the second command (helm install), not the first one (score-helm run).

Let me know if you need more information around this.

Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "workload.name" . }}
annotations:
{{- toYaml .Values.workload.annotations | nindent 4 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really should add these to the values.yaml file as sample defaults.

workload:
  annotations: {}
  labels: {}
  containers:
    annotations: {}
    labels: {}
service:
  labels: {}

Why no annotations on the service?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RE: values.yaml file as sample defaults - love the idea, but it's not the case today: https://github.com/score-spec/score-helm-charts/blob/main/charts/workload/values.yaml - useless for now, but let's add in another/dedicated PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no annotations on the service?

No reasons, I missed it, just added, thanks for catching this.

labels:
{{- include "workload.labels" . | nindent 4 }}
{{- include "workload.commonLabels" . | nindent 4 }}
{{- toYaml .Values.workload.labels | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "workload.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- toYaml .Values.workload.containers.annotations | nindent 8 }}
labels:
{{- include "workload.selectorLabels" . | nindent 8 }}
{{- toYaml .Values.workload.containers.labels | nindent 8 }}
spec:
containers:
{{- range $name, $container := .Values.containers }}
Expand Down
7 changes: 5 additions & 2 deletions charts/workload/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ apiVersion: v1
kind: Service
metadata:
name: {{ include "workload.name" . }}
annotations:
{{- toYaml .Values.service.annotations | nindent 4 }}
labels:
{{- include "workload.labels" . | nindent 4 }}
{{- include "workload.commonLabels" . | nindent 4 }}
{{- toYaml .Values.service.labels | nindent 4 }}
spec:
type: {{ .Values.service.type }}
selector:
Expand All @@ -13,4 +16,4 @@ spec:
ports:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}