Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
fix: use release name for resources name
Browse files Browse the repository at this point in the history
  • Loading branch information
mloiseleur authored Jan 10, 2024
1 parent f3477e1 commit 2bad46f
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 18 deletions.
10 changes: 8 additions & 2 deletions traefik-hub/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Expand the name of the chart.
*/}}
{{- define "traefik-hub.name" -}}
{{- .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Expand All @@ -26,11 +26,17 @@ Create chart name and version as used by the chart label.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Expand the serviceAccountName to use for RBAC and the deployment.
*/}}
{{- define "traefik-hub.serviceaccount-name" -}}
{{- .Values.serviceAccountName | default (include "traefik-hub.name" .) -}}
{{- end -}}

{{/* Shared labels used for selector */}}
{{/* This is an immutable field: this should not change between upgrade */}}
{{- define "traefik-hub.labelselector" -}}
app.kubernetes.io/name: {{ template "traefik-hub.name" . }}
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/instance: {{ template "traefik-hub.instance-name" . }}
{{- end }}

Expand Down
6 changes: 3 additions & 3 deletions traefik-hub/templates/cluster-role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: traefik-hub-controller
name: {{ include "traefik-hub.instance-name" . }}
labels:
{{- include "traefik-hub.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: traefik-hub-controller
name: {{ include "traefik-hub.instance-name" . }}
subjects:
- kind: ServiceAccount
name: {{ .Values.serviceAccountName }}
name: {{ include "traefik-hub.serviceaccount-name" . }}
namespace: {{ .Release.Namespace }}
4 changes: 2 additions & 2 deletions traefik-hub/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: traefik
name: {{ include "traefik-hub.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "traefik-hub.labels" . | nindent 4 }}
Expand Down Expand Up @@ -38,7 +38,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ .Values.serviceAccountName }}
serviceAccountName: {{ include "traefik-hub.serviceaccount-name" . }}
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
Expand Down
2 changes: 1 addition & 1 deletion traefik-hub/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: traefik-hub-controller
name: {{ include "traefik-hub.instance-name" . }}
rules:
- apiGroups:
- networking.k8s.io
Expand Down
5 changes: 2 additions & 3 deletions traefik-hub/templates/service-account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
kind: ServiceAccount
apiVersion: v1
metadata:
name: {{ .Values.serviceAccountName }}
name: {{ include "traefik-hub.serviceaccount-name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "traefik-hub.labels" . | nindent 4 }}
labels: {{- include "traefik-hub.labels" . | nindent 4 }}
automountServiceAccountToken: false
2 changes: 1 addition & 1 deletion traefik-hub/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: Service
metadata:
name: traefik
name: {{ include "traefik-hub.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "traefik-hub.labels" . | nindent 4 }}
Expand Down
4 changes: 2 additions & 2 deletions traefik-hub/tests/cluster-role-binding_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ tests:
of: ClusterRoleBinding
- equal:
path: metadata.name
value: traefik-hub-controller
value: traefik-hub-traefik
- equal:
path: subjects[0]
value:
kind: ServiceAccount
name: traefik-hub-controller
name: traefik-hub
namespace: traefik
- it: should namespace and serviceAccountName
set:
Expand Down
3 changes: 3 additions & 0 deletions traefik-hub/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ tests:
asserts:
- isKind:
of: Deployment
- equal:
path: metadata.name
value: traefik-hub
- it: should set the image
set:
image: test
Expand Down
3 changes: 3 additions & 0 deletions traefik-hub/tests/service_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ tests:
- equal:
path: spec.type
value: ClusterIP
- equal:
path: metadata.name
value: "traefik-hub"
- equal:
path: metadata.annotations
value: null
Expand Down
5 changes: 1 addition & 4 deletions traefik-hub/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ maxSurge: 1
priorityClassName: ""

imagePullSecrets: []
# - name: regcred

image: ghcr.io/traefik/traefik-hub:{{ .Chart.AppVersion }}
serviceAccountName: traefik-hub-controller

serviceAccountName:

resources: {}
# requests:
Expand Down

0 comments on commit 2bad46f

Please sign in to comment.