Skip to content

Commit d3da3e4

Browse files
committed
chore(examples): remove castai_rebalancing_schedules from most examples
`castai_rebalancing_schedule` is an organization-level resource while most of our examples are in the scope of a single cluster. Trying to create (and recreate) a rebalancing schedule from the same example (or different examples) can lead to errors like: ``` │ Error: expected status code 200, received: status=409 body={"message":"Schedule with a name \"rebalance spots at every 30th minute\" already exists","fieldViolations":[]} │ │ with castai_rebalancing_schedule.spots, │ on castai.tf line 221, in resource "castai_rebalancing_schedule" "spots": │ 221: resource "castai_rebalancing_schedule" "spots" { ``` I'm removing `castai_rebalancing_schedules` and referencing `castai_rebalancing_job`s in all examples but `gke/gke_clusters_with_workspaces` where organization and cluster level are correctly separated. The data source and resource examples also still remain in place.
1 parent 1e50190 commit d3da3e4

File tree

3 files changed

+0
-103
lines changed

3 files changed

+0
-103
lines changed

examples/aks/aks_cluster_existing/castai.tf

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -128,30 +128,3 @@ module "castai_aks_cluster" {
128128

129129
install_omni = true
130130
}
131-
132-
resource "castai_rebalancing_schedule" "default" {
133-
name = "rebalance nodes at every 30th minute"
134-
schedule {
135-
cron = "CRON_TZ=America/Argentina/Buenos_Aires */30 * * * *"
136-
}
137-
trigger_conditions {
138-
savings_percentage = 20
139-
}
140-
launch_configuration {
141-
# only consider instances older than 5 minutes
142-
node_ttl_seconds = 300
143-
num_targeted_nodes = 3
144-
rebalancing_min_nodes = 2
145-
keep_drain_timeout_nodes = false
146-
execution_conditions {
147-
enabled = true
148-
achieved_savings_percentage = 10
149-
}
150-
}
151-
}
152-
153-
resource "castai_rebalancing_job" "default" {
154-
cluster_id = module.castai_aks_cluster.cluster_id
155-
rebalancing_schedule_id = castai_rebalancing_schedule.default.id
156-
enabled = true
157-
}

examples/eks/eks_cluster_autoscaler_policies/castai.tf

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -217,41 +217,3 @@ module "castai-eks-cluster" {
217217
# module "castai-eks-cluster" has to be destroyed before module "castai-eks-role-iam".
218218
depends_on = [module.castai-eks-role-iam, module.vpc, module.eks]
219219
}
220-
221-
resource "castai_rebalancing_schedule" "spots" {
222-
name = "rebalance spots at every 30th minute"
223-
schedule {
224-
cron = "*/30 * * * *"
225-
}
226-
trigger_conditions {
227-
savings_percentage = 20
228-
}
229-
launch_configuration {
230-
# only consider instances older than 5 minutes
231-
node_ttl_seconds = 300
232-
num_targeted_nodes = 3
233-
rebalancing_min_nodes = 2
234-
keep_drain_timeout_nodes = false
235-
selector = jsonencode({
236-
nodeSelectorTerms = [{
237-
matchExpressions = [
238-
{
239-
key = "scheduling.cast.ai/spot"
240-
operator = "Exists"
241-
}
242-
]
243-
}]
244-
})
245-
execution_conditions {
246-
enabled = true
247-
achieved_savings_percentage = 10
248-
}
249-
}
250-
}
251-
252-
resource "castai_rebalancing_job" "spots" {
253-
cluster_id = castai_eks_clusterid.cluster_id.id
254-
rebalancing_schedule_id = castai_rebalancing_schedule.spots.id
255-
enabled = true
256-
depends_on = [module.castai-eks-cluster]
257-
}

examples/eks/eks_cluster_existing/castai.tf

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -194,41 +194,3 @@ module "castai_eks_cluster" {
194194
# module "castai-eks-cluster" has to be destroyed before module "castai-eks-role-iam".
195195
depends_on = [module.castai_eks_role_iam]
196196
}
197-
198-
resource "castai_rebalancing_schedule" "spots" {
199-
name = "rebalance spots at every 30th minute"
200-
schedule {
201-
cron = "*/30 * * * *"
202-
}
203-
trigger_conditions {
204-
savings_percentage = 20
205-
}
206-
launch_configuration {
207-
# only consider instances older than 5 minutes
208-
node_ttl_seconds = 300
209-
num_targeted_nodes = 3
210-
rebalancing_min_nodes = 2
211-
keep_drain_timeout_nodes = false
212-
selector = jsonencode({
213-
nodeSelectorTerms = [{
214-
matchExpressions = [
215-
{
216-
key = "scheduling.cast.ai/spot"
217-
operator = "Exists"
218-
}
219-
]
220-
}]
221-
})
222-
execution_conditions {
223-
enabled = true
224-
achieved_savings_percentage = 10
225-
}
226-
}
227-
}
228-
229-
resource "castai_rebalancing_job" "spots" {
230-
cluster_id = castai_eks_clusterid.cluster_id.id
231-
rebalancing_schedule_id = castai_rebalancing_schedule.spots.id
232-
enabled = true
233-
depends_on = [module.castai_eks_cluster]
234-
}

0 commit comments

Comments
 (0)