1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Feature] [Scheduler] Deployment Scale (#1764)

This commit is contained in:
Adam Janikowski 2024-11-12 17:55:27 +01:00 committed by GitHub
parent 5a05c1db5b
commit f89e64d707
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 92 additions and 0 deletions

View file

@ -131,6 +131,8 @@ linters-settings:
pkg: k8s.io/api/storage/v1
- alias: meta
pkg: k8s.io/apimachinery/pkg/apis/meta/v1
- alias: autoscaling
pkg: k8s.io/api/autoscaling/v1
- alias: typedCore
pkg: k8s.io/client-go/kubernetes/typed/core/v1
- alias: ugrpc

View file

@ -21,6 +21,7 @@
- (Feature) (Platform) Storage
- (Maintenance) Extract GRPC Client Package
- (Feature) (Platform) Chart
- (Feature) (Scheduler) Deployment Scale Functionality
## [1.2.43](https://github.com/arangodb/kube-arangodb/tree/1.2.43) (2024-10-14)
- (Feature) ArangoRoute CRD

View file

@ -20,3 +20,6 @@ spec:
storage: true
subresources:
status: {}
scale:
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas

View file

@ -20,3 +20,6 @@ spec:
storage: true
subresources:
status: {}
scale:
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas

View file

@ -20,3 +20,6 @@ spec:
storage: true
subresources:
status: {}
scale:
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas

View file

@ -20,3 +20,6 @@ spec:
storage: true
subresources:
status: {}
scale:
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas

View file

@ -38,6 +38,8 @@ type ArangoSchedulerDeploymentList struct {
}
// +genclient
// +genclient:method=GetScale,verb=get,subresource=scale,result=k8s.io/api/autoscaling/v1.Scale
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ArangoSchedulerDeployment wraps apps. ArangoSchedulerDeployment with profile details

View file

@ -20,3 +20,6 @@ spec:
storage: true
subresources:
status: {}
scale:
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas

View file

@ -27,6 +27,7 @@ import (
v1beta1 "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1"
scheme "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme"
autoscalingv1 "k8s.io/api/autoscaling/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
@ -51,6 +52,9 @@ type ArangoSchedulerDeploymentInterface interface {
List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ArangoSchedulerDeploymentList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ArangoSchedulerDeployment, err error)
GetScale(ctx context.Context, arangoSchedulerDeploymentName string, options v1.GetOptions) (*autoscalingv1.Scale, error)
UpdateScale(ctx context.Context, arangoSchedulerDeploymentName string, scale *autoscalingv1.Scale, opts v1.UpdateOptions) (*autoscalingv1.Scale, error)
ArangoSchedulerDeploymentExpansion
}
@ -71,3 +75,32 @@ func newArangoSchedulerDeployments(c *SchedulerV1beta1Client, namespace string)
func() *v1beta1.ArangoSchedulerDeploymentList { return &v1beta1.ArangoSchedulerDeploymentList{} }),
}
}
// GetScale takes name of the arangoSchedulerDeployment, and returns the corresponding autoscalingv1.Scale object, and an error if there is any.
func (c *arangoSchedulerDeployments) GetScale(ctx context.Context, arangoSchedulerDeploymentName string, options v1.GetOptions) (result *autoscalingv1.Scale, err error) {
result = &autoscalingv1.Scale{}
err = c.GetClient().Get().
Namespace(c.GetNamespace()).
Resource("arangoschedulerdeployments").
Name(arangoSchedulerDeploymentName).
SubResource("scale").
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// UpdateScale takes the top resource name and the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
func (c *arangoSchedulerDeployments) UpdateScale(ctx context.Context, arangoSchedulerDeploymentName string, scale *autoscalingv1.Scale, opts v1.UpdateOptions) (result *autoscalingv1.Scale, err error) {
result = &autoscalingv1.Scale{}
err = c.GetClient().Put().
Namespace(c.GetNamespace()).
Resource("arangoschedulerdeployments").
Name(arangoSchedulerDeploymentName).
SubResource("scale").
VersionedParams(&opts, scheme.ParameterCodec).
Body(scale).
Do(ctx).
Into(result)
return
}

View file

@ -26,6 +26,7 @@ import (
"context"
v1beta1 "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1"
autoscalingv1 "k8s.io/api/autoscaling/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
types "k8s.io/apimachinery/pkg/types"
@ -149,3 +150,27 @@ func (c *FakeArangoSchedulerDeployments) Patch(ctx context.Context, name string,
}
return obj.(*v1beta1.ArangoSchedulerDeployment), err
}
// GetScale takes name of the arangoSchedulerDeployment, and returns the corresponding scale object, and an error if there is any.
func (c *FakeArangoSchedulerDeployments) GetScale(ctx context.Context, arangoSchedulerDeploymentName string, options v1.GetOptions) (result *autoscalingv1.Scale, err error) {
emptyResult := &autoscalingv1.Scale{}
obj, err := c.Fake.
Invokes(testing.NewGetSubresourceActionWithOptions(arangoschedulerdeploymentsResource, c.ns, "scale", arangoSchedulerDeploymentName, options), emptyResult)
if obj == nil {
return emptyResult, err
}
return obj.(*autoscalingv1.Scale), err
}
// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
func (c *FakeArangoSchedulerDeployments) UpdateScale(ctx context.Context, arangoSchedulerDeploymentName string, scale *autoscalingv1.Scale, opts v1.UpdateOptions) (result *autoscalingv1.Scale, err error) {
emptyResult := &autoscalingv1.Scale{}
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceActionWithOptions(arangoschedulerdeploymentsResource, "scale", c.ns, scale, opts), &autoscalingv1.Scale{})
if obj == nil {
return emptyResult, err
}
return obj.(*autoscalingv1.Scale), err
}

View file

@ -23,6 +23,7 @@ package generic
import (
"context"
autoscaling "k8s.io/api/autoscaling/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)
@ -61,6 +62,19 @@ type DeleteInterface[S meta.Object] interface {
Delete(ctx context.Context, name string, opts meta.DeleteOptions) error
}
type ScaleGet interface {
GetScale(ctx context.Context, name string, options meta.GetOptions) (*autoscaling.Scale, error)
}
type ScaleUpdate interface {
UpdateScale(ctx context.Context, name string, scale *autoscaling.Scale, opts meta.UpdateOptions) (*autoscaling.Scale, error)
}
type Scale interface {
ScaleGet
ScaleUpdate
}
type ReadClient[S meta.Object] interface {
GetInterface[S]
}