From a148bd04671dc53915230a32525b2c7691efe0cd Mon Sep 17 00:00:00 2001 From: Michael Dresser Date: Fri, 27 May 2022 17:00:29 -0400 Subject: [PATCH 1/4] Update Cluster Controller docs: link to turndown No reason to repeat instructions that are already available in an OSS repo. --- controller.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/controller.md b/controller.md index 6ef83d0b8..6edfd2f65 100644 --- a/controller.md +++ b/controller.md @@ -1,11 +1,11 @@ Cluster Controller ================== -Kubecost's cluster controller contains Kubecost's automation features, +Kubecost's Cluster Controller contains Kubecost's automation features, and thus has write permission to certain resources on your cluster. Cluster controller enables actions like: -- automated cluster scaledown +- Automated cluster scaledown - 1-click cluster right-sizing - [1-click request right-sizing](./guide-one-click-request-sizing.md) @@ -63,6 +63,10 @@ You may also enable via `--set` when running helm install: --set clusterController.enabled=true ``` +## Using automated cluster scaledown + +Cluster Controller wraps all functionality in and provides the same interface/CRDs as https://github.com/kubecost/cluster-turndown. Follow that documentation for usage instructions. You can safely ignore the deployment instructions in that README because you have already deployed Cluster Controller. + Edit this doc on [GitHub](https://github.com/kubecost/docs/blob/main/controller.md) From 105338bfc10e0a39e8aba8d95a4f53c37b84fd62 Mon Sep 17 00:00:00 2001 From: Michael Dresser Date: Fri, 27 May 2022 17:02:36 -0400 Subject: [PATCH 2/4] Add breaking change note for turndown CRDs --- controller.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controller.md b/controller.md index 6edfd2f65..07057b707 100644 --- a/controller.md +++ b/controller.md @@ -67,6 +67,8 @@ You may also enable via `--set` when running helm install: Cluster Controller wraps all functionality in and provides the same interface/CRDs as https://github.com/kubecost/cluster-turndown. Follow that documentation for usage instructions. You can safely ignore the deployment instructions in that README because you have already deployed Cluster Controller. +> The v1 -> v2 breaking change mentioned in the cluster-turndown README also applies to Cluster Controller, but for v0.0.6 -> v0.1.0. Cluster Controller was upgraded to v0.1.0 in v1.94 of Kubecost. + Edit this doc on [GitHub](https://github.com/kubecost/docs/blob/main/controller.md) From 2fe5372e3a5ca9770170f238a947e0b987939924 Mon Sep 17 00:00:00 2001 From: Michael Dresser Date: Thu, 2 Jun 2022 12:40:29 -0400 Subject: [PATCH 3/4] Add TurndownSchedule migration guide for v1.94+ --- controller.md | 2 +- v1-94-turndown-schedule-migration-guide.md | 65 ++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 v1-94-turndown-schedule-migration-guide.md diff --git a/controller.md b/controller.md index 07057b707..c9ecdd555 100644 --- a/controller.md +++ b/controller.md @@ -67,7 +67,7 @@ You may also enable via `--set` when running helm install: Cluster Controller wraps all functionality in and provides the same interface/CRDs as https://github.com/kubecost/cluster-turndown. Follow that documentation for usage instructions. You can safely ignore the deployment instructions in that README because you have already deployed Cluster Controller. -> The v1 -> v2 breaking change mentioned in the cluster-turndown README also applies to Cluster Controller, but for v0.0.6 -> v0.1.0. Cluster Controller was upgraded to v0.1.0 in v1.94 of Kubecost. +> :warning: The v1 -> v2 breaking change mentioned in the cluster-turndown README also applies to Cluster Controller, but for v0.0.6 -> v0.1.0. Cluster Controller was upgraded to v0.1.0 in v1.94 of Kubecost. Follow the [migration guide](https://github.com/kubecost/docs/blob/main/v1-94-turndown-schedule-migration-guide.md) if you use turndown in a version of Kubecost < v1.94 and are upgrading to v1.94+ of Kubecost. Edit this doc on [GitHub](https://github.com/kubecost/docs/blob/main/controller.md) diff --git a/v1-94-turndown-schedule-migration-guide.md b/v1-94-turndown-schedule-migration-guide.md new file mode 100644 index 000000000..6287d5553 --- /dev/null +++ b/v1-94-turndown-schedule-migration-guide.md @@ -0,0 +1,65 @@ +v1.94+ TurndownSchedule migration guide +======================================= + +In v1.94 of Kubecost, the `turndownschedules.kubecost.k8s.io/v1alpha1` Custom Resource Definition (CRD) was [moved](https://github.com/kubecost/cost-analyzer-helm-chart/pull/1444) to `turndownschedules.kubecost.com/v1alpha1` to adhere to [Kubernetes policy for CRD domain namespacing](https://github.com/kubernetes/enhancements/pull/1111). This is a breaking change for users of Cluster Controller's turndown functionality. Please follow this guide for a successful migration of your turndown schedule resources. + +> As part of this change, the CRD was updated to use `apiextensions.k8s.io/v1` because `v1beta1` was removed in K8s v1.22. If using Kubecost v1.94+, Cluster Controller's turndown functionality will not work on K8s versions before the introduction of `apiextensions.k8s.io/v1`. + +# Situation 1: You have deployed cluster controller but don't use turndown + +In this situation, you've deployed Kubecost's Cluster Controller at some point +using `--set clusterController.enabled=true`, but you don't use the turndown functionality. + +That means that this command should return one line: + + kubectl get crd turndownschedules.kubecost.k8s.io + +And this command should return no resources: + + kubectl get turndownschedules.kubecost.k8s.io + +This situation is easy! You can do nothing, and turndown should continue to behave correctly because `kubectl get turndownschedule` and related commands will correctly default to the new `turndownschedules.kubecost.com/v1alpha1` CRD after you upgrade to Kubecost v1.94 or higher. + +If you would like to be fastidious and clean up the old CRD, simply run `kubectl delete crd turndownschedules.kubecost.k8s.io` after upgrading Kubecost to v1.94 or higher. + + +# Situation 2: You currently use turndown + +In this situation, you've deployed Kubecost's Cluster Controller at some point using `--set clusterController.enabled=true` and you have at least one `turndownschedule.kubecost.k8s.io` resource currently present in your cluster. + +That means that this command should return one line: + + kubectl get crd turndownschedules.kubecost.k8s.io + +And this command should return at least one resource: + + kubectl get turndownschedules.kubecost.k8s.io + +We have a few steps to perform if you want Cluster Controller's turndown functionality to continue to behave according to your already-defined turndown schedules. + +1. Upgrade Kubecost to v1.94 or higher with `--set clusterController.enabled=true` +2. Make sure the new CRD has been defined after your Kubecost upgrade. + + This command should return a line: + + kubectl get crd turndownschedules.kubecost.com + +3. Copy your existing `turndownschedules.kubecost.k8s.io` resources into the new CRD. + + kubectl get turndownschedules.kubecost.k8s.io -o yaml \ + | sed 's|kubecost.k8s.io|kubecost.com|' \ + | kubectl apply -f - + +4. (optional) Delete the old `turndownschedules.kubecost.k8s.io` CRD + + Because the CRDs have a finalizer on them, we have to follow [this workaround](https://github.com/kubernetes/kubernetes/issues/60538#issuecomment-369099998) to remove the finalizer from our old resources. This lets us clean up without locking up. + + kubectl patch \ + crd/turndownschedules.kubecost.k8s.io \ + -p '{"metadata":{"finalizers":[]}}' \ + --type=merge + + kubectl delete crd turndownschedules.kubecost.k8s.io + + + From 23faa59b36e85ab81f56d4392980009360fc5eb6 Mon Sep 17 00:00:00 2001 From: Michael Dresser Date: Thu, 2 Jun 2022 16:19:03 -0400 Subject: [PATCH 4/4] Note unnecessary delete command --- v1-94-turndown-schedule-migration-guide.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/v1-94-turndown-schedule-migration-guide.md b/v1-94-turndown-schedule-migration-guide.md index 6287d5553..3e2b4f3b5 100644 --- a/v1-94-turndown-schedule-migration-guide.md +++ b/v1-94-turndown-schedule-migration-guide.md @@ -59,6 +59,8 @@ We have a few steps to perform if you want Cluster Controller's turndown functio -p '{"metadata":{"finalizers":[]}}' \ --type=merge + > The following command may be unnecessary because Helm should automatically remove the `turndownschedules.kubecost.k8s.io` resource during the upgrade. The removal will remain in a pending state until the finalizer patch above is implemented. + kubectl delete crd turndownschedules.kubecost.k8s.io