Skip to content

Commit

Permalink
Merge pull request #549 from zalando-incubator/scaling-schedule-status
Browse files Browse the repository at this point in the history
Add scaling schedule controller to updating status
  • Loading branch information
mikkeloscar committed Apr 12, 2023
2 parents b631a4f + 0794873 commit 88b7d74
Show file tree
Hide file tree
Showing 15 changed files with 793 additions and 155 deletions.
18 changes: 17 additions & 1 deletion docs/cluster_scaling_schedules_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ spec:
singular: clusterscalingschedule
scope: Cluster
versions:
- name: v1
- additionalPrinterColumns:
- description: Whether one or more schedules are currently active.
jsonPath: .status.active
name: Active
type: boolean
name: v1
schema:
openAPIV3Schema:
description: ClusterScalingSchedule describes a cluster scoped time based
Expand Down Expand Up @@ -119,11 +124,22 @@ spec:
required:
- schedules
type: object
status:
description: ScalingScheduleStatus is the status section of the ScalingSchedule.
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
type: boolean
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
Expand Down
7 changes: 7 additions & 0 deletions docs/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ rules:
- get
- list
- watch
- apiGroups:
- zalando.org
resources:
- clusterscalingschedules/status
- scalingschedules/status
verbs:
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand Down
20 changes: 19 additions & 1 deletion docs/scaling_schedules_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ metadata:
spec:
group: zalando.org
names:
categories:
- all
kind: ScalingSchedule
listKind: ScalingScheduleList
plural: scalingschedules
singular: scalingschedule
scope: Namespaced
versions:
- name: v1
- additionalPrinterColumns:
- description: Whether one or more schedules are currently active.
jsonPath: .status.active
name: Active
type: boolean
name: v1
schema:
openAPIV3Schema:
description: ScalingSchedule describes a namespaced time based metric to be
Expand Down Expand Up @@ -119,11 +126,22 @@ spec:
required:
- schedules
type: object
status:
description: ScalingScheduleStatus is the status section of the ScalingSchedule.
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
type: boolean
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/zalando-incubator/cluster-lifecycle-manager v0.0.0-20230223125308-aff25efae501
golang.org/x/net v0.8.0
golang.org/x/oauth2 v0.6.0
golang.org/x/sync v0.1.0
k8s.io/api v0.23.0
k8s.io/apimachinery v0.23.0
k8s.io/apiserver v0.23.0
Expand Down Expand Up @@ -93,7 +94,6 @@ require (
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
Expand Down
20 changes: 20 additions & 0 deletions pkg/apis/zalando.org/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ import (
// ScalingSchedule describes a namespaced time based metric to be used
// in autoscaling operations.
// +k8s:deepcopy-gen=true
// +kubebuilder:resource:categories=all
// +kubebuilder:printcolumn:name="Active",type=boolean,JSONPath=`.status.active`,description="Whether one or more schedules are currently active."
// +kubebuilder:subresource:status
type ScalingSchedule struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ScalingScheduleSpec `json:"spec"`
// +optional
Status ScalingScheduleStatus `json:"status"`
}

// +genclient
Expand All @@ -28,12 +33,17 @@ type ScalingSchedule struct {
// ClusterScalingSchedule describes a cluster scoped time based metric
// to be used in autoscaling operations.
// +k8s:deepcopy-gen=true
// +kubebuilder:resource:categories=all
// +kubebuilder:printcolumn:name="Active",type=boolean,JSONPath=`.status.active`,description="Whether one or more schedules are currently active."
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
type ClusterScalingSchedule struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ScalingScheduleSpec `json:"spec"`
// +optional
Status ScalingScheduleStatus `json:"status"`
}

// ScalingScheduleSpec is the spec part of the ScalingSchedule.
Expand Down Expand Up @@ -125,6 +135,16 @@ const (
// +kubebuilder:validation:Format="date-time"
type ScheduleDate string

// ScalingScheduleStatus is the status section of the ScalingSchedule.
// +k8s:deepcopy-gen=true
type ScalingScheduleStatus struct {
// Active is true if at least one of the schedules defined in the
// scaling schedule is currently active.
// +kubebuilder:default:=false
// +optional
Active bool `json:"active"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ScalingScheduleList is a list of namespaced scaling schedules.
Expand Down
18 changes: 18 additions & 0 deletions pkg/apis/zalando.org/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 88b7d74

Please sign in to comment.