Skip to content

Commit

Permalink
fix labels (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
matas-cast authored Apr 4, 2024
1 parent 64e04cd commit fe3f783
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
27 changes: 12 additions & 15 deletions charts/kvisor/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ Create chart name and version as used by the chart label.
Common labels
*/}}

{{- define "kvisor.topLevelLabels" -}}
{{- define "kvisor.commonLabels" -}}
{{- range $key, $value := .Values.commonLabels }}
{{$key}}: {{$value}}
{{- end }}
{{- end }}

{{- define "kvisor.labels" -}}
helm.sh/chart: {{ include "kvisor.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}


{{- define "kvisor.commonLabels" -}}
{{- range $key, $value := .Values.commonLabels }}
{{$key}}: {{$value}}
{{- end }}
{{ include "kvisor.commonLabels" . }}
{{- end }}

{{/*
Expand All @@ -74,15 +74,14 @@ Common helpers for runtime agent.
{{- end }}

{{- define "kvisor.agent.labels" -}}
{{ include "kvisor.topLevelLabels" . }}
{{ include "kvisor.labels" . }}
{{ include "kvisor.agent.selectorLabels" . }}
{{- end }}

{{- define "kvisor.agent.selectorLabels" -}}
app.kubernetes.io/name: {{ include "kvisor.agent.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: agent
{{ include "kvisor.commonLabels" . }}
{{- end }}

{{/*
Expand All @@ -101,15 +100,14 @@ Common helpers for controller.
{{- end }}

{{- define "kvisor.controller.labels" -}}
{{ include "kvisor.topLevelLabels" . }}
{{ include "kvisor.labels" . }}
{{ include "kvisor.controller.selectorLabels" . }}
{{- end }}

{{- define "kvisor.controller.selectorLabels" -}}
app.kubernetes.io/name: {{ include "kvisor.controller.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: controller
{{ include "kvisor.commonLabels" . }}
{{- end }}


Expand All @@ -123,11 +121,10 @@ Common helpers for event generator.
{{- define "kvisor.eventGenerator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "kvisor.name" . }}-event-generator
app.kubernetes.io/instance: {{ .Release.Name }}
{{ include "kvisor.commonLabels" . }}
{{- end }}

{{- define "kvisor.eventGenerator.labels" -}}
{{ include "kvisor.topLevelLabels" . }}
{{ include "kvisor.labels" . }}
{{ include "kvisor.eventGenerator.selectorLabels" . }}
{{- end }}

Expand All @@ -153,5 +150,5 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "kvisor.castaiMockServer.labels" -}}
{{ include "kvisor.topLevelLabels" . }}
{{ include "kvisor.labels" . }}
{{- end }}
10 changes: 4 additions & 6 deletions charts/kvisor/templates/agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ spec:
labels:
app.kubernetes.io/component: agent
{{- include "kvisor.agent.selectorLabels" . | nindent 8 }}
{{- include "kvisor.commonLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down Expand Up @@ -163,8 +164,7 @@ metadata:
name: {{ include "kvisor.agent.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "kvisor.topLevelLabels" . | nindent 4}}
{{- include "kvisor.commonLabels" . | nindent 4 }}
{{- include "kvisor.labels" . | nindent 4}}
{{- with .Values.agent.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand All @@ -175,8 +175,7 @@ kind: ClusterRole
metadata:
name: {{ include "kvisor.fullname" . }}
labels:
{{- include "kvisor.topLevelLabels" . | nindent 4}}
{{- include "kvisor.commonLabels" . | nindent 4 }}
{{- include "kvisor.labels" . | nindent 4}}
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -212,8 +211,7 @@ kind: ClusterRoleBinding
metadata:
name: {{ include "kvisor.fullname" . }}
labels:
{{- include "kvisor.topLevelLabels" . | nindent 4}}
{{- include "kvisor.commonLabels" . | nindent 4 }}
{{- include "kvisor.labels" . | nindent 4}}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
1 change: 1 addition & 0 deletions charts/kvisor/templates/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ spec:
{{- end }}
labels:
{{- include "kvisor.controller.selectorLabels" . | nindent 8 }}
{{- include "kvisor.commonLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "kvisor.controller.serviceAccountName" . }}
dnsPolicy: {{.Values.controller.dnsPolicy}}
Expand Down
1 change: 1 addition & 0 deletions charts/kvisor/templates/event-generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ spec:
labels:
app.kubernetes.io/component: event-generator
{{- include "kvisor.eventGenerator.selectorLabels" . | nindent 8 }}
{{- include "kvisor.commonLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down
3 changes: 1 addition & 2 deletions charts/kvisor/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ metadata:
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "kvisor.topLevelLabels" . | nindent 4}}
{{- include "kvisor.commonLabels" . | nindent 4 }}
{{- include "kvisor.labels" . | nindent 4}}
data:
{{- if .Values.castai.apiKey }}
CASTAI_API_KEY: {{ required "castai.apiKey must be provided" .Values.castai.apiKey | b64enc | quote }}
Expand Down

0 comments on commit fe3f783

Please sign in to comment.