[COMMON] Fix Authorization Policy Template 03/134203/1
authorAndrewLamb <andrew.a.lamb@est.tech>
Tue, 18 Apr 2023 11:13:13 +0000 (12:13 +0100)
committerAndrewLamb <andrew.a.lamb@est.tech>
Tue, 18 Apr 2023 11:20:07 +0000 (12:20 +0100)
Fix for: no matches for kind AuthorizationPolicy, when trying to
install on deployment with no istio.

Issue-ID: OOM-3163
Change-Id: I3e0be55d78e6c88655eeaf267c25b8e6747c5b3c
Signed-off-by: AndrewLamb <andrew.a.lamb@est.tech>
kubernetes/common/common/templates/_serviceMesh.tpl

index fe2424c..3ba945e 100644 (file)
@@ -98,7 +98,7 @@ true
               app.kubernetes.io/name: <app-to-match>    ("app.kubernetes.io/name" corresponds to key defined in "common.labels", which is included in "common.service")
 
     If common.useAuthorizationPolicies returns false:
-      Will create an authorization policy without rules, i.e., an allow-all policy
+      Will not create an authorization policy
 */}}
 {{- define "common.authorizationPolicy" -}}
 {{-   $dot := default . .dot -}}
@@ -106,6 +106,7 @@ true
 {{-   $authorizedPrincipals := default list $dot.Values.serviceMesh.authorizationPolicy.authorizedPrincipals -}}
 {{-   $defaultOperationMethods := list "GET" "POST" "PUT" "PATCH" "DELETE" -}}
 {{-   $relName := include "common.release" . -}}
+{{-   if (include "common.useAuthorizationPolicies" .) }}
 apiVersion: security.istio.io/v1beta1
 kind: AuthorizationPolicy
 metadata:
@@ -117,7 +118,6 @@ spec:
       app.kubernetes.io/name: {{ include "common.servicename" . }}
   action: ALLOW
   rules:
-{{-   if (include "common.useAuthorizationPolicies" .) }}
 {{-     if $authorizedPrincipals }}
 {{-       range $principal := $authorizedPrincipals }}
   - from:
@@ -143,7 +143,5 @@ spec:
 {{-         end }}
 {{-       end }}
 {{-     end }}
-{{-   else }}
-    - {}
 {{-   end }}
 {{- end -}}