Skip to content

Commit

Permalink
fix(helm): chart should respect -n <namespace> flag (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
zbindenren authored Oct 25, 2022
1 parent 4d4dc39 commit a5a3a79
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions helm/kubenurse/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | quote }}
{{ define "image" -}}
{{ printf "%s:%s" .Values.daemonset.image.repository .Values.daemonset.image.tag }}
{{- end }}

{{- define "namespace" -}}
{{- default .Release.Namespace .Values.namespace | quote -}}
{{- end -}}
2 changes: 1 addition & 1 deletion helm/kubenurse/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app: {{ include "name" . | quote }}
{{ include "helm-labels" . | indent 4 }}
name: {{ include "name" . | quote }}
namespace: {{ .Values.namespace }}
namespace: {{ include "namespace" . }}
spec:
selector:
matchLabels:
Expand Down
2 changes: 1 addition & 1 deletion helm/kubenurse/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
labels:
{{ include "common-labels" . | indent 4 }}
name: {{ include "name" . | quote }}
namespace: {{ .Values.namespace }}
namespace: {{ include "namespace" . }}
spec:
ingressClassName: {{ .Values.ingress.className }}
rules:
Expand Down
8 changes: 4 additions & 4 deletions helm/kubenurse/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "name" . | quote }}
namespace: {{ .Values.namespace }}
namespace: {{ include "namespace" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "name" . | quote }}
subjects:
- kind: ServiceAccount
name: {{ include "name" . | quote }}
namespace: {{ .Values.namespace }}
namespace: {{ include "namespace" . }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "name" . | quote }}
namespace: {{ .Values.namespace }}
namespace: {{ include "namespace" . }}
rules:
- apiGroups:
- ""
Expand All @@ -40,7 +40,7 @@ roleRef:
subjects:
- kind: ServiceAccount
name: {{ include "name" . | quote }}
namespace: {{ .Values.namespace }}
namespace: {{ include "namespace" . }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
2 changes: 1 addition & 1 deletion helm/kubenurse/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
app: {{ include "name" . | quote }}
{{ include "common-labels" . | indent 4 }}
name: {{ include "name" . | quote }}
namespace: {{ .Values.namespace }}
namespace: {{ include "namespace" . }}
spec:
ports:
- name: {{ .Values.service.name }}
Expand Down
2 changes: 1 addition & 1 deletion helm/kubenurse/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ metadata:
name: {{ .Values.serviceAccount.name }}
labels:
{{ include "common-labels" . | indent 6 }}
namespace: {{ .Values.namespace }}
namespace: {{ include "namespace" . }}
4 changes: 2 additions & 2 deletions helm/kubenurse/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "name" . | quote }}
namespace: {{ .Values.namespace }}
namespace: {{ include "namespace" . }}
labels:
{{- toYaml .Values.serviceMonitor.labels | nindent 4}}
spec:
Expand All @@ -16,4 +16,4 @@ spec:
selector:
matchLabels:
{{ include "common-labels" . | indent 6 }}
{{- end -}}
{{- end -}}

0 comments on commit a5a3a79

Please sign in to comment.