kubecost / cluster-turndown

Automated turndown of Kubernetes clusters on specific schedules.
Apache License 2.0
259 stars 23 forks source link

Upgrade turndownschedules CRD to apiextensions v1 #44

Closed michaelmdresser closed 2 years ago

michaelmdresser commented 2 years ago

This PR addresses https://github.com/kubecost/cluster-turndown/issues/40.

Changes

apiextensions.k8s.io/v1beta1 is removed as of K8s v1.22 [1], so all CRDs have to be updated to apiextensions.k8s.io/v1. This commit does the upgrade for the turndownschedule CRD.

As part of the API updates, K8s is enforcing things grouped under *.k8s.io to be approved [2] because they are actually supposed to be Kubernetes community-managed APIs [3]. So this commit also changes the CRD from:

turndownschedules.kubecost.k8s.io to turndownschedules.kubecost.com

This is in-line with K8s rules and links to our main domain.

Testing

Tested by applying cluster-turndown-full.yaml and example-schedule.yaml successfully (with updated container image from this commit) as instructed by the README.

Notes

We did a similar change in https://github.com/kubecost/cost-analyzer-helm-chart/pull/1429 but didn't do all of the necessary steps, like changing the CRD group to kubecost.com and similar changes. Once this PR has been approved, merged, and a new version of cluster-turndown is released, we'll have to update cluster-controller (because of the regenerated code for turndownschedules.kubecost.com) and the turndownschedule CRD in the main Kubecost Helm chart.

[1] https://cloud.google.com/kubernetes-engine/docs/deprecations/apis-1-22 [2] https://github.com/kubernetes/enhancements/pull/1111 [3] https://github.com/kubernetes/enhancements/pull/1111#issuecomment-507834574

michaelmdresser commented 2 years ago

Does this break existing resources?

Yes, unfortunately it does. This requires a major version update and a breaking change notification in the release notes.