From 80aca0c71e05b03f82fb3f28d4157a5e510b84c6 Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Tue, 6 Feb 2024 19:55:09 +0100 Subject: [PATCH 1/4] Updated RBAC API version. The `rbac.authorization.k8s.io/v1beta1` API version of ClusterRole and ClusterRoleBinding is no longer served as of Kubernetes v1.22. https://kubernetes.io/docs/reference/using-api/deprecation-guide/#rbac-resources-v122 --- artifacts/kubes/scaling/chart/templates/rbac.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/artifacts/kubes/scaling/chart/templates/rbac.yaml b/artifacts/kubes/scaling/chart/templates/rbac.yaml index 07a7968..27b1e8a 100644 --- a/artifacts/kubes/scaling/chart/templates/rbac.yaml +++ b/artifacts/kubes/scaling/chart/templates/rbac.yaml @@ -1,6 +1,6 @@ {{- if .Values.rbac.create -}} kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 metadata: name: {{ template "scheduled-scaler.fullname" . }} rules: @@ -26,7 +26,7 @@ metadata: name: {{ template "scheduled-scaler.fullname" . }} namespace: {{ .Release.Namespace }} --- -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: {{ template "scheduled-scaler.fullname" . }} From 7c2102dfffdbc1c7067efd14a16bea5ffbb67f9e Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Tue, 6 Feb 2024 19:57:21 +0100 Subject: [PATCH 2/4] Updated CRD API version. The `apiextensions.k8s.io/v1beta1` API version of CustomResourceDefinition is no longer served as of Kubernetes v1.22. https://kubernetes.io/docs/reference/using-api/deprecation-guide/#customresourcedefinition-v122 --- artifacts/kubes/scaling/chart/templates/crd.yaml | 2 +- artifacts/kubes/scaling/crd.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/artifacts/kubes/scaling/chart/templates/crd.yaml b/artifacts/kubes/scaling/chart/templates/crd.yaml index c7220ab..ee81b51 100644 --- a/artifacts/kubes/scaling/chart/templates/crd.yaml +++ b/artifacts/kubes/scaling/chart/templates/crd.yaml @@ -1,4 +1,4 @@ -apiVersion: apiextensions.k8s.io/v1beta1 +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: # name must match the spec fields below, and be in the form: . diff --git a/artifacts/kubes/scaling/crd.yml b/artifacts/kubes/scaling/crd.yml index c7220ab..ee81b51 100644 --- a/artifacts/kubes/scaling/crd.yml +++ b/artifacts/kubes/scaling/crd.yml @@ -1,4 +1,4 @@ -apiVersion: apiextensions.k8s.io/v1beta1 +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: # name must match the spec fields below, and be in the form: . From f7c04ff6e6a6d83891646d0c17b550ae48d98b74 Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Tue, 6 Feb 2024 20:06:10 +0100 Subject: [PATCH 3/4] Updated CRD API version. Added required openAPIV3Schema. The `apiextensions.k8s.io/v1beta1` API version of CustomResourceDefinition is no longer served as of Kubernetes v1.22. https://kubernetes.io/docs/reference/using-api/deprecation-guide/#customresourcedefinition-v122 --- .../kubes/scaling/chart/templates/crd.yaml | 45 ++++++++++++++++++- artifacts/kubes/scaling/crd.yml | 44 +++++++++++++++++- 2 files changed, 86 insertions(+), 3 deletions(-) diff --git a/artifacts/kubes/scaling/chart/templates/crd.yaml b/artifacts/kubes/scaling/chart/templates/crd.yaml index ee81b51..95d22fa 100644 --- a/artifacts/kubes/scaling/chart/templates/crd.yaml +++ b/artifacts/kubes/scaling/chart/templates/crd.yaml @@ -6,8 +6,49 @@ metadata: spec: # group name to use for REST API: /apis// group: scaling.k8s.restdev.com - # version name to use for REST API: /apis// - version: v1alpha1 + versions: + # version name to use for REST API: /apis// + - name: v1alpha1 + served: true + storage: true + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + timeZone: + type: string + target: + type: object + properties: + kind: + type: string + name: + type: string + apiVersion: + type: string + required: ["kind", "name", "apiVersion"] + steps: + type: array + items: + type: object + properties: + runat: + type: string + pattern: "^(((\\d+|\\d+(-|\\/)\\d+)(,(\\d+|\\d+(-|\\/)\\d+))*|\\*) ){5}((\\d+|\\d+(-|\\/)\\d+)(,(\\d+|\\d+(-|\\/)\\d+))*|\\*)$" + mode: + type: string + pattern: "^(fixed|range)$" + replicas: + type: integer + minReplicas: + type: integer + maxReplicas: + type: integer + required: ["runat", "mode"] + required: ["target", "steps"] # either Namespaced or Cluster scope: Namespaced names: diff --git a/artifacts/kubes/scaling/crd.yml b/artifacts/kubes/scaling/crd.yml index ee81b51..8e3af6c 100644 --- a/artifacts/kubes/scaling/crd.yml +++ b/artifacts/kubes/scaling/crd.yml @@ -7,7 +7,49 @@ spec: # group name to use for REST API: /apis// group: scaling.k8s.restdev.com # version name to use for REST API: /apis// - version: v1alpha1 + versions: + # version name to use for REST API: /apis// + - name: v1alpha1 + served: true + storage: true + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + timeZone: + type: string + target: + type: object + properties: + kind: + type: string + name: + type: string + apiVersion: + type: string + required: ["kind", "name", "apiVersion"] + steps: + type: array + items: + type: object + properties: + runat: + type: string + pattern: "^(((\\d+|\\d+(-|\\/)\\d+)(,(\\d+|\\d+(-|\\/)\\d+))*|\\*) ){5}((\\d+|\\d+(-|\\/)\\d+)(,(\\d+|\\d+(-|\\/)\\d+))*|\\*)$" + mode: + type: string + pattern: "^(fixed|range)$" + replicas: + type: integer + minReplicas: + type: integer + maxReplicas: + type: integer + required: ["runat", "mode"] + required: ["target", "steps"] # either Namespaced or Cluster scope: Namespaced names: From ccaa47fc228896099f88812ded75d7747b1afa6a Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Tue, 6 Feb 2024 20:22:21 +0100 Subject: [PATCH 4/4] Added descriptions to CRD --- artifacts/kubes/scaling/chart/templates/crd.yaml | 14 ++++++++++++++ artifacts/kubes/scaling/crd.yml | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/artifacts/kubes/scaling/chart/templates/crd.yaml b/artifacts/kubes/scaling/chart/templates/crd.yaml index 95d22fa..da9048f 100644 --- a/artifacts/kubes/scaling/chart/templates/crd.yaml +++ b/artifacts/kubes/scaling/chart/templates/crd.yaml @@ -13,39 +13,53 @@ spec: storage: true schema: openAPIV3Schema: + description: "ScheduledScaler is the Schema for the scheduled-scaler API" type: object properties: spec: + description: "ScheduledScalerSpec is the specification of a ScheduledScaler" type: object properties: timeZone: + description: "Timezone to use for the cronjob" type: string target: + description: "Target to scale" type: object properties: kind: + description: "Kind of the target (InstanceGroup/HorizontalPodAutoscaler)" type: string name: + description: "Name of the target resource" type: string apiVersion: + description: "API version of the target resource" type: string required: ["kind", "name", "apiVersion"] steps: + description: "List of steps to scale the target resource at a specific time." type: array items: + description: "Step to scale the target resource at a specific time." type: object properties: runat: + description: "Cronjob time string (gocron) to run the scaling. Uses Cron Expression Format, https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format" type: string pattern: "^(((\\d+|\\d+(-|\\/)\\d+)(,(\\d+|\\d+(-|\\/)\\d+))*|\\*) ){5}((\\d+|\\d+(-|\\/)\\d+)(,(\\d+|\\d+(-|\\/)\\d+))*|\\*)$" mode: + description: "Type of scaling to run. 'fixed': set replicas to a fixed value, 'range': set replicas to a range" type: string pattern: "^(fixed|range)$" replicas: + description: "Number of replicas to set when mode is 'fixed'" type: integer minReplicas: + description: "Minimum number of replicas to set when mode is 'range'" type: integer maxReplicas: + description: "Maximum number of replicas to set when mode is 'range'" type: integer required: ["runat", "mode"] required: ["target", "steps"] diff --git a/artifacts/kubes/scaling/crd.yml b/artifacts/kubes/scaling/crd.yml index 8e3af6c..da9048f 100644 --- a/artifacts/kubes/scaling/crd.yml +++ b/artifacts/kubes/scaling/crd.yml @@ -6,7 +6,6 @@ metadata: spec: # group name to use for REST API: /apis// group: scaling.k8s.restdev.com - # version name to use for REST API: /apis// versions: # version name to use for REST API: /apis// - name: v1alpha1 @@ -14,39 +13,53 @@ spec: storage: true schema: openAPIV3Schema: + description: "ScheduledScaler is the Schema for the scheduled-scaler API" type: object properties: spec: + description: "ScheduledScalerSpec is the specification of a ScheduledScaler" type: object properties: timeZone: + description: "Timezone to use for the cronjob" type: string target: + description: "Target to scale" type: object properties: kind: + description: "Kind of the target (InstanceGroup/HorizontalPodAutoscaler)" type: string name: + description: "Name of the target resource" type: string apiVersion: + description: "API version of the target resource" type: string required: ["kind", "name", "apiVersion"] steps: + description: "List of steps to scale the target resource at a specific time." type: array items: + description: "Step to scale the target resource at a specific time." type: object properties: runat: + description: "Cronjob time string (gocron) to run the scaling. Uses Cron Expression Format, https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format" type: string pattern: "^(((\\d+|\\d+(-|\\/)\\d+)(,(\\d+|\\d+(-|\\/)\\d+))*|\\*) ){5}((\\d+|\\d+(-|\\/)\\d+)(,(\\d+|\\d+(-|\\/)\\d+))*|\\*)$" mode: + description: "Type of scaling to run. 'fixed': set replicas to a fixed value, 'range': set replicas to a range" type: string pattern: "^(fixed|range)$" replicas: + description: "Number of replicas to set when mode is 'fixed'" type: integer minReplicas: + description: "Minimum number of replicas to set when mode is 'range'" type: integer maxReplicas: + description: "Maximum number of replicas to set when mode is 'range'" type: integer required: ["runat", "mode"] required: ["target", "steps"]