Skip to content

Commit

Permalink
Merge pull request #57 from fgeck/namespaceOverride
Browse files Browse the repository at this point in the history
Add namespaceOverride template variable
  • Loading branch information
thebsdbox authored Jan 15, 2025
2 parents a5a6938 + 9bf1ad5 commit dba1ee2
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 7 deletions.
11 changes: 11 additions & 0 deletions charts/kube-vip-cloud-provider/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ Expand the name of the chart.
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Determine the namespace to use, allowing for a namespace override.
*/}}
{{- define "kube-vip-cloudprovider.namespace" -}}
{{- if .Values.namespaceOverride }}
{{- .Values.namespaceOverride }}
{{- else }}
{{- .Release.Namespace }}
{{- end }}
{{- 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
2 changes: 1 addition & 1 deletion charts/kube-vip-cloud-provider/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "kube-vip-cloud-provider.name" . }}
namespace: {{ .Release.Namespace }}
namespace: {{ include "kube-vip-cloudprovider.namespace" . }}
data:
{{- range $key, $value := .Values.cm.data }}
{{ $key }}: {{ $value | quote }}
Expand Down
2 changes: 1 addition & 1 deletion charts/kube-vip-cloud-provider/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "kube-vip-cloud-provider.name" . }}
namespace: {{ .Release.Namespace | default "kube-system" }}
namespace: {{ include "kube-vip-cloudprovider.namespace" . | default "kube-system" }}
spec:
replicas: {{ .Values.replicasCount }}
selector:
Expand Down
4 changes: 2 additions & 2 deletions charts/kube-vip-cloud-provider/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "kube-vip-cloud-provider.name" . }}
namespace: {{ .Release.Namespace | default "kube-system" }}
namespace: {{ include "kube-vip-cloudprovider.namespace" . | default "kube-system" }}
labels:
{{- include "kube-vip-cloud-provider.labels" . | nindent 4 }}
---
Expand Down Expand Up @@ -34,4 +34,4 @@ roleRef:
subjects:
- kind: ServiceAccount
name: {{ include "kube-vip-cloud-provider.name" . }}
namespace: {{ .Release.Namespace }}
namespace: {{ include "kube-vip-cloudprovider.namespace" . }}
3 changes: 3 additions & 0 deletions charts/kube-vip-cloud-provider/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ image:
# Overrides the image tag whose default is the chart appVersion.
# tag: "v0.0.4"

# Custom namespace to override the namespace for the deployed resources.
namespaceOverride: ""

## Cloud Provider ConfigMap
## CIDR blocks , IP ranges [start address - end address]
## Multiple pools by CIDR per Namespace, Multiple IP ranges per Namespace (handles overlapping ranges)
Expand Down
11 changes: 11 additions & 0 deletions charts/kube-vip/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}

{{/*
Determine the namespace to use, allowing for a namespace override.
*/}}
{{- define "kube-vip.namespace" -}}
{{- if .Values.namespaceOverride }}
{{- .Values.namespaceOverride }}
{{- else }}
{{- .Release.Namespace }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
Expand Down
2 changes: 1 addition & 1 deletion charts/kube-vip/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "kube-vip.name" . }}
namespace: {{ .Release.Namespace | default "kube-system" }}
namespace: {{ include "kube-vip.namespace" . | default "kube-system" }}
spec:
selector:
matchLabels:
Expand Down
4 changes: 2 additions & 2 deletions charts/kube-vip/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "kube-vip.name" . }}
namespace: {{ .Release.Namespace }}
namespace: {{ include "kube-vip.namespace" . }}
labels:
{{- include "kube-vip.labels" . | nindent 4 }}
---
Expand Down Expand Up @@ -33,4 +33,4 @@ roleRef:
subjects:
- kind: ServiceAccount
name: {{ include "kube-vip.name" . }}
namespace: {{ .Release.Namespace }}
namespace: {{ include "kube-vip.namespace" . }}
2 changes: 2 additions & 0 deletions charts/kube-vip/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ extraLabels: {}
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
# Custom namespace to override the namespace for the deployed resources.
namespaceOverride: ""

serviceAccount:
# Specifies whether a service account should be created
Expand Down

0 comments on commit dba1ee2

Please sign in to comment.