Repository: fission/fission
Pull request #2710 (2023-01-31 07:41:58)

Allow permission to router for ingress resources in release namespace
## Description
Currently when user create ingress for router then they get an error `cannot create resource "ingresses" in API group "networking.k8s.io" in the namespace "fission` This error occurs because currently router don't have any permissions to create any k8s resources in the release namespace(where fission is installed)
This PR include changes to create necessary permission to allow router to create ingress resource in release namespace.

## Which issue(s) this PR fixes:

Fixes https://github.com/fission/fission/issues/2708

## Testing
<!--- Please describe in detail how you tested your changes. -->

## Checklist:
<!-- Please tick following checkboxes as per your understanding. -->
- [ ] I ran tests as well as code linting locally to verify my changes. 
- [ ] I have done manual verification of my changes, changes working as expected.
- [ ] I have added new tests to cover my changes.
- [ ] My changes follow contributing guidelines of Fission.
- [ ] I have signed all of my commits.



Patch:
diff --git a/charts/fission-all/templates/_helpers.tpl b/charts/fission-all/templates/_helpers.tpl
index b01c6721..cbc63b29 100644
--- a/charts/fission-all/templates/_helpers.tpl
+++ b/charts/fission-all/templates/_helpers.tpl
@@ -55,6 +55,22 @@ This template generates the image name for the deployment depending on the value
 {{- end }}
 {{- end -}}
 
+{{- define "reporterImage" -}}
+{{- if .Values.repository -}}
+  {{- if eq .Values.imageTag "" -}}
+    {{ .Values.repository }}/{{ .Values.postInstallReportImage }}
+  {{- else -}}
+    {{ .Values.repository }}/{{ .Values.postInstallReportImage }}:{{ .Values.imageTag }}
+  {{- end }}
+{{- else -}}
+  {{- if eq .Values.imageTag "" -}}
+    {{ .Values.postInstallReportImage }}
+  {{- else -}}
+    {{ .Values.postInstallReportImage }}:{{ .Values.imageTag }}
+  {{- end }}
+{{- end }}
+{{- end -}}
+
 {{- define "opentelemtry.envs" }}
 - name: OTEL_EXPORTER_OTLP_ENDPOINT
   value: "{{ .Values.openTelemetry.otlpCollectorEndpoint }}"
diff --git a/charts/fission-all/templates/analytics/nonhelm-install-job.yaml b/charts/fission-all/templates/analytics/nonhelm-install-job.yaml
index 90ad2a68..019b3293 100644
--- a/charts/fission-all/templates/analytics/nonhelm-install-job.yaml
+++ b/charts/fission-all/templates/analytics/nonhelm-install-job.yaml
@@ -26,11 +26,7 @@ spec:
       restartPolicy: Never
       containers:
         - name: post-install-job
-        {{- if .Values.imageTag }}
-          image: {{ .Values.postInstallReportImage }}:{{ .Values.imageTag }}
-        {{- else }}
-          image: {{ .Values.postInstallReportImage }}
-        {{- end }}
+          image: {{ include "reporterImage" . | quote }}
           imagePullPolicy: {{ .Values.pullPolicy }}
           command: [ "/reporter" ]
           args: ["event", "-c", "fission-use", "-a", "yaml-post-install", "-l", "{{ .Chart.Name }}-{{ .Chart.Version }}"]
diff --git a/charts/fission-all/templates/analytics/post-install-job.yaml b/charts/fission-all/templates/analytics/post-install-job.yaml
index 6c5b10e2..97dfc3a5 100644
--- a/charts/fission-all/templates/analytics/post-install-job.yaml
+++ b/charts/fission-all/templates/analytics/post-install-job.yaml
@@ -30,11 +30,7 @@ spec:
       restartPolicy: Never
       containers:
         - name: post-install-job
-        {{- if .Values.imageTag }}
-          image: {{ .Values.postInstallReportImage }}:{{ .Values.imageTag }}
-        {{- else }}
-          image: {{ .Values.postInstallReportImage }}
-        {{- end }}
+          image: {{ include "reporterImage" . | quote }}
           imagePullPolicy: {{ .Values.pullPolicy }}
           command: [ "/reporter" ]
           args: ["event", "-c", "fission-use", "-a", "helm-post-install", "-l", "{{ .Chart.Name }}-{{ .Chart.Version }}"]
diff --git a/charts/fission-all/templates/analytics/post-upgrade-job.yaml b/charts/fission-all/templates/analytics/post-upgrade-job.yaml
index 2c827ad4..b90cc1b8 100644
--- a/charts/fission-all/templates/analytics/post-upgrade-job.yaml
+++ b/charts/fission-all/templates/analytics/post-upgrade-job.yaml
@@ -30,11 +30,7 @@ spec:
       restartPolicy: Never
       containers:
         - name: post-upgrade-job
-        {{- if .Values.imageTag }}
-          image: {{ .Values.postInstallReportImage }}:{{ .Values.imageTag }}
-        {{- else }}
-          image: {{ .Values.postInstallReportImage }}
-        {{- end }}
+          image: {{ include "reporterImage" . | quote }}
           imagePullPolicy: {{ .Values.pullPolicy }}
           command: [ "/reporter" ]
           args: ["event", "-c", "fission-use", "-a", "helm-post-upgrade", "-l", "{{ .Chart.Name }}-{{ .Chart.Version }}"]
diff --git a/charts/fission-all/templates/mqt-fission-kafka/deployment.yaml b/charts/fission-all/templates/mqt-fission-kafka/deployment.yaml
index 89ad630a..1ccc2c15 100644
--- a/charts/fission-all/templates/mqt-fission-kafka/deployment.yaml
+++ b/charts/fission-all/templates/mqt-fission-kafka/deployment.yaml
@@ -25,11 +25,7 @@ spec:
     spec:
       containers:
       - name: mqtrigger
-      {{- if eq .Values.imageTag "" }}
-        image: "{{ .Values.image }}"
-      {{- else }}
-        image: "{{ .Values.image }}:{{ .Values.imageTag }}"
-      {{- end }}
+        image: {{ include "fission-bundleImage" . | quote }}
         imagePullPolicy: {{ .Values.pullPolicy }}
         command: ["/fission-bundle"]
         args: ["--mqt", "--routerUrl", "http://router.{{ .Release.Namespace }}"]
diff --git a/charts/fission-all/templates/router/role-kubernetes.yaml b/charts/fission-all/templates/router/role-kubernetes.yaml
index 27a38951..4513def1 100644
--- a/charts/fission-all/templates/router/role-kubernetes.yaml
+++ b/charts/fission-all/templates/router/role-kubernetes.yaml
@@ -1,4 +1,5 @@
 {{- include "kubernetes-role-generator" (merge (dict "namespace" .Values.defaultNamespace "component" "router") .) }}
+{{- include "kubernetes-role-generator" (merge (dict "namespace" .Release.Namespace "component" "router") .) }}
 
 {{- if gt (len .Values.additionalFissionNamespaces) 0 }}
 {{- range $namespace := $.Values.additionalFissionNamespaces }}
diff --git a/charts/fission-all/values.yaml b/charts/fission-all/values.yaml
index b40a5fee..5c99ea0d 100644
--- a/charts/fission-all/values.yaml
+++ b/charts/fission-all/values.yaml
@@ -14,7 +14,7 @@ routerServiceType: LoadBalancer
 ## repository represents base repository for images used in the chart.
 ## Keep it empty for using existing local image
 ##
-repository: index.docker.io
+repository: ghcr.io
 
 ## image represents the base image fission-bundle used by multiple Fission components.
 ## We alter arguments to the image to run a particular component.
diff --git a/skaffold.yaml b/skaffold.yaml
index 9e7e5ca7..7ddbda94 100644
--- a/skaffold.yaml
+++ b/skaffold.yaml
@@ -61,7 +61,7 @@ manifests:
         preUpgradeChecks.imageTag: ""
         priorityClassName: system-cluster-critical
         prometheus.serviceEndpoint: ""
-        repository: index.docker.io
+        repository: ghcr.io
         routerServiceType: LoadBalancer
         runtimePodSpec.enabled: "false"
         serviceMonitor.additionalServiceMonitorLabels.release: prometheus


Test patch:
diff --git a/test/upgrade_test/fission_objects.sh b/test/upgrade_test/fission_objects.sh
index be364300..62e1b244 100644
--- a/test/upgrade_test/fission_objects.sh
+++ b/test/upgrade_test/fission_objects.sh
@@ -5,7 +5,7 @@ ns="fission"
 ROOT=$(pwd)
 PREV_STABLE_VERSION=v1.16.3
 HELM_VARS_PREV_RELEASE="routerServiceType=NodePort,analytics=false"
-HELM_VARS_LATEST_RELEASE="routerServiceType=NodePort,repository=docker.io/library,image=fission-bundle,pullPolicy=IfNotPresent,imageTag=latest,fetcher.image=docker.io/library/fetcher,fetcher.imageTag=latest,postInstallReportImage=reporter,preUpgradeChecks.image=preupgradechecks,preUpgradeChecks.imageTag=latest,analytics=false"
+HELM_VARS_LATEST_RELEASE="routerServiceType=NodePort,repository=ghcr.io,image=fission/fission-bundle,pullPolicy=IfNotPresent,imageTag=latest,fetcher.image=fission/fetcher,fetcher.imageTag=latest,postInstallReportImage=fission/reporter,preUpgradeChecks.image=fission/pre-upgrade-checks,preUpgradeChecks.imageTag=latest,analytics=false"
 
 doit() {
     echo "! $*"