-
Notifications
You must be signed in to change notification settings - Fork 0
feat: inf-3308 adapt charts to support Envoy Gateway #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
08e8c93
feat: inf-3308 adapt charts to support Envoy Gateway
jmpalomares 96d39eb
feat: inf-3308 adapt charts to support Envoy Gateway
jmpalomares 9f2f436
feat: inf-3308 adapt charts to support Envoy Gateway
jmpalomares 5d22b91
Merge branch 'main' into feat/inf-3308-adapt-charts-envoy-gateway
jmpalomares 6921420
feat: inf-3308 adapt charts to support Envoy Gateway
jmpalomares 3a40b7c
chore: updates based on tests with FBA
32a6f3a
chore: updatae monolith
7d96149
chore: linted and added sample values to microservice for gateway
849373b
chore: added value samples to monolith
f74644d
chore: rename file
dd3fbcc
chore: rename file
ede88ba
Merge branch 'main' into feat/inf-3308-adapt-charts-envoy-gateway
andibeuge 4fc9a11
chore: delete unused tempalte
b8c6478
fix: add validation to prevent invalid ReferenceGrant resources (#418)
Copilot ecea7dd
fix: enhance charts to support Envoy Gateway based on feedback (#417)
Copilot d6edbbc
chore: remove invalid block
c9562ca
Update parcellab/monolith/README.md
andibeuge a6fd86f
Update parcellab/common/templates/_referencegrant.tpl
andibeuge 66a3d81
fix: correct policy namespace
90acd65
Apply suggestion from @Copilot
andibeuge 29521de
Apply suggestion from @Copilot
andibeuge f82ace1
Apply suggestion from @Copilot
andibeuge ba4705f
Apply suggestion from @Copilot
andibeuge adc8724
Merge branch 'main' into feat/inf-3308-adapt-charts-envoy-gateway
andibeuge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| {{/* vim: set filetype=mustache: */}} | ||
| {{/* | ||
| Common HTTPRoute definition with deterministic names and labels: | ||
| {{ include "common.httproutes" . }} | ||
| */}} | ||
|
|
||
| {{- define "common.httproutes" -}} | ||
| {{- $envoy := .Values.envoy | default dict -}} | ||
| {{- if $envoy.enabled -}} | ||
| {{- $gateway := default (dict "name" "gateway-api" "namespace" "envoy-gateway") $envoy.gateway -}} | ||
| {{- $httproutes := default (list) $envoy.httpRoutes -}} | ||
| {{- $baseName := include "common.fullname" . -}} | ||
| {{- $globalLabels := include "common.labels" . -}} | ||
| {{- $serviceNamespace := .Release.Namespace -}} | ||
| {{- $security := default dict $envoy.security -}} | ||
| {{- $securityEnabled := default false $security.enabled -}} | ||
| {{- $securityLabelKey := printf "%s/security-required" (include "common.parcellabtagsdomain" .) -}} | ||
|
|
||
| {{- range $index, $route := $httproutes }} | ||
| {{- $hosts := required (printf "envoy.httpRoutes[%d].hosts is required" $index) $route.hosts -}} | ||
| {{- if eq (len $hosts) 0 -}} | ||
| {{- fail (printf "envoy.httpRoutes[%d].hosts cannot be empty" $index) -}} | ||
| {{- end -}} | ||
| {{- $rawRouteName := default (printf "%s-%d" $baseName $index) $route.name -}} | ||
| {{- $sanitizedRouteName := trunc 63 (trimSuffix "-" (regexReplaceAll "[^a-z0-9-]" (lower $rawRouteName) "-")) -}} | ||
| {{- $routeName := default (printf "%s-%d" $baseName $index) $sanitizedRouteName }} | ||
| --- | ||
| apiVersion: gateway.networking.k8s.io/v1 | ||
| kind: HTTPRoute | ||
| metadata: | ||
| name: {{ $routeName }} | ||
| namespace: {{ $serviceNamespace }} | ||
| labels: | ||
| {{- $globalLabels | nindent 4 }} | ||
| {{ $securityLabelKey }}: {{ (ternary "true" "false" $securityEnabled) | quote }} | ||
| {{- with $route.labels }} | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| annotations: | ||
| external-dns.alpha.kubernetes.io/hostname: "{{ join "," $route.hosts }}" | ||
| spec: | ||
| parentRefs: | ||
| - name: {{ $gateway.name }} | ||
| namespace: {{ $gateway.namespace }} | ||
| group: gateway.networking.k8s.io | ||
| kind: Gateway | ||
| hostnames: | ||
| {{- range $hosts }} | ||
| - {{ . | quote }} | ||
| {{- end }} | ||
| {{- with $route.rules }} | ||
| rules: | ||
| {{ toYaml . | nindent 4 }} | ||
| {{ end }} | ||
| {{ end }} | ||
| {{- end }} | ||
| {{- end }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| {{/* vim: set filetype=mustache: */}} | ||
| {{/* | ||
| Common ReferenceGrant definition: | ||
| {{ include "common.referencegrant" ( | ||
| dict | ||
| "Values" "the values scope" | ||
| "Release" .Release | ||
| ) }} | ||
| */}} | ||
|
|
||
| {{- define "common.referencegrant" -}} | ||
| {{- $envoy := .Values.envoy | default dict -}} | ||
| {{- $referenceGrant := .Values.envoy.referenceGrant | default dict -}} | ||
| {{- $gateway := $envoy.gateway | default dict -}} | ||
| {{- $name := include "common.fullname" . }} | ||
| {{- $serviceNamespace := .Release.Namespace }} | ||
| {{- $from := $referenceGrant.from | default list -}} | ||
| {{- $to := $referenceGrant.to | default list -}} | ||
| {{- if and $envoy.enabled (gt (len $from) 0) (gt (len $to) 0) -}} | ||
| --- | ||
| apiVersion: gateway.networking.k8s.io/v1beta1 | ||
| kind: ReferenceGrant | ||
| metadata: | ||
| name: {{ (printf "%s-reference-grant" $name) }} | ||
| namespace: {{ $gateway.namespace | quote }} | ||
| labels: | ||
| {{- include "common.labels" . | nindent 4 }} | ||
| {{- with $referenceGrant.annotations }} | ||
| annotations: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| spec: | ||
| from: | ||
| {{- range $from }} | ||
| - group: {{ .group | default "gateway.networking.k8s.io" | quote }} | ||
| kind: {{ required "referenceGrant.from.kind is required" .kind | quote }} | ||
| namespace: {{ $serviceNamespace | quote }} | ||
| {{- with .name }} | ||
| name: {{ . | quote }} | ||
| {{- end }} | ||
| {{- end }} | ||
| to: | ||
| {{- range $to }} | ||
| - group: {{ .group | default "" | quote }} | ||
| kind: {{ required "referenceGrant.to.kind is required" .kind | quote }} | ||
| {{- with .name }} | ||
| name: {{ . | quote }} | ||
| {{- end }} | ||
| {{- end }} | ||
andibeuge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {{- end -}} | ||
| {{- end -}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| {{/* vim: set filetype=mustache: */}} | ||
| {{/* | ||
| Render Envoy Gateway SecurityPolicy resources defined under | ||
| .Values.envoy.security.policies. Each policy renders as a complete resource | ||
| (OIDC, JWT, authorization) while inheriting defaults from envoy.security.*. | ||
| */}} | ||
| {{- define "common.securitypolicies" -}} | ||
| {{- $values := .Values -}} | ||
| {{- $envoy := default (dict "enabled" false) $values.envoy -}} | ||
| {{- if $envoy.enabled }} | ||
| {{- $security := default dict $envoy.security -}} | ||
| {{- $policies := default (list) $security.policies -}} | ||
| {{- if $policies }} | ||
| {{- $scope := dict "Values" $values "Release" .Release -}} | ||
| {{- $serviceName := default (include "common.fullname" $scope) $values.name -}} | ||
| {{- $policyNamespace := .Release.Namespace -}} | ||
| {{- $securityLabelKey := printf "%s/security-required" (include "common.parcellabtagsdomain" .) -}} | ||
| {{- $globalIssuer := $security.issuer -}} | ||
| {{- $globalRedirectURL := $security.redirectURL -}} | ||
| {{- $globalCookieDomain := $security.cookieDomain -}} | ||
| {{- $globalLogoutPath := $security.logoutPath -}} | ||
| {{- $globalClientID := $security.clientID -}} | ||
| {{- $globalClientSecretName := $security.clientSecretName -}} | ||
| {{- $globalScopes := $security.scopes -}} | ||
| {{- $globalClaimHeaders := $security.claimToHeaders -}} | ||
| {{- $globalJwtProviderName := $security.jwtProviderName -}} | ||
| {{- $globalJwksURI := $security.jwksURI -}} | ||
|
|
||
| {{ range $policyIndex, $policy := $policies }} | ||
| {{- $policyName := required (printf "envoy.security.policies[%d].name is required" $policyIndex) $policy.name -}} | ||
| {{- $issuer := required (printf "SecurityPolicy %q requires envoy.security.issuer or policies[].issuer" $policyName) (coalesce $policy.issuer $globalIssuer) -}} | ||
| {{- $redirectURL := required (printf "SecurityPolicy %q requires redirectURL (set envoy.security.redirectURL or policies[].redirectURL)" $policyName) (coalesce $policy.redirectURL $globalRedirectURL) -}} | ||
| {{- $cookieDomain := required (printf "SecurityPolicy %q requires cookieDomain (set envoy.security.cookieDomain or policies[].cookieDomain)" $policyName) (coalesce $policy.cookieDomain $globalCookieDomain) -}} | ||
| {{- $logoutPath := coalesce $policy.logoutPath $globalLogoutPath "/logout" -}} | ||
| {{- $clientID := coalesce $policy.clientID $globalClientID $serviceName -}} | ||
| {{- $defaultSecretName := printf "%s-oidc-secret" $serviceName -}} | ||
| {{- $clientSecretName := coalesce $policy.clientSecretName $globalClientSecretName $defaultSecretName -}} | ||
| {{- $scopes := coalesce $policy.scopes $globalScopes -}} | ||
| {{- $claimToHeaders := coalesce $policy.claimToHeaders $globalClaimHeaders -}} | ||
| {{- $jwtProviderName := coalesce $policy.jwtProviderName $globalJwtProviderName "keycloak" -}} | ||
| {{- $jwksURI := coalesce $policy.jwksURI $globalJwksURI (printf "%s/protocol/openid-connect/certs" $issuer) -}} | ||
| {{- $targetRef := $policy.targetRef -}} | ||
| {{- $targetRefs := $policy.targetRefs -}} | ||
| {{- $rawSelectors := list -}} | ||
| {{- if $policy.targetSelectors }} | ||
| {{- if kindIs "slice" $policy.targetSelectors }} | ||
| {{- $rawSelectors = $policy.targetSelectors -}} | ||
| {{- else }} | ||
| {{- $rawSelectors = list $policy.targetSelectors -}} | ||
| {{- end }} | ||
| {{- else if $policy.targetSelector }} | ||
| {{- $rawSelectors = list $policy.targetSelector -}} | ||
| {{- end }} | ||
| {{- if and (not $targetRef) (not $targetRefs) (eq (len $rawSelectors) 0) }} | ||
| {{- $rawSelectors = list (dict "matchLabels" (dict $securityLabelKey "true")) -}} | ||
| {{- end }} | ||
| {{- $targetSelectors := list -}} | ||
| {{- range $rawSelectors }} | ||
| {{- $group := default "gateway.networking.k8s.io" .group -}} | ||
| {{- $kind := default "HTTPRoute" .kind -}} | ||
| {{- $matchLabels := default (dict) .matchLabels -}} | ||
| {{- $targetSelectors = append $targetSelectors (dict "group" $group "kind" $kind "matchLabels" $matchLabels) -}} | ||
| {{- end }} | ||
| {{- $defaultAction := default "Deny" $policy.defaultAction -}} | ||
| --- | ||
| apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
| kind: SecurityPolicy | ||
| metadata: | ||
| name: {{ $policyName }} | ||
| namespace: {{ $policyNamespace | quote }} | ||
| annotations: | ||
| oidc.autoregistrar.parcellab.dev/sync-enabled: 'true' | ||
| spec: | ||
| {{- if $targetRef }} | ||
| targetRef: | ||
| {{- toYaml $targetRef | nindent 4 }} | ||
| {{- else if $targetRefs }} | ||
| targetRefs: | ||
| {{- toYaml $targetRefs | nindent 4 }} | ||
| {{- else }} | ||
| targetSelectors: | ||
| {{- toYaml $targetSelectors | nindent 4 }} | ||
| {{- end }} | ||
| oidc: | ||
| provider: | ||
| issuer: {{ $issuer | quote }} | ||
| clientID: {{ $clientID | quote }} | ||
| clientSecret: | ||
| name: {{ $clientSecretName | quote }} | ||
| redirectURL: {{ $redirectURL | quote }} | ||
| logoutPath: {{ $logoutPath | quote }} | ||
| {{- with $scopes }} | ||
| scopes: | ||
| {{ toYaml . | nindent 6 }} | ||
| {{- end }} | ||
| cookieDomain: {{ $cookieDomain | quote }} | ||
| forwardAccessToken: true | ||
| passThroughAuthHeader: true | ||
| jwt: | ||
| optional: false | ||
| providers: | ||
| - name: {{ $jwtProviderName | quote }} | ||
| issuer: {{ $issuer | quote }} | ||
| remoteJWKS: | ||
| cacheDuration: 300s | ||
| uri: {{ $jwksURI | quote }} | ||
| {{- with $claimToHeaders }} | ||
| claimToHeaders: | ||
| {{ toYaml . | nindent 8 }} | ||
andibeuge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {{- end }} | ||
|
|
||
| authorization: | ||
| defaultAction: {{ $defaultAction }} | ||
| {{- with $policy.authorizationRules }} | ||
| rules: | ||
| {{ toYaml . | nindent 6 }} | ||
| {{- end }} | ||
| {{ end }} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {{- include "common.httproutes" . }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {{- include "common.referencegrant" . }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {{- include "common.securitypolicies" . }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {{- include "common.httproutes" . }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {{- include "common.referencegrant" . }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {{- include "common.securitypolicies" . }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.