-
Notifications
You must be signed in to change notification settings - Fork 69
changes to make pxb compatible for Helm4 support #876
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
Open
vk-px
wants to merge
2
commits into
pre-release-2.11.0
Choose a base branch
from
helm4-support-2.11.0-base
base: pre-release-2.11.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| {{/* | ||
| ============================================================================= | ||
| CRD Helper Templates for Helm 4 SSA Compatibility | ||
| ============================================================================= | ||
|
|
||
| These helpers support conditional CRD installation to prevent conflicts when | ||
| CRDs are pre-installed by another component (e.g., Portworx Enterprise). | ||
|
|
||
| In Helm 4 with Server-Side Apply (SSA), CRD ownership conflicts occur when | ||
| multiple managers attempt to manage the same CRD. By conditionally installing | ||
| CRDs only when they don't exist, we avoid these conflicts. | ||
|
|
||
| SUPPORTED VALUES for .Values.installCRDs: | ||
| - "true" : Always install CRDs (use when CRDs don't exist) | ||
| - "false" : Never install CRDs (use with ArgoCD when CRDs are managed separately, | ||
| or when Portworx Enterprise is pre-installed) | ||
| - "auto" : Use Helm lookup to detect if CRDs exist (default) | ||
| NOTE: With ArgoCD, lookup always returns empty, so "auto" behaves | ||
| like "true". ArgoCD users with pre-existing CRDs should use "false". | ||
|
|
||
| ARGOCD USERS: | ||
| When deploying via ArgoCD with pre-existing CRDs (e.g., Portworx installed), | ||
| you MUST set installCRDs: "false" to avoid conflicts. ArgoCD uses `helm template` | ||
| which doesn't have cluster access, so the lookup function cannot detect existing CRDs. | ||
|
|
||
| Alternatively, use ArgoCD's built-in skipCrds option: | ||
| spec: | ||
| source: | ||
| helm: | ||
| skipCrds: true | ||
| */}} | ||
|
|
||
| {{/* | ||
| Check if a CRD exists in the cluster. | ||
| Usage: {{ include "px-central.crdExists" "alertmanagers.monitoring.coreos.com" }} | ||
| Returns: "true" if the CRD exists, "false" otherwise | ||
|
|
||
| NOTE: This returns "false" when used with ArgoCD (helm template) because | ||
| lookup requires cluster access which ArgoCD doesn't provide during rendering. | ||
| */}} | ||
| {{- define "px-central.crdExists" -}} | ||
| {{- $crd := lookup "apiextensions.k8s.io/v1" "CustomResourceDefinition" "" . -}} | ||
| {{- if $crd }}true{{- else }}false{{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Determine if a CRD should be installed based on installCRDs value. | ||
| Usage: {{ include "px-central.shouldInstallCRD" (dict "crdName" "alertmanagers.monitoring.coreos.com" "context" .) }} | ||
| Returns: "true" if the CRD should be installed, "false" otherwise | ||
|
|
||
| Logic: | ||
| - During upgrades: Always return "false" (CRDs were installed during initial install) | ||
| - installCRDs: "true" or true -> Always return "true" | ||
| - installCRDs: "false" or false -> Always return "false" | ||
| - installCRDs: "auto" (default) -> Use lookup to check if CRD exists | ||
| (NOTE: ArgoCD will always get "true" here due to lookup limitations) | ||
|
|
||
| NOTE: Helm --set flag parses "false" as boolean, while values.yaml keeps it as string. | ||
| This helper handles both boolean and string types. | ||
| */}} | ||
| {{- define "px-central.shouldInstallCRD" -}} | ||
| {{- /* Skip CRD installation during upgrades - CRDs were installed during initial install */ -}} | ||
| {{- if or .context.Release.IsUpgrade .context.Values.isUpgrade -}} | ||
| false | ||
| {{- else -}} | ||
| {{- /* Get installCRDs value, defaulting to "auto" if nil/empty string */ -}} | ||
| {{- $installCRDs := .context.Values.installCRDs -}} | ||
| {{- /* Check if installCRDs is nil or empty string (but NOT boolean false) */ -}} | ||
| {{- $isNilOrEmpty := and (not (kindIs "bool" $installCRDs)) (not $installCRDs) -}} | ||
| {{- if $isNilOrEmpty -}} | ||
| {{- $installCRDs = "auto" -}} | ||
| {{- end -}} | ||
| {{- /* Convert to string for consistent comparison */ -}} | ||
| {{- $installCRDsStr := toString $installCRDs -}} | ||
| {{- /* Handle "true" (also handles boolean true which becomes "true") */ -}} | ||
| {{- if eq $installCRDsStr "true" -}} | ||
| true | ||
| {{- /* Handle "false" (also handles boolean false which becomes "false") */ -}} | ||
| {{- else if eq $installCRDsStr "false" -}} | ||
| false | ||
| {{- else -}} | ||
| {{- /* installCRDs = "auto" - use lookup */ -}} | ||
| {{- $crdExists := include "px-central.crdExists" .crdName -}} | ||
| {{- if eq $crdExists "true" -}} | ||
| false | ||
| {{- else -}} | ||
| true | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| CRD labels - common labels for all CRDs | ||
| */}} | ||
| {{- define "px-central.crdLabels" -}} | ||
| app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| app.kubernetes.io/part-of: px-central | ||
| helm.sh/chart: {{ include "px-central.chart" . }} | ||
| {{- 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
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
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.