Add namespace override

Signed-off-by: Guangbo Chen <steven.guangbo.chen@gmail.com>
This commit is contained in:
Guangbo Chen 2020-12-03 23:02:28 +08:00 committed by Sheng Yang
parent d77dc2c35e
commit 791d63c5e3
15 changed files with 34 additions and 16 deletions

View File

@ -53,3 +53,14 @@ app.kubernetes.io/version: {{ .Chart.AppVersion }}
{{ include "system_default_registry" . }} {{ include "system_default_registry" . }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- /*
define the longhorn release namespace
*/ -}}
{{- define "release_namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}

View File

@ -10,4 +10,4 @@ roleRef:
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: longhorn-service-account name: longhorn-service-account
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}

View File

@ -4,7 +4,7 @@ metadata:
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
app: longhorn-manager app: longhorn-manager
name: longhorn-manager name: longhorn-manager
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
spec: spec:
selector: selector:
matchLabels: matchLabels:
@ -97,7 +97,7 @@ metadata:
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
app: longhorn-manager app: longhorn-manager
name: longhorn-backend name: longhorn-backend
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
spec: spec:
type: {{ .Values.service.manager.type }} type: {{ .Values.service.manager.type }}
sessionAffinity: ClientIP sessionAffinity: ClientIP

View File

@ -2,7 +2,7 @@ apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
name: longhorn-default-setting name: longhorn-default-setting
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
data: data:
default-setting.yaml: |- default-setting.yaml: |-

View File

@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: longhorn-driver-deployer name: longhorn-driver-deployer
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
spec: spec:
replicas: 1 replicas: 1

View File

@ -4,7 +4,7 @@ metadata:
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
app: longhorn-ui app: longhorn-ui
name: longhorn-ui name: longhorn-ui
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
spec: spec:
replicas: 1 replicas: 1
selector: selector:
@ -41,7 +41,7 @@ metadata:
kubernetes.io/cluster-service: "true" kubernetes.io/cluster-service: "true"
{{- end }} {{- end }}
name: longhorn-frontend name: longhorn-frontend
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
spec: spec:
{{- if eq .Values.service.ui.type "Rancher-Proxy" }} {{- if eq .Values.service.ui.type "Rancher-Proxy" }}
type: ClusterIP type: ClusterIP

View File

@ -3,6 +3,7 @@ apiVersion: extensions/v1beta1
kind: Ingress kind: Ingress
metadata: metadata:
name: longhorn-ingress name: longhorn-ingress
namespace: {{ include "release_namespace" . }}
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
app: longhorn-ingress app: longhorn-ingress
annotations: annotations:

View File

@ -5,7 +5,7 @@ metadata:
"helm.sh/hook": post-upgrade "helm.sh/hook": post-upgrade
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation "helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
name: longhorn-post-upgrade name: longhorn-post-upgrade
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
spec: spec:
activeDeadlineSeconds: 900 activeDeadlineSeconds: 900

View File

@ -35,7 +35,7 @@ kind: Role
metadata: metadata:
name: longhorn-psp-role name: longhorn-psp-role
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
rules: rules:
- apiGroups: - apiGroups:
- policy - policy
@ -51,7 +51,7 @@ kind: RoleBinding
metadata: metadata:
name: longhorn-psp-binding name: longhorn-psp-binding
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: Role kind: Role
@ -59,8 +59,8 @@ roleRef:
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: longhorn-service-account name: longhorn-service-account
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
- kind: ServiceAccount - kind: ServiceAccount
name: default name: default
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
{{- end }} {{- end }}

View File

@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
name: {{ .Values.privateRegistry.registrySecret }} name: {{ .Values.privateRegistry.registrySecret }}
namespace: {{ include "release_namespace" . }}
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
type: kubernetes.io/dockerconfigjson type: kubernetes.io/dockerconfigjson
data: data:

View File

@ -2,5 +2,5 @@ apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: longhorn-service-account name: longhorn-service-account
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}

View File

@ -2,7 +2,7 @@ apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
name: longhorn-storageclass name: longhorn-storageclass
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
data: data:
storageclass.yaml: | storageclass.yaml: |

View File

@ -4,6 +4,7 @@ apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
name: longhorn name: longhorn
namespace: {{ include "release_namespace" . }}
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
app: longhorn app: longhorn
type: kubernetes.io/tls type: kubernetes.io/tls

View File

@ -5,7 +5,7 @@ metadata:
"helm.sh/hook": pre-delete "helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": hook-succeeded "helm.sh/hook-delete-policy": hook-succeeded
name: longhorn-uninstall name: longhorn-uninstall
namespace: {{ .Release.Namespace }} namespace: {{ include "release_namespace" . }}
labels: {{- include "longhorn.labels" . | nindent 4 }} labels: {{- include "longhorn.labels" . | nindent 4 }}
spec: spec:
activeDeadlineSeconds: 900 activeDeadlineSeconds: 900

View File

@ -153,3 +153,7 @@ ingress:
# Configure a pod security policy in the Longhorn namespace to allow privileged pods # Configure a pod security policy in the Longhorn namespace to allow privileged pods
enablePSP: true enablePSP: true
## Specify override namespace, specifically this is useful for using longhorn as sub-chart
## and its release namespace is not the `longhorn-system`
namespaceOverride: ""