Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cpu autoscaling #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ build: generate fmt vet ## Build manager binary.
run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/main.go

.PHONY: debug
debug: manifests build
dlv --listen=:2345 --headless=true --api-version=2 exec ./bin/manager -- --config=./config/manager/controller_manager_config.yaml

.PHONY: docker-build
docker-build: ## Build docker image with the manager.
docker buildx build --build-arg VERSION=${VERSION} -t ${IMG} . --load
Expand Down
13 changes: 13 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: cassandra.datastax.com
layout:
- go.kubebuilder.io/v4-alpha
Expand Down Expand Up @@ -29,4 +33,13 @@ resources:
kind: CassandraTask
path: github.com/k8ssandra/cass-operator/apis/control/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: cassandra.datastax.com
group: cassandra.datastax.com
kind: CassandraDataCenterAutoscaler
path: github.com/k8ssandra/cass-operator/api/cassandra.datastax.com/v1beta1
version: v1beta1
version: "3"
64 changes: 64 additions & 0 deletions apis/autoscaling/v1beta1/cassandradatacenterautoscaler_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright 2023.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// CassandraDataCenterAutoscalerSpec defines the desired state of CassandraDataCenterAutoscaler
type CassandraDataCenterAutoscalerSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
CassandraDatacenterRef string `json:"cassandraDatacenterRef,omitempty"`
// Foo is an example field of CassandraDataCenterAutoscaler. Edit cassandradatacenterautoscaler_types.go to remove/update
Foo string `json:"foo,omitempty"`
}

// CassandraDataCenterAutoscalerStatus defines the observed state of CassandraDataCenterAutoscaler
type CassandraDataCenterAutoscalerStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// CassandraDataCenterAutoscaler is the Schema for the cassandradatacenterautoscalers API
type CassandraDataCenterAutoscaler struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CassandraDataCenterAutoscalerSpec `json:"spec,omitempty"`
Status CassandraDataCenterAutoscalerStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// CassandraDataCenterAutoscalerList contains a list of CassandraDataCenterAutoscaler
type CassandraDataCenterAutoscalerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CassandraDataCenterAutoscaler `json:"items"`
}

func init() {
SchemeBuilder.Register(&CassandraDataCenterAutoscaler{}, &CassandraDataCenterAutoscalerList{})
}
36 changes: 36 additions & 0 deletions apis/autoscaling/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2023.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1beta1 contains API Schema definitions for the cassandra.datastax.com v1beta1 API group
// +kubebuilder:object:generate=true
// +groupName=cassandra.datastax.com.cassandra.datastax.com
package v1beta1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "cassandra.datastax.com.cassandra.datastax.com", Version: "v1beta1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
115 changes: 115 additions & 0 deletions apis/autoscaling/v1beta1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion apis/cassandra/v1beta1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion apis/config/v1beta1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion apis/control/v1alpha1/zz_generated.deepcopy.go

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

22 changes: 17 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package main

import (
"flag"
cassandradatastaxcomv1beta1 "github.com/k8ssandra/cass-operator/apis/autoscaling/v1beta1"
cassandradatastaxcomcontroller "github.com/k8ssandra/cass-operator/internal/controllers/autoscaling"
"os"
"strings"

Expand Down Expand Up @@ -55,6 +57,7 @@ func init() {
utilruntime.Must(api.AddToScheme(scheme))
utilruntime.Must(configv1beta1.AddToScheme(scheme))
utilruntime.Must(controlv1alpha1.AddToScheme(scheme))
utilruntime.Must(cassandradatastaxcomv1beta1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down Expand Up @@ -124,19 +127,28 @@ func main() {
os.Exit(1)
}

if !operConfig.DisableWebhooks {
if err = (&api.CassandraDatacenter{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "CassandraDatacenter")
os.Exit(1)
/*
if !operConfig.DisableWebhooks {
if err = (&api.CassandraDatacenter{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "CassandraDatacenter")
os.Exit(1)
}
}
}
*/
if err = (&controlcontrollers.CassandraTaskReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "CassandraTask")
os.Exit(1)
}
if err = (&cassandradatastaxcomcontroller.CassandraDataCenterAutoscalerReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "CassandraDataCenterAutoscaler")
os.Exit(1)
}
//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.0
name: cassandradatacenterautoscalers.cassandra.datastax.com.cassandra.datastax.com
spec:
group: cassandra.datastax.com.cassandra.datastax.com
names:
kind: CassandraDataCenterAutoscaler
listKind: CassandraDataCenterAutoscalerList
plural: cassandradatacenterautoscalers
singular: cassandradatacenterautoscaler
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
description: CassandraDataCenterAutoscaler is the Schema for the cassandradatacenterautoscalers
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: CassandraDataCenterAutoscalerSpec defines the desired state
of CassandraDataCenterAutoscaler
properties:
cassandraDatacenterRef:
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Important: Run "make" to regenerate code after modifying this file'
type: string
foo:
description: Foo is an example field of CassandraDataCenterAutoscaler.
Edit cassandradatacenterautoscaler_types.go to remove/update
type: string
type: object
status:
description: CassandraDataCenterAutoscalerStatus defines the observed
state of CassandraDataCenterAutoscaler
type: object
type: object
served: true
storage: true
subresources:
status: {}
Loading