-
Notifications
You must be signed in to change notification settings - Fork 716
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
Fix CRD chart regression and fix CRDs for upgrades #1131
Conversation
fff7a3c
to
72a97c8
Compare
- > | ||
{{- range $path, $_ := (.Files.Glob "crd-manifest/**.yaml") }} | ||
{{- $crd := get (get ($.Files.Get $path | fromYaml) "metadata") "name" }} | ||
if [[ -n "$(kubectl get crd {{ $crd }} -o jsonpath='{.spec.preserveUnknownFields}')" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a best effort operation (hence the || true
) that should be done only if the CRD exists and has .spec.preserveUnknownFields
set to some value.
If the CRD does not exist or if .spec.preserveUnknownFields
is unset, this bash script will skip since the kubectl get
command will return nothing to the stdout, but it will still print the error in finding the resource since the kubectl get command prints to stderr.
{{- range $path, $_ := (.Files.Glob "crd-manifest/**.yaml") }} | ||
{{- $crd := get (get ($.Files.Get $path | fromYaml) "metadata") "name" }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helm code that basically says "look at each file in crd-manifest that ends with .yaml and parse it as a YAML doc. Then pull out metadata.name
's value and put it in the variable $crd."
e.g. anywhere that says {{ $crd }}
below would look like prometheus.monitoring.coreos.com
.
72a97c8
to
9ce7e3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fix CRD chart regression and fix CRDs for upgrades
Fix CRD chart regression and fix CRDs for upgrades
Merge pull request #1131 from aiyengar2/fix_crd_chart Fix CRD chart regression and fix CRDs for upgrades
Fix CRD chart regression and fix CRDs for upgrades
The first commit reverts a change introduced in a previous commit that deletes CRDs before re-installing them. This is not an option in a production environment since it would wipe out all of the CRs in the cluster, which would effectively remove any customization that a user added between Monitoring chart upgrades.
The second commit modifies the CRD chart to use rancher/agent instead of rancher/kubectl (since we need to perform some light scripting and
sh
is not offered in rancher/kubectl).Once the image was modified, I changed the remove-finalizer container to avoid doing an entire kubectl apply in favor of just removing the finalizers (the original intention of the container) and added a new initContainer on install that would destroy the preserveUnknownField on an upgrade due to an issue with upgrading an apiextensions.k8s.io/v1beta1 CRD to one in apiextensions.k8s.io/v1, as noted in https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#field-pruning using the workaround described in kubernetes-sigs/controller-tools#476 (comment).
Related Issue: rancher/rancher#31991, rancher/rancher#32225