Skip to content

Commit

Permalink
[helm chart] replace name with fullname helper (#77)
Browse files Browse the repository at this point in the history
* fix: remplace name with fullname helper

* change name with the fullname for chart rbac resources

* remove helper name

---------

Co-authored-by: Jan <[email protected]>
  • Loading branch information
rekcah78 and JTaeuber authored Sep 3, 2024
1 parent 6cd190f commit a6b90cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
16 changes: 7 additions & 9 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "py-kube-downscaler.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
Expand Down Expand Up @@ -34,14 +27,19 @@ Create chart name and version as used by the chart label.
Common labels
*/}}
{{- define "py-kube-downscaler.labels" -}}
application: {{ include "py-kube-downscaler.name" . }}
helm.sh/chart: {{ include "py-kube-downscaler.chart" . }}
{{ include "py-kube-downscaler.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "py-kube-downscaler.selectorLabels" -}}
application: {{ include "py-kube-downscaler.name" . }}
application: {{ include "py-kube-downscaler.fullname" . }}
{{- end }}

{{/*
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Deployment
metadata:
labels:
{{- include "py-kube-downscaler.labels" . | nindent 4 }}
name: {{ include "py-kube-downscaler.name" . }}
name: {{ include "py-kube-downscaler.fullname" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
Expand Down
8 changes: 4 additions & 4 deletions chart/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
{{- end }}

{{- $releaseNamespace := .Release.Namespace }}
{{- $name := include "py-kube-downscaler.name" . }}
{{- $name := include "py-kube-downscaler.fullname" . }}
{{- $serviceAccountName := include "py-kube-downscaler.serviceAccountName" . }}
{{- range $namespace := .Values.constrainedNamespaces }}
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -130,7 +130,7 @@ subjects:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "py-kube-downscaler.name" . }}
name: {{ include "py-kube-downscaler.fullname" . }}
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -281,11 +281,11 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "py-kube-downscaler.name" . }}
name: {{ include "py-kube-downscaler.fullname" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "py-kube-downscaler.name" . }}
name: {{ include "py-kube-downscaler.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "py-kube-downscaler.serviceAccountName" . }}
Expand Down

0 comments on commit a6b90cc

Please sign in to comment.