From 491749eb5b53ac9e0138c5f3487ec179f5057482 Mon Sep 17 00:00:00 2001 From: firmansyahn <80936459+firmansyahn@users.noreply.github.com> Date: Fri, 9 Aug 2024 14:24:13 +0700 Subject: [PATCH] Add more Istio and Kubernetes Gateway API resources --- charts/common/Chart.yaml | 8 +- charts/common/templates/_istio.tpl | 114 +++++++++++++++++++++++++++++ charts/common/templates/_sigs.tpl | 44 +++++++++++ 3 files changed, 163 insertions(+), 3 deletions(-) diff --git a/charts/common/Chart.yaml b/charts/common/Chart.yaml index fc9c3a5..0c49035 100644 --- a/charts/common/Chart.yaml +++ b/charts/common/Chart.yaml @@ -2,9 +2,11 @@ annotations: category: Infrastructure artifacthub.io/changes: | - kind: changed - description: Add Flux CD + description: Add more granular Istio API resources + - kind: changed + description: Add more granular Kubernetes Gateway API resources apiVersion: v2 -appVersion: 0.1.6 +appVersion: 0.1.7 description: A Library Helm Chart for grouping common logic between Startechnica charts. This chart is not deployable by itself. home: https://github.com/startechnica/apps/tree/main/charts/common @@ -23,4 +25,4 @@ name: st-common sources: - https://startechnica.github.io/apps type: library -version: 0.1.6 \ No newline at end of file +version: 0.1.7 \ No newline at end of file diff --git a/charts/common/templates/_istio.tpl b/charts/common/templates/_istio.tpl index 9943fea..76547de 100644 --- a/charts/common/templates/_istio.tpl +++ b/charts/common/templates/_istio.tpl @@ -56,6 +56,36 @@ SPDX-License-Identifier: APACHE-2.0 {{- end -}} {{- end -}} +{{/* Return the appropriate apiVersion for Istio AuthorizationPolicy. */}} +{{- define "common.capabilities.istioAuthorizationPolicy.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "security.istio.io/v1beta1/AuthorizationPolicy" -}} + {{- print "security.istio.io/v1beta1" -}} +{{- else if .Capabilities.APIVersions.Has "security.istio.io/v1/AuthorizationPolicy" -}} + {{- print "security.istio.io/v1" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Istio DestinationRule. */}} +{{- define "common.capabilities.istioDestinationRule.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "networking.istio.io/v1beta1/DestinationRule" -}} + {{- print "networking.istio.io/v1beta1" -}} +{{- else if .Capabilities.APIVersions.Has "networking.istio.io/v1/DestinationRule" -}} + {{- print "networking.istio.io/v1" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Istio EnvoyFilter. */}} +{{- define "common.capabilities.istioEnvoyFilter.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "networking.istio.io/v1alpha3/EnvoyFilter" -}} + {{- print "networking.istio.io/v1alpha3" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} {{/* Return the appropriate apiVersion for Istio Gateway. */}} {{- define "common.capabilities.istioGateway.apiVersion" -}} @@ -68,6 +98,59 @@ SPDX-License-Identifier: APACHE-2.0 {{- end -}} {{- end -}} +{{/* Return the appropriate apiVersion for Istio PeerAuthentication. */}} +{{- define "common.capabilities.istioPeerAuthentication.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "security.istio.io/v1beta1/PeerAuthentication" -}} + {{- print "security.istio.io/v1beta1" -}} +{{- else if .Capabilities.APIVersions.Has "security.istio.io/v1/PeerAuthentication" -}} + {{- print "security.istio.io/v1" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Istio ProxyConfig. */}} +{{- define "common.capabilities.istioProxyConfig.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "networking.istio.io/v1beta1/ProxyConfig" -}} + {{- print "networking.istio.io/v1beta1" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Istio RequestAuthentication. */}} +{{- define "common.capabilities.istioRequestAuthentication.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "security.istio.io/v1beta1/RequestAuthentication" -}} + {{- print "security.istio.io/v1beta1" -}} +{{- else if .Capabilities.APIVersions.Has "security.istio.io/v1/RequestAuthentication" -}} + {{- print "security.istio.io/v1" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Istio Sidecar. */}} +{{- define "common.capabilities.istioSidecar.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "networking.istio.io/v1beta1/Sidecar" -}} + {{- print "networking.istio.io/v1beta1" -}} +{{- else if .Capabilities.APIVersions.Has "networking.istio.io/v1/Sidecar" -}} + {{- print "networking.istio.io/v1" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Istio ServiceEntry. */}} +{{- define "common.capabilities.istioServiceEntry.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "networking.istio.io/v1beta1/ServiceEntry" -}} + {{- print "networking.istio.io/v1beta1" -}} +{{- else if .Capabilities.APIVersions.Has "networking.istio.io/v1/ServiceEntry" -}} + {{- print "networking.istio.io/v1" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} + {{/* Return the appropriate apiVersion for Istio VirtualService. */}} {{- define "common.capabilities.istioVirtualService.apiVersion" -}} {{- if .Capabilities.APIVersions.Has "networking.istio.io/v1beta1/VirtualService" -}} @@ -77,4 +160,35 @@ SPDX-License-Identifier: APACHE-2.0 {{- else -}} {{- false -}} {{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Istio WasmPlugin. */}} +{{- define "common.capabilities.istioWasmPlugin.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "extensions.istio.io/v1alpha1/WasmPlugin" -}} + {{- print "extensions.istio.io/v1alpha1" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Istio WorkloadEntry. */}} +{{- define "common.capabilities.istioWorkloadEntry.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "networking.istio.io/v1beta1/WorkloadEntry" -}} + {{- print "networking.istio.io/v1beta1" -}} +{{- else if .Capabilities.APIVersions.Has "networking.istio.io/v1/WorkloadEntry" -}} + {{- print "networking.istio.io/v1" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Istio WorkloadGroup. */}} +{{- define "common.capabilities.istioWorkloadGroup.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "networking.istio.io/v1beta1/WorkloadGroup" -}} + {{- print "networking.istio.io/v1beta1" -}} +{{- else if .Capabilities.APIVersions.Has "networking.istio.io/v1/WorkloadGroup" -}} + {{- print "networking.istio.io/v1" -}} +{{- else -}} + {{- false -}} +{{- end -}} {{- end -}} \ No newline at end of file diff --git a/charts/common/templates/_sigs.tpl b/charts/common/templates/_sigs.tpl index 08699d6..9f21227 100644 --- a/charts/common/templates/_sigs.tpl +++ b/charts/common/templates/_sigs.tpl @@ -14,4 +14,48 @@ SPDX-License-Identifier: APACHE-2.0 {{- else -}} {{- false -}} {{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Kubernetes Gateway API Gateway */}} +{{- define "common.capabilities.networkingGatewayGateway.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1/Gateway" -}} + {{- print "gateway.networking.k8s.io/v1" -}} +{{- else if .Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1beta1/Gateway" -}} + {{- print "gateway.networking.k8s.io/v1beta1" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Kubernetes Gateway API GRPCRoute */}} +{{- define "common.capabilities.networkingGatewayGRPCRoute.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1/GRPCRoute" -}} + {{- print "gateway.networking.k8s.io/v1" -}} +{{- else if .Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1beta1/GRPCRoute" -}} + {{- print "gateway.networking.k8s.io/v1beta1" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Kubernetes Gateway API HTTPRoute */}} +{{- define "common.capabilities.networkingGatewayHTTPRoute.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1/HTTPRoute" -}} + {{- print "gateway.networking.k8s.io/v1" -}} +{{- else if .Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1beta1/HTTPRoute" -}} + {{- print "gateway.networking.k8s.io/v1beta1" -}} +{{- else -}} + {{- false -}} +{{- end -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Kubernetes Gateway API ReferenceGrant */}} +{{- define "common.capabilities.networkingGatewayReferenceGrant.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1/ReferenceGrant" -}} + {{- print "gateway.networking.k8s.io/v1" -}} +{{- else if .Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1beta1/ReferenceGrant" -}} + {{- print "gateway.networking.k8s.io/v1beta1" -}} +{{- else -}} + {{- false -}} +{{- end -}} {{- end -}} \ No newline at end of file