Allow empty namespace for fission function and builder (#2621)

Currently, we create Fission resources in the default namespace, function-related resources are created in the fission-function namespace, whereas builder resources are created in the fission-builder namespace. This causes confusion for a lot of users.
In this fix, we allow the user to set the function and builder namespace empty so that function and builder resources are created in the same namespace as the function resource always.

If the user desires older behaviour they can functionNamespace and builderNamespace the same previous before the upgrade.

* use default namespace for fission  function and builder
* support for existing fission namespaces
* Replace builder and function namespace with template
* Fix namespace creation template

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Shubham Bansal
2022-11-16 22:16:05 +05:30
committed by GitHub
parent 70a0afd624
commit 6d117ad43a
31 changed files with 357 additions and 199 deletions
@@ -61,7 +61,7 @@ roleRef:
subjects:
- kind: ServiceAccount
name: fission-fetcher
namespace: {{ .Values.functionNamespace }}
namespace: {{template "fission-function-ns" . }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
@@ -75,5 +75,5 @@ roleRef:
subjects:
- kind: ServiceAccount
name: fission-builder
namespace: {{ .Values.builderNamespace }}
namespace: {{ template "fission-builder-ns" . }}
{{- end -}}
+17 -1
View File
@@ -86,4 +86,20 @@ Define the svc's name
*/}}
{{- define "fission-webhook.svc" -}}
{{- printf "webhook-service" -}}
{{- end -}}
{{- end -}}
{{- define "fission-function-ns" -}}
{{- if .Values.functionNamespace -}}
{{- printf "%s" .Values.functionNamespace -}}
{{- else -}}
{{- printf "%s" .Values.defaultNamespace -}}
{{- end -}}
{{- end -}}
{{- define "fission-builder-ns" -}}
{{- if .Values.builderNamespace -}}
{{- printf "%s" .Values.builderNamespace -}}
{{- else -}}
{{- printf "%s" .Values.builderNamespace -}}
{{- end -}}
{{- end -}}
@@ -27,7 +27,7 @@ spec:
image: {{ include "fission-bundleImage" . | quote }}
imagePullPolicy: {{ .Values.pullPolicy }}
command: ["/fission-bundle"]
args: ["--builderMgr", "--storageSvcUrl", "http://storagesvc.{{ .Release.Namespace }}", "--envbuilder-namespace", "{{ .Values.builderNamespace }}"]
args: ["--builderMgr", "--storageSvcUrl", "http://storagesvc.{{ .Release.Namespace }}"]
env:
- name: FETCHER_IMAGE
{{- if eq .Values.fetcher.imageTag "" }}
@@ -39,6 +39,12 @@ spec:
value: "{{ .Values.pullPolicy }}"
- name: BUILDER_IMAGE_PULL_POLICY
value: "{{ .Values.pullPolicy }}"
- name: FISSION_BUILDER_NAMESPACE
value: "{{ .Values.builderNamespace }}"
- name: FISSION_FUNCTION_NAMESPACE
value: "{{ .Values.functionNamespace }}"
- name: FISSION_DEFAULT_NAMESPACE
value: "{{ .Values.defaultNamespace }}"
- name: ENABLE_ISTIO
value: "{{ .Values.enableIstio }}"
- name: FETCHER_MINCPU
@@ -33,8 +33,12 @@ spec:
command: ["/fission-bundle"]
args: ["--controllerPort", "8888"]
env:
- name: FISSION_DEFAULT_NAMESPACE
value: "{{ .Values.defaultNamespace }}"
- name: FISSION_BUILDER_NAMESPACE
value: "{{ .Values.builderNamespace }}"
- name: FISSION_FUNCTION_NAMESPACE
value: "{{ .Values.functionNamespace }}"
value: "{{ .Values.functionNamespace }}"
- name: DEBUG_ENV
value: {{ .Values.debugEnv | quote }}
- name: PPROF_ENABLED
@@ -27,7 +27,7 @@ spec:
image: {{ include "fission-bundleImage" . | quote }}
imagePullPolicy: {{ .Values.pullPolicy }}
command: ["/fission-bundle"]
args: ["--executorPort", "8888", "--namespace", "{{ .Values.functionNamespace }}"]
args: ["--executorPort", "8888"]
env:
- name: FETCHER_IMAGE
{{- if eq .Values.fetcher.imageTag "" }}
@@ -37,6 +37,12 @@ spec:
{{- end }}
- name: FETCHER_IMAGE_PULL_POLICY
value: "{{ .Values.pullPolicy }}"
- name: FISSION_BUILDER_NAMESPACE
value: "{{ .Values.builderNamespace }}"
- name: FISSION_FUNCTION_NAMESPACE
value: "{{ .Values.functionNamespace }}"
- name: FISSION_DEFAULT_NAMESPACE
value: "{{ .Values.defaultNamespace }}"
- name: RUNTIME_IMAGE_PULL_POLICY
value: "{{ .Values.pullPolicy }}"
- name: ADOPT_EXISTING_RESOURCES
@@ -1,24 +1,29 @@
{{- if .Values.createNamespace }}
{{- if and (ne .Values.functionNamespace "default") (ne .Values.functionNamespace "") }}
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.functionNamespace }}
name: {{ template "fission-function-ns" . }}
labels:
name: fission-function
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
{{- if .Values.enableIstio }}
istio-injection: enabled
{{- end }}
{{- end}}
---
{{- if and (ne .Values.builderNamespace "default") (ne .Values.builderNamespace "") }}
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.builderNamespace }}
name: {{ template "fission-builder-ns" . }}
labels:
name: fission-builder
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
{{- if .Values.enableIstio }}
istio-injection: enabled
{{- end }}
{{- end }}
{{- end }}
@@ -8,7 +8,7 @@ can be used
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: {{ .Values.functionNamespace }}
namespace: {{ template "fission-function-ns" . }}
name: {{ .Release.Name }}-event-fetcher
rules:
- apiGroups:
@@ -9,7 +9,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Release.Name }}-fission-fetcher-pod-reader
namespace: {{ .Values.functionNamespace }}
namespace: {{ template "fission-function-ns" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
@@ -17,7 +17,7 @@ roleRef:
subjects:
- kind: ServiceAccount
name: fission-fetcher
namespace: {{ .Values.functionNamespace }}
namespace: {{ template "fission-function-ns" . }}
{{- if not .Values.singleDefaultNamespace }}
{{- range $namespace := $.Values.additionalFissionNamespaces }}
@@ -2,11 +2,11 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: fission-fetcher
namespace: {{ .Values.functionNamespace }}
namespace: {{ template "fission-function-ns" . }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: fission-builder
namespace: {{ .Values.builderNamespace }}
namespace: {{ template "fission-builder-ns" . }}
@@ -35,7 +35,6 @@ spec:
{{- end }}
imagePullPolicy: {{ .Values.pullPolicy }}
command: [ "/pre-upgrade-checks" ]
args: ["--fn-pod-namespace", "{{ .Values.functionNamespace }}", "--envbuilder-namespace", "{{ .Values.builderNamespace }}"]
env:
{{- include "fission-resource-namespace.envs" . | indent 8 }}
{{- if .Values.terminationMessagePath }}
+12 -10
View File
@@ -61,16 +61,6 @@ controllerPort: 31313
##
routerPort: 31314
## functionNamespace represents the namespace in which Fission Function resources will be created.
## This is different from the release namespace.
##
functionNamespace: fission-function
## builderNamespace represents the namespace in which Fission Builder resources will be created.
## This is different from the release namespace.
##
builderNamespace: fission-builder
## defaultNamespace represents the namespace in which Fission custom resources will be created by the Fission user.
## This is different from the release namespace.
## Please consider setting `singleDefaultNamespace` and `additionalFissionNamespaces` if you want
@@ -79,6 +69,18 @@ builderNamespace: fission-builder
##
defaultNamespace: default
## builderNamespace represents the namespace in which Fission Builder resources will be created.
## if builderNamespace is set to empty then builder resources will be created in the same namespace as the Fission resources.
## This is different from the release namespace.
##
builderNamespace: ""
## functionNamespace represents the namespace in which Fission Function resources will be created.
## if functionNamespace is set to empty then function resources will be created in the same namespace as the Fission resources.
## This is different from the release namespace.
##
functionNamespace: ""
## If true, fission will only watch for fission custom resources created in the `defaultNamespace` above.
##
singleDefaultNamespace: true