From c57d4c2bc5d6d4dc5a945b0dc1c083f9f0cc7559 Mon Sep 17 00:00:00 2001 From: Arnob Kumar Saha Date: Thu, 1 Aug 2024 20:05:58 +0600 Subject: [PATCH 1/7] Keep the druid dependency references if given (#1272) Signed-off-by: Arnob kumar saha Signed-off-by: Tapajit Chandra Paul Co-authored-by: Tapajit Chandra Paul --- apis/kubedb/v1alpha2/druid_helpers.go | 81 +++++++++++++++------------ apis/kubedb/v1alpha2/druid_webhook.go | 28 ++++++--- 2 files changed, 65 insertions(+), 44 deletions(-) diff --git a/apis/kubedb/v1alpha2/druid_helpers.go b/apis/kubedb/v1alpha2/druid_helpers.go index 46eae241dc..45fd8c6650 100644 --- a/apis/kubedb/v1alpha2/druid_helpers.go +++ b/apis/kubedb/v1alpha2/druid_helpers.go @@ -511,18 +511,25 @@ func (d *Druid) SetDefaults() { } } - if d.Spec.MetadataStorage == nil { - d.Spec.MetadataStorage = &MetadataStorage{} - } - if !d.Spec.MetadataStorage.ExternallyManaged { - if d.Spec.MetadataStorage.ObjectReference == nil { - d.Spec.MetadataStorage.ObjectReference = &kmapi.ObjectReference{} + d.SetDefaultsToMetadataStorage() + d.SetDefaultsToZooKeeperRef() + + if d.Spec.Monitor != nil { + if d.Spec.Monitor.Prometheus == nil { + d.Spec.Monitor.Prometheus = &mona.PrometheusSpec{} } - d.Spec.MetadataStorage.Name = d.GetMetadataStorageName() + if d.Spec.Monitor.Prometheus != nil && d.Spec.Monitor.Prometheus.Exporter.Port == 0 { + d.Spec.Monitor.Prometheus.Exporter.Port = kubedb.DruidExporterPort + } + d.Spec.Monitor.SetDefaults() } - if d.Spec.MetadataStorage.Namespace == "" { - d.Spec.MetadataStorage.Namespace = d.Namespace +} + +func (d *Druid) SetDefaultsToMetadataStorage() { + if d.Spec.MetadataStorage == nil { + d.Spec.MetadataStorage = &MetadataStorage{} } + d.SetMetadataStorageObjectRef() if d.Spec.MetadataStorage.LinkedDB == "" { d.Spec.MetadataStorage.LinkedDB = "druid" } @@ -541,12 +548,6 @@ func (d *Druid) SetDefaults() { d.Spec.MetadataStorage.Type = DruidMetadataStorageMySQL } } - if !d.Spec.MetadataStorage.ExternallyManaged { - if d.Spec.MetadataStorage.ObjectReference == nil { - d.Spec.MetadataStorage.ObjectReference = &kmapi.ObjectReference{} - } - d.Spec.MetadataStorage.Name = d.GetMetadataStorageName() - } if d.Spec.MetadataStorage.Version == nil { var defaultVersion string @@ -557,33 +558,17 @@ func (d *Druid) SetDefaults() { } d.Spec.MetadataStorage.Version = &defaultVersion } +} +func (d *Druid) SetDefaultsToZooKeeperRef() { if d.Spec.ZookeeperRef == nil { d.Spec.ZookeeperRef = &ZookeeperRef{} } - if !d.Spec.ZookeeperRef.ExternallyManaged { - if d.Spec.ZookeeperRef.ObjectReference == nil { - d.Spec.ZookeeperRef.ObjectReference = &kmapi.ObjectReference{} - } - if d.Spec.ZookeeperRef.Name == "" { - d.Spec.ZookeeperRef.Name = d.GetZooKeeperName() - } - if d.Spec.ZookeeperRef.Namespace == "" { - d.Spec.ZookeeperRef.Namespace = d.Namespace - } + d.SetZooKeeperObjectRef() + if d.Spec.ZookeeperRef.Version == nil { defaultVersion := "3.7.2" d.Spec.ZookeeperRef.Version = &defaultVersion } - - if d.Spec.Monitor != nil { - if d.Spec.Monitor.Prometheus == nil { - d.Spec.Monitor.Prometheus = &mona.PrometheusSpec{} - } - if d.Spec.Monitor.Prometheus != nil && d.Spec.Monitor.Prometheus.Exporter.Port == 0 { - d.Spec.Monitor.Prometheus.Exporter.Port = kubedb.DruidExporterPort - } - d.Spec.Monitor.SetDefaults() - } } func (d *Druid) GetDefaultPVC() *core.PersistentVolumeClaimSpec { @@ -700,6 +685,19 @@ func (d *Druid) GetAppBinding(name string, namespace string) (*appcat.AppBinding return appbinding, nil } +func (d *Druid) SetMetadataStorageObjectRef() { + if d.Spec.MetadataStorage.ObjectReference == nil { + d.Spec.MetadataStorage.ObjectReference = &kmapi.ObjectReference{} + } + if d.Spec.MetadataStorage.Name == "" { + d.Spec.MetadataStorage.ExternallyManaged = false + d.Spec.MetadataStorage.Name = d.GetMetadataStorageName() + } + if d.Spec.MetadataStorage.Namespace == "" { + d.Spec.MetadataStorage.Namespace = d.Namespace + } +} + func (d *Druid) GetMetadataStorageName() string { if d.Spec.MetadataStorage.Type == DruidMetadataStoragePostgreSQL { return d.OffShootName() + "-pg-metadata" @@ -707,6 +705,19 @@ func (d *Druid) GetMetadataStorageName() string { return d.OffShootName() + "-mysql-metadata" } +func (d *Druid) SetZooKeeperObjectRef() { + if d.Spec.ZookeeperRef.ObjectReference == nil { + d.Spec.ZookeeperRef.ObjectReference = &kmapi.ObjectReference{} + } + if d.Spec.ZookeeperRef.Name == "" { + d.Spec.ZookeeperRef.ExternallyManaged = false + d.Spec.ZookeeperRef.Name = d.GetZooKeeperName() + } + if d.Spec.ZookeeperRef.Namespace == "" { + d.Spec.ZookeeperRef.Namespace = d.Namespace + } +} + func (d *Druid) GetZooKeeperName() string { return d.OffShootName() + "-zk" } diff --git a/apis/kubedb/v1alpha2/druid_webhook.go b/apis/kubedb/v1alpha2/druid_webhook.go index cf62fbf719..dfc6628984 100644 --- a/apis/kubedb/v1alpha2/druid_webhook.go +++ b/apis/kubedb/v1alpha2/druid_webhook.go @@ -126,16 +126,26 @@ func (d *Druid) validateCreateOrUpdate() field.ErrorList { } } - if d.Spec.MetadataStorage == nil { - allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("metadataStorage"), + if d.Spec.MetadataStorage.Name == "" { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("metadataStorage").Child("name"), d.Name, - "spec.metadataStorage is missing")) - } else { - if d.Spec.MetadataStorage.ExternallyManaged && d.Spec.MetadataStorage.Name == "" { - allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("metadataStorage").Child("name"), - d.Name, - "spec.metadataStorage.name can not be empty when d.Spec.MetadataStorage.ExternallyManaged is true")) - } + "spec.metadataStorage.name can not be empty")) + } + if d.Spec.MetadataStorage.Namespace == "" { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("metadataStorage").Child("namespace"), + d.Name, + "spec.metadataStorage.namespace can not be empty")) + } + + if d.Spec.ZookeeperRef.Name == "" { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("zookeeperRef").Child("name"), + d.Name, + "spec.zookeeperRef.name can not be empty")) + } + if d.Spec.ZookeeperRef.Namespace == "" { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("zookeeperRef").Child("namespace"), + d.Name, + "spec.zookeeperRef.namespace can not be empty")) } if d.Spec.Topology == nil { From 08af58b8794c2e978e47bf8c77c0301eac91c046 Mon Sep 17 00:00:00 2001 From: Hiranmoy Das Chowdhury <49994927+HiranmoyChowdhury@users.noreply.github.com> Date: Thu, 1 Aug 2024 20:07:46 +0600 Subject: [PATCH 2/7] pgbouncerAutoScalerSpec Update and Scheme Register (#1268) Signed-off-by: Hiranmoy Das Chowdhury --- apis/autoscaling/v1alpha1/mongodb_webhook.go | 2 +- .../autoscaling/v1alpha1/openapi_generated.go | 23 +++-------- apis/autoscaling/v1alpha1/pgbouncer_types.go | 8 +--- .../autoscaling/v1alpha1/pgbouncer_webhook.go | 24 +++++++---- apis/autoscaling/v1alpha1/pgpool_types.go | 2 +- apis/autoscaling/v1alpha1/pgpool_webhook.go | 2 +- apis/autoscaling/v1alpha1/postgres_types.go | 2 +- apis/autoscaling/v1alpha1/postgres_webhook.go | 2 +- apis/autoscaling/v1alpha1/proxysql_webhook.go | 2 +- apis/autoscaling/v1alpha1/rabbitmq_webhook.go | 2 +- .../v1alpha1/redis_sentinel_webhook.go | 2 +- apis/autoscaling/v1alpha1/redis_webhook.go | 2 +- apis/autoscaling/v1alpha1/register.go | 12 ++++++ .../v1alpha1/singlestore_webhook.go | 2 +- apis/autoscaling/v1alpha1/solr_webhook.go | 2 +- .../autoscaling/v1alpha1/zookeeper_webhook.go | 2 +- .../v1alpha1/zz_generated.deepcopy.go | 10 ----- ...aling.kubedb.com_pgbouncerautoscalers.yaml | 41 ------------------- 18 files changed, 48 insertions(+), 94 deletions(-) diff --git a/apis/autoscaling/v1alpha1/mongodb_webhook.go b/apis/autoscaling/v1alpha1/mongodb_webhook.go index 2001e52244..2bf98ec336 100644 --- a/apis/autoscaling/v1alpha1/mongodb_webhook.go +++ b/apis/autoscaling/v1alpha1/mongodb_webhook.go @@ -115,7 +115,7 @@ func (in *MongoDBAutoscaler) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (in *MongoDBAutoscaler) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - mongoLog.Info("validate create", "name", in.Name) + mongoLog.Info("validate update", "name", in.Name) return nil, in.validate() } diff --git a/apis/autoscaling/v1alpha1/openapi_generated.go b/apis/autoscaling/v1alpha1/openapi_generated.go index 24c1f20f20..8be246bb63 100644 --- a/apis/autoscaling/v1alpha1/openapi_generated.go +++ b/apis/autoscaling/v1alpha1/openapi_generated.go @@ -28568,7 +28568,7 @@ func schema_apimachinery_apis_autoscaling_v1alpha1_PgBouncerAutoscalerSpec(ref c }, "opsRequestOptions": { SchemaProps: spec.SchemaProps{ - Description: "This field will be used to control the behaviour of ops-manager", + Description: "OpsRequestOptions will be used to control the behaviour of ops-manager", Ref: ref("kubedb.dev/apimachinery/apis/autoscaling/v1alpha1.PgBouncerOpsRequestOptions"), }, }, @@ -28577,17 +28577,12 @@ func schema_apimachinery_apis_autoscaling_v1alpha1_PgBouncerAutoscalerSpec(ref c Ref: ref("kubedb.dev/apimachinery/apis/autoscaling/v1alpha1.PgBouncerComputeAutoscalerSpec"), }, }, - "storage": { - SchemaProps: spec.SchemaProps{ - Ref: ref("kubedb.dev/apimachinery/apis/autoscaling/v1alpha1.PgBouncerStorageAutoscalerSpec"), - }, - }, }, Required: []string{"databaseRef"}, }, }, Dependencies: []string{ - "k8s.io/api/core/v1.LocalObjectReference", "kubedb.dev/apimachinery/apis/autoscaling/v1alpha1.PgBouncerComputeAutoscalerSpec", "kubedb.dev/apimachinery/apis/autoscaling/v1alpha1.PgBouncerOpsRequestOptions", "kubedb.dev/apimachinery/apis/autoscaling/v1alpha1.PgBouncerStorageAutoscalerSpec"}, + "k8s.io/api/core/v1.LocalObjectReference", "kubedb.dev/apimachinery/apis/autoscaling/v1alpha1.PgBouncerComputeAutoscalerSpec", "kubedb.dev/apimachinery/apis/autoscaling/v1alpha1.PgBouncerOpsRequestOptions"}, } } @@ -28621,12 +28616,6 @@ func schema_apimachinery_apis_autoscaling_v1alpha1_PgBouncerOpsRequestOptions(re SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "readinessCriteria": { - SchemaProps: spec.SchemaProps{ - Description: "Specifies the Readiness Criteria", - Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.PgBouncerReplicaReadinessCriteria"), - }, - }, "timeout": { SchemaProps: spec.SchemaProps{ Description: "Timeout for each step of the ops request in second. If a step doesn't finish within the specified timeout, the ops request will result in failure.", @@ -28635,7 +28624,7 @@ func schema_apimachinery_apis_autoscaling_v1alpha1_PgBouncerOpsRequestOptions(re }, "apply": { SchemaProps: spec.SchemaProps{ - Description: "ApplyOption is to control the execution of OpsRequest depending on the database state.", + Description: "Apply is to control the execution of OpsRequest depending on the database state.", Type: []string{"string"}, Format: "", }, @@ -28644,7 +28633,7 @@ func schema_apimachinery_apis_autoscaling_v1alpha1_PgBouncerOpsRequestOptions(re }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/apis/meta/v1.Duration", "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgBouncerReplicaReadinessCriteria"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.Duration"}, } } @@ -28782,7 +28771,7 @@ func schema_apimachinery_apis_autoscaling_v1alpha1_PgpoolAutoscalerSpec(ref comm }, "opsRequestOptions": { SchemaProps: spec.SchemaProps{ - Description: "This field will be used to control the behaviour of ops-manager", + Description: "OpsRequestOptions will be used to control the behaviour of ops-manager", Ref: ref("kubedb.dev/apimachinery/apis/autoscaling/v1alpha1.PgpoolOpsRequestOptions"), }, }, @@ -29027,7 +29016,7 @@ func schema_apimachinery_apis_autoscaling_v1alpha1_PostgresAutoscalerSpec(ref co }, "opsRequestOptions": { SchemaProps: spec.SchemaProps{ - Description: "This field will be used to control the behaviour of ops-manager", + Description: "OpsRequestOptions will be used to control the behaviour of ops-manager", Ref: ref("kubedb.dev/apimachinery/apis/autoscaling/v1alpha1.PostgresOpsRequestOptions"), }, }, diff --git a/apis/autoscaling/v1alpha1/pgbouncer_types.go b/apis/autoscaling/v1alpha1/pgbouncer_types.go index 3e72a39f2c..e8219c61e2 100644 --- a/apis/autoscaling/v1alpha1/pgbouncer_types.go +++ b/apis/autoscaling/v1alpha1/pgbouncer_types.go @@ -60,11 +60,10 @@ type PgBouncerAutoscaler struct { type PgBouncerAutoscalerSpec struct { DatabaseRef *core.LocalObjectReference `json:"databaseRef"` - // This field will be used to control the behaviour of ops-manager + // OpsRequestOptions will be used to control the behaviour of ops-manager OpsRequestOptions *PgBouncerOpsRequestOptions `json:"opsRequestOptions,omitempty"` Compute *PgBouncerComputeAutoscalerSpec `json:"compute,omitempty"` - Storage *PgBouncerStorageAutoscalerSpec `json:"storage,omitempty"` } type PgBouncerComputeAutoscalerSpec struct { @@ -79,13 +78,10 @@ type PgBouncerStorageAutoscalerSpec struct { } type PgBouncerOpsRequestOptions struct { - // Specifies the Readiness Criteria - ReadinessCriteria *opsapi.PgBouncerReplicaReadinessCriteria `json:"readinessCriteria,omitempty"` - // Timeout for each step of the ops request in second. If a step doesn't finish within the specified timeout, the ops request will result in failure. Timeout *metav1.Duration `json:"timeout,omitempty"` - // ApplyOption is to control the execution of OpsRequest depending on the database state. + // Apply is to control the execution of OpsRequest depending on the database state. // +kubebuilder:default="IfReady" Apply opsapi.ApplyOption `json:"apply,omitempty"` } diff --git a/apis/autoscaling/v1alpha1/pgbouncer_webhook.go b/apis/autoscaling/v1alpha1/pgbouncer_webhook.go index f456c0a651..d7fd405c14 100644 --- a/apis/autoscaling/v1alpha1/pgbouncer_webhook.go +++ b/apis/autoscaling/v1alpha1/pgbouncer_webhook.go @@ -26,7 +26,9 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/builder" logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) @@ -34,9 +36,17 @@ import ( // log is for logging in this package. var pbLog = logf.Log.WithName("pgbouncer-autoscaler") +func (in *PgBouncerAutoscaler) SetupWebhookWithManager(mgr manager.Manager) error { + return builder.WebhookManagedBy(mgr). + For(in). + Complete() +} + +// +kubebuilder:webhook:path=/mutate-autoscaling-kubedb-com-v1alpha1-pgbouncerautoscaler,mutating=true,failurePolicy=fail,sideEffects=None,groups=autoscaling.kubedb.com,resources=pgbouncerautoscaler,verbs=create;update,versions=v1alpha1,name=mpgbouncerautoscaler.kb.io,admissionReviewVersions={v1,v1beta1} + var _ webhook.Defaulter = &PgBouncerAutoscaler{} -// Default implements webhook.CustomDefaulter so a webhook will be registered for the type +// Default implements webhook.Defaulter so a webhook will be registered for the type func (r *PgBouncerAutoscaler) Default() { pbLog.Info("defaulting", "name", r.Name) r.setDefaults() @@ -55,10 +65,6 @@ func (r *PgBouncerAutoscaler) setDefaults() { r.setOpsReqOptsDefaults() - if r.Spec.Storage != nil { - setDefaultStorageValues(r.Spec.Storage.PgBouncer) - } - if r.Spec.Compute != nil { setDefaultComputeValues(r.Spec.Compute.PgBouncer) } @@ -75,6 +81,8 @@ func (r *PgBouncerAutoscaler) setOpsReqOptsDefaults() { } } +// +kubebuilder:webhook:path=/validate-schema-kubedb-com-v1alpha1-pgbouncerautoscaler,mutating=false,failurePolicy=fail,sideEffects=None,groups=schema.kubedb.com,resources=pgbouncerautoscalers,verbs=create;update;delete,versions=v1alpha1,name=vpgbouncerautoscaler.kb.io,admissionReviewVersions={v1,v1beta1} + var _ webhook.Validator = &PgBouncerAutoscaler{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type @@ -85,7 +93,7 @@ func (r *PgBouncerAutoscaler) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *PgBouncerAutoscaler) ValidateUpdate(oldObj runtime.Object) (admission.Warnings, error) { - pbLog.Info("validate create", "name", r.Name) + pbLog.Info("validate update", "name", r.Name) return nil, r.validate() } @@ -97,11 +105,11 @@ func (r *PgBouncerAutoscaler) validate() error { if r.Spec.DatabaseRef == nil { return errors.New("databaseRef can't be empty") } - var kf dbapi.PgBouncer + var bouncer dbapi.PgBouncer err := DefaultClient.Get(context.TODO(), types.NamespacedName{ Name: r.Spec.DatabaseRef.Name, Namespace: r.Namespace, - }, &kf) + }, &bouncer) if err != nil { _ = fmt.Errorf("can't get PgBouncer %s/%s \n", r.Namespace, r.Spec.DatabaseRef.Name) return err diff --git a/apis/autoscaling/v1alpha1/pgpool_types.go b/apis/autoscaling/v1alpha1/pgpool_types.go index eebc6670e8..32d13a6678 100644 --- a/apis/autoscaling/v1alpha1/pgpool_types.go +++ b/apis/autoscaling/v1alpha1/pgpool_types.go @@ -60,7 +60,7 @@ type PgpoolAutoscaler struct { type PgpoolAutoscalerSpec struct { DatabaseRef *core.LocalObjectReference `json:"databaseRef"` - // This field will be used to control the behaviour of ops-manager + // OpsRequestOptions will be used to control the behaviour of ops-manager OpsRequestOptions *PgpoolOpsRequestOptions `json:"opsRequestOptions,omitempty"` Compute *PgpoolComputeAutoscalerSpec `json:"compute,omitempty"` diff --git a/apis/autoscaling/v1alpha1/pgpool_webhook.go b/apis/autoscaling/v1alpha1/pgpool_webhook.go index 33425ca38c..17cadc9f77 100644 --- a/apis/autoscaling/v1alpha1/pgpool_webhook.go +++ b/apis/autoscaling/v1alpha1/pgpool_webhook.go @@ -81,7 +81,7 @@ func (r *PgpoolAutoscaler) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *PgpoolAutoscaler) ValidateUpdate(oldObj runtime.Object) (admission.Warnings, error) { - pgpoolLog.Info("validate create", "name", r.Name) + pgpoolLog.Info("validate update", "name", r.Name) return nil, r.validate() } diff --git a/apis/autoscaling/v1alpha1/postgres_types.go b/apis/autoscaling/v1alpha1/postgres_types.go index 6a84fa1182..c1dd1bbae9 100644 --- a/apis/autoscaling/v1alpha1/postgres_types.go +++ b/apis/autoscaling/v1alpha1/postgres_types.go @@ -62,7 +62,7 @@ type PostgresAutoscaler struct { type PostgresAutoscalerSpec struct { DatabaseRef *core.LocalObjectReference `json:"databaseRef"` - // This field will be used to control the behaviour of ops-manager + // OpsRequestOptions will be used to control the behaviour of ops-manager OpsRequestOptions *PostgresOpsRequestOptions `json:"opsRequestOptions,omitempty"` Compute *PostgresComputeAutoscalerSpec `json:"compute,omitempty"` diff --git a/apis/autoscaling/v1alpha1/postgres_webhook.go b/apis/autoscaling/v1alpha1/postgres_webhook.go index a608b462b0..efda7e516d 100644 --- a/apis/autoscaling/v1alpha1/postgres_webhook.go +++ b/apis/autoscaling/v1alpha1/postgres_webhook.go @@ -83,7 +83,7 @@ func (in *PostgresAutoscaler) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (in *PostgresAutoscaler) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - pgLog.Info("validate create", "name", in.Name) + pgLog.Info("validate update", "name", in.Name) return nil, in.validate() } diff --git a/apis/autoscaling/v1alpha1/proxysql_webhook.go b/apis/autoscaling/v1alpha1/proxysql_webhook.go index cf3d107937..24e8b297ec 100644 --- a/apis/autoscaling/v1alpha1/proxysql_webhook.go +++ b/apis/autoscaling/v1alpha1/proxysql_webhook.go @@ -79,7 +79,7 @@ func (in *ProxySQLAutoscaler) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (in *ProxySQLAutoscaler) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - proxyLog.Info("validate create", "name", in.Name) + proxyLog.Info("validate update", "name", in.Name) return nil, in.validate() } diff --git a/apis/autoscaling/v1alpha1/rabbitmq_webhook.go b/apis/autoscaling/v1alpha1/rabbitmq_webhook.go index b352ce75dd..9f1a41cfa3 100644 --- a/apis/autoscaling/v1alpha1/rabbitmq_webhook.go +++ b/apis/autoscaling/v1alpha1/rabbitmq_webhook.go @@ -85,7 +85,7 @@ func (r *RabbitMQAutoscaler) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *RabbitMQAutoscaler) ValidateUpdate(oldObj runtime.Object) (admission.Warnings, error) { - rabbitLog.Info("validate create", "name", r.Name) + rabbitLog.Info("validate update", "name", r.Name) return nil, r.validate() } diff --git a/apis/autoscaling/v1alpha1/redis_sentinel_webhook.go b/apis/autoscaling/v1alpha1/redis_sentinel_webhook.go index c44df8986f..90d89d4e47 100644 --- a/apis/autoscaling/v1alpha1/redis_sentinel_webhook.go +++ b/apis/autoscaling/v1alpha1/redis_sentinel_webhook.go @@ -79,7 +79,7 @@ func (in *RedisSentinelAutoscaler) ValidateCreate() (admission.Warnings, error) // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (in *RedisSentinelAutoscaler) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - rsLog.Info("validate create", "name", in.Name) + rsLog.Info("validate update", "name", in.Name) return nil, in.validate() } diff --git a/apis/autoscaling/v1alpha1/redis_webhook.go b/apis/autoscaling/v1alpha1/redis_webhook.go index 4f4315194a..e43fbf6b62 100644 --- a/apis/autoscaling/v1alpha1/redis_webhook.go +++ b/apis/autoscaling/v1alpha1/redis_webhook.go @@ -91,7 +91,7 @@ func (in *RedisAutoscaler) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (in *RedisAutoscaler) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - redisLog.Info("validate create", "name", in.Name) + redisLog.Info("validate update", "name", in.Name) return nil, in.validate() } diff --git a/apis/autoscaling/v1alpha1/register.go b/apis/autoscaling/v1alpha1/register.go index 599546a126..bd4816f6bb 100644 --- a/apis/autoscaling/v1alpha1/register.go +++ b/apis/autoscaling/v1alpha1/register.go @@ -54,12 +54,16 @@ func Resource(resource string) schema.GroupResource { // Adds the list of known types to api.Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, + &ClickHouseAutoscaler{}, + &ClickHouseAutoscalerList{}, &DruidAutoscaler{}, &DruidAutoscalerList{}, &ElasticsearchAutoscaler{}, &ElasticsearchAutoscalerList{}, &EtcdAutoscaler{}, &EtcdAutoscalerList{}, + &FerretDBAutoscaler{}, + &FerretDBAutoscalerList{}, &KafkaAutoscaler{}, &KafkaAutoscalerList{}, &MariaDBAutoscaler{}, @@ -68,10 +72,14 @@ func addKnownTypes(scheme *runtime.Scheme) error { &MemcachedAutoscalerList{}, &MongoDBAutoscaler{}, &MongoDBAutoscalerList{}, + &MSSQLServerAutoscaler{}, + &MSSQLServerAutoscalerList{}, &MySQLAutoscaler{}, &MySQLAutoscalerList{}, &PerconaXtraDBAutoscaler{}, &PerconaXtraDBAutoscalerList{}, + &PgBouncerAutoscaler{}, + &PgBouncerAutoscalerList{}, &PgpoolAutoscaler{}, &PgpoolAutoscalerList{}, &PostgresAutoscaler{}, @@ -86,6 +94,10 @@ func addKnownTypes(scheme *runtime.Scheme) error { &RedisSentinelAutoscalerList{}, &SinglestoreAutoscaler{}, &SinglestoreAutoscalerList{}, + &SolrAutoscaler{}, + &SolrAutoscalerList{}, + &ZooKeeperAutoscaler{}, + &ZooKeeperAutoscalerList{}, ) scheme.AddKnownTypes(SchemeGroupVersion, diff --git a/apis/autoscaling/v1alpha1/singlestore_webhook.go b/apis/autoscaling/v1alpha1/singlestore_webhook.go index c8c4c3f48d..00e22b87ff 100644 --- a/apis/autoscaling/v1alpha1/singlestore_webhook.go +++ b/apis/autoscaling/v1alpha1/singlestore_webhook.go @@ -95,7 +95,7 @@ func (s *SinglestoreAutoscaler) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (s *SinglestoreAutoscaler) ValidateUpdate(oldObj runtime.Object) (admission.Warnings, error) { - kafkaLog.Info("validate create", "name", s.Name) + kafkaLog.Info("validate update", "name", s.Name) return nil, s.validate() } diff --git a/apis/autoscaling/v1alpha1/solr_webhook.go b/apis/autoscaling/v1alpha1/solr_webhook.go index acbf65fc31..5a7b46ddb2 100644 --- a/apis/autoscaling/v1alpha1/solr_webhook.go +++ b/apis/autoscaling/v1alpha1/solr_webhook.go @@ -85,7 +85,7 @@ func (r *SolrAutoscaler) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *SolrAutoscaler) ValidateUpdate(oldObj runtime.Object) (admission.Warnings, error) { - sllog.Info("validate create", "name", r.Name) + sllog.Info("validate update", "name", r.Name) return nil, r.validate() } diff --git a/apis/autoscaling/v1alpha1/zookeeper_webhook.go b/apis/autoscaling/v1alpha1/zookeeper_webhook.go index cf72c94399..e947348344 100644 --- a/apis/autoscaling/v1alpha1/zookeeper_webhook.go +++ b/apis/autoscaling/v1alpha1/zookeeper_webhook.go @@ -85,7 +85,7 @@ func (r *ZooKeeperAutoscaler) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *ZooKeeperAutoscaler) ValidateUpdate(oldObj runtime.Object) (admission.Warnings, error) { - zkLog.Info("validate create", "name", r.Name) + zkLog.Info("validate update", "name", r.Name) return nil, r.validate() } diff --git a/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go b/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go index a4b49d06f4..8748406c4c 100644 --- a/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go +++ b/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go @@ -2555,11 +2555,6 @@ func (in *PgBouncerAutoscalerSpec) DeepCopyInto(out *PgBouncerAutoscalerSpec) { *out = new(PgBouncerComputeAutoscalerSpec) (*in).DeepCopyInto(*out) } - if in.Storage != nil { - in, out := &in.Storage, &out.Storage - *out = new(PgBouncerStorageAutoscalerSpec) - (*in).DeepCopyInto(*out) - } return } @@ -2602,11 +2597,6 @@ func (in *PgBouncerComputeAutoscalerSpec) DeepCopy() *PgBouncerComputeAutoscaler // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PgBouncerOpsRequestOptions) DeepCopyInto(out *PgBouncerOpsRequestOptions) { *out = *in - if in.ReadinessCriteria != nil { - in, out := &in.ReadinessCriteria, &out.ReadinessCriteria - *out = new(opsv1alpha1.PgBouncerReplicaReadinessCriteria) - **out = **in - } if in.Timeout != nil { in, out := &in.Timeout, &out.Timeout *out = new(metav1.Duration) diff --git a/crds/autoscaling.kubedb.com_pgbouncerautoscalers.yaml b/crds/autoscaling.kubedb.com_pgbouncerautoscalers.yaml index b920b2f024..b717ba8d5d 100644 --- a/crds/autoscaling.kubedb.com_pgbouncerautoscalers.yaml +++ b/crds/autoscaling.kubedb.com_pgbouncerautoscalers.yaml @@ -107,50 +107,9 @@ spec: - IfReady - Always type: string - readinessCriteria: - type: object timeout: type: string type: object - storage: - properties: - pgbouncer: - properties: - expansionMode: - enum: - - Offline - - Online - type: string - scalingRules: - items: - properties: - appliesUpto: - type: string - threshold: - type: string - required: - - appliesUpto - - threshold - type: object - type: array - scalingThreshold: - format: int32 - type: integer - trigger: - type: string - upperBound: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - usageThreshold: - format: int32 - type: integer - required: - - expansionMode - type: object - type: object required: - databaseRef type: object From 67d239489f43c0fbdb9731dec6b2274eb0ba05b5 Mon Sep 17 00:00:00 2001 From: Abu Sayed <82162518+sayedppqq@users.noreply.github.com> Date: Thu, 1 Aug 2024 20:10:25 +0600 Subject: [PATCH 3/7] Add FerretDBOpsManager (#1267) Signed-off-by: sayedppqq --- apis/ops/v1alpha1/ferretdb_ops.types.go | 118 +++++++ apis/ops/v1alpha1/ferretdb_ops.types_enum.go | 90 +++++ apis/ops/v1alpha1/ferretdb_ops_helpers.go | 76 +++++ apis/ops/v1alpha1/openapi_generated.go | 299 +++++++++++++++++ apis/ops/v1alpha1/register.go | 2 + apis/ops/v1alpha1/zz_generated.deepcopy.go | 183 ++++++++++ .../v1alpha1/fake/fake_ferretdbopsrequest.go | 142 ++++++++ .../ops/v1alpha1/fake/fake_ops_client.go | 4 + .../typed/ops/v1alpha1/ferretdbopsrequest.go | 196 +++++++++++ .../typed/ops/v1alpha1/generated_expansion.go | 2 + .../typed/ops/v1alpha1/ops_client.go | 5 + client/informers/externalversions/generic.go | 2 + .../ops/v1alpha1/ferretdbopsrequest.go | 91 +++++ .../ops/v1alpha1/interface.go | 7 + .../ops/v1alpha1/expansion_generated.go | 8 + .../ops/v1alpha1/ferretdbopsrequest.go | 100 ++++++ crds/ops.kubedb.com_ferretdbopsrequests.yaml | 314 ++++++++++++++++++ 17 files changed, 1639 insertions(+) create mode 100644 apis/ops/v1alpha1/ferretdb_ops.types.go create mode 100644 apis/ops/v1alpha1/ferretdb_ops.types_enum.go create mode 100644 apis/ops/v1alpha1/ferretdb_ops_helpers.go create mode 100644 client/clientset/versioned/typed/ops/v1alpha1/fake/fake_ferretdbopsrequest.go create mode 100644 client/clientset/versioned/typed/ops/v1alpha1/ferretdbopsrequest.go create mode 100644 client/informers/externalversions/ops/v1alpha1/ferretdbopsrequest.go create mode 100644 client/listers/ops/v1alpha1/ferretdbopsrequest.go create mode 100644 crds/ops.kubedb.com_ferretdbopsrequests.yaml diff --git a/apis/ops/v1alpha1/ferretdb_ops.types.go b/apis/ops/v1alpha1/ferretdb_ops.types.go new file mode 100644 index 0000000000..d08c402702 --- /dev/null +++ b/apis/ops/v1alpha1/ferretdb_ops.types.go @@ -0,0 +1,118 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +//go:generate go-enum --mustparse --names --values +package v1alpha1 + +import ( + "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" + + core "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + ResourceCodeFerretDBOpsRequest = "frops" + ResourceKindFerretDBOpsRequest = "FerretDBOpsRequest" + ResourceSingularFerretDBOpsRequest = "ferretdbopsrequest" + ResourcePluralFerretDBOpsRequest = "ferretdbopsrequests" +) + +// FerretDBDBOpsRequest defines a FerretDB DBA operation. + +// +genclient +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// +kubebuilder:object:root=true +// +kubebuilder:resource:path=ferretdbopsrequests,singular=ferretdbopsrequest,shortName=frops,categories={datastore,kubedb,appscode} +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type" +// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +type FerretDBOpsRequest struct { + metav1.TypeMeta `json:",inline,omitempty"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec FerretDBOpsRequestSpec `json:"spec,omitempty"` + Status OpsRequestStatus `json:"status,omitempty"` +} + +// FerretDBOpsRequestSpec is the spec for FerretDBOpsRequest +type FerretDBOpsRequestSpec struct { + // Specifies the FerretDB reference + DatabaseRef core.LocalObjectReference `json:"databaseRef"` + // Specifies the ops request type: UpdateVersion, HorizontalScaling, VerticalScaling etc. + Type FerretDBOpsRequestType `json:"type"` + // Specifies information necessary for upgrading ferretdb + UpdateVersion *FerretDBUpdateVersionSpec `json:"updateVersion,omitempty"` + // Specifies information necessary for horizontal scaling + HorizontalScaling *FerretDBHorizontalScalingSpec `json:"horizontalScaling,omitempty"` + // Specifies information necessary for vertical scaling + VerticalScaling *FerretDBVerticalScalingSpec `json:"verticalScaling,omitempty"` + // Specifies information necessary for configuring TLS + TLS *FerretDBTLSSpec `json:"tls,omitempty"` + // Specifies information necessary for restarting database + Restart *RestartSpec `json:"restart,omitempty"` + // Timeout for each step of the ops request in second. If a step doesn't finish within the specified timeout, the ops request will result in failure. + Timeout *metav1.Duration `json:"timeout,omitempty"` + // ApplyOption is to control the execution of OpsRequest depending on the database state. + // +kubebuilder:default="IfReady" + Apply ApplyOption `json:"apply,omitempty"` +} + +type FerretDBTLSSpec struct { + TLSSpec `json:",inline,omitempty"` + + // SSLMode for both standalone and clusters. [disable;allow;prefer;require;verify-ca;verify-full] + // +optional + SSLMode v1alpha2.SSLMode `json:"sslMode,omitempty"` + + // ClientAuthMode for both standalone and clusters. (default will be md5. [md5;scram;cert]) + // +optional + ClientAuthMode v1alpha2.ClusterAuthMode `json:"clientAuthMode,omitempty"` +} + +// +kubebuilder:validation:Enum=UpdateVersion;VerticalScaling;Restart;HorizontalScaling;ReconfigureTLS +// ENUM(UpdateVersion, Restart, VerticalScaling, HorizontalScaling, ReconfigureTLS) +type FerretDBOpsRequestType string + +// FerretDBUpdateVersionSpec contains the update version information of a ferretdb cluster +type FerretDBUpdateVersionSpec struct { + // Specifies the target version name from catalog + TargetVersion string `json:"targetVersion,omitempty"` +} + +// FerretDBHorizontalScalingSpec contains the horizontal scaling information of a FerretDB cluster +type FerretDBHorizontalScalingSpec struct { + // Number of node + Node *int32 `json:"node,omitempty"` +} + +// FerretDBVerticalScalingSpec contains the vertical scaling information of a FerretDB cluster +type FerretDBVerticalScalingSpec struct { + // Resource spec for nodes + Node *PodResources `json:"node,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// FerretDBOpsRequestList is a list of FerretDBOpsRequests +type FerretDBOpsRequestList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + // Items is a list of FerretDBOpsRequest CRD objects + Items []FerretDBOpsRequest `json:"items,omitempty"` +} diff --git a/apis/ops/v1alpha1/ferretdb_ops.types_enum.go b/apis/ops/v1alpha1/ferretdb_ops.types_enum.go new file mode 100644 index 0000000000..284db35ac9 --- /dev/null +++ b/apis/ops/v1alpha1/ferretdb_ops.types_enum.go @@ -0,0 +1,90 @@ +// Code generated by go-enum DO NOT EDIT. +// Version: +// Revision: +// Build Date: +// Built By: + +package v1alpha1 + +import ( + "fmt" + "strings" +) + +const ( + // FerretDBOpsRequestTypeUpdateVersion is a FerretDBOpsRequestType of type UpdateVersion. + FerretDBOpsRequestTypeUpdateVersion FerretDBOpsRequestType = "UpdateVersion" + // FerretDBOpsRequestTypeRestart is a FerretDBOpsRequestType of type Restart. + FerretDBOpsRequestTypeRestart FerretDBOpsRequestType = "Restart" + // FerretDBOpsRequestTypeVerticalScaling is a FerretDBOpsRequestType of type VerticalScaling. + FerretDBOpsRequestTypeVerticalScaling FerretDBOpsRequestType = "VerticalScaling" + // FerretDBOpsRequestTypeHorizontalScaling is a FerretDBOpsRequestType of type HorizontalScaling. + FerretDBOpsRequestTypeHorizontalScaling FerretDBOpsRequestType = "HorizontalScaling" + // FerretDBOpsRequestTypeReconfigureTLS is a FerretDBOpsRequestType of type ReconfigureTLS. + FerretDBOpsRequestTypeReconfigureTLS FerretDBOpsRequestType = "ReconfigureTLS" +) + +var ErrInvalidFerretDBOpsRequestType = fmt.Errorf("not a valid FerretDBOpsRequestType, try [%s]", strings.Join(_FerretDBOpsRequestTypeNames, ", ")) + +var _FerretDBOpsRequestTypeNames = []string{ + string(FerretDBOpsRequestTypeUpdateVersion), + string(FerretDBOpsRequestTypeRestart), + string(FerretDBOpsRequestTypeVerticalScaling), + string(FerretDBOpsRequestTypeHorizontalScaling), + string(FerretDBOpsRequestTypeReconfigureTLS), +} + +// FerretDBOpsRequestTypeNames returns a list of possible string values of FerretDBOpsRequestType. +func FerretDBOpsRequestTypeNames() []string { + tmp := make([]string, len(_FerretDBOpsRequestTypeNames)) + copy(tmp, _FerretDBOpsRequestTypeNames) + return tmp +} + +// FerretDBOpsRequestTypeValues returns a list of the values for FerretDBOpsRequestType +func FerretDBOpsRequestTypeValues() []FerretDBOpsRequestType { + return []FerretDBOpsRequestType{ + FerretDBOpsRequestTypeUpdateVersion, + FerretDBOpsRequestTypeRestart, + FerretDBOpsRequestTypeVerticalScaling, + FerretDBOpsRequestTypeHorizontalScaling, + FerretDBOpsRequestTypeReconfigureTLS, + } +} + +// String implements the Stringer interface. +func (x FerretDBOpsRequestType) String() string { + return string(x) +} + +// IsValid provides a quick way to determine if the typed value is +// part of the allowed enumerated values +func (x FerretDBOpsRequestType) IsValid() bool { + _, err := ParseFerretDBOpsRequestType(string(x)) + return err == nil +} + +var _FerretDBOpsRequestTypeValue = map[string]FerretDBOpsRequestType{ + "UpdateVersion": FerretDBOpsRequestTypeUpdateVersion, + "Restart": FerretDBOpsRequestTypeRestart, + "VerticalScaling": FerretDBOpsRequestTypeVerticalScaling, + "HorizontalScaling": FerretDBOpsRequestTypeHorizontalScaling, + "ReconfigureTLS": FerretDBOpsRequestTypeReconfigureTLS, +} + +// ParseFerretDBOpsRequestType attempts to convert a string to a FerretDBOpsRequestType. +func ParseFerretDBOpsRequestType(name string) (FerretDBOpsRequestType, error) { + if x, ok := _FerretDBOpsRequestTypeValue[name]; ok { + return x, nil + } + return FerretDBOpsRequestType(""), fmt.Errorf("%s is %w", name, ErrInvalidFerretDBOpsRequestType) +} + +// MustParseFerretDBOpsRequestType converts a string to a FerretDBOpsRequestType, and panics if is not valid. +func MustParseFerretDBOpsRequestType(name string) FerretDBOpsRequestType { + val, err := ParseFerretDBOpsRequestType(name) + if err != nil { + panic(err) + } + return val +} diff --git a/apis/ops/v1alpha1/ferretdb_ops_helpers.go b/apis/ops/v1alpha1/ferretdb_ops_helpers.go new file mode 100644 index 0000000000..abdc3c76fc --- /dev/null +++ b/apis/ops/v1alpha1/ferretdb_ops_helpers.go @@ -0,0 +1,76 @@ +/* +Copyright AppsCode Inc. and Contributors + +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 v1alpha1 + +import ( + "fmt" + + "kubedb.dev/apimachinery/apis" + "kubedb.dev/apimachinery/apis/ops" + "kubedb.dev/apimachinery/crds" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "kmodules.xyz/client-go/apiextensions" +) + +func (r *FerretDBOpsRequest) CustomResourceDefinition() *apiextensions.CustomResourceDefinition { + return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralFerretDBOpsRequest)) +} + +var _ apis.ResourceInfo = &FerretDBOpsRequest{} + +func (r *FerretDBOpsRequest) ResourceFQN() string { + return fmt.Sprintf("%s.%s", ResourcePluralFerretDBOpsRequest, ops.GroupName) +} + +func (r *FerretDBOpsRequest) ResourceShortCode() string { + return ResourceCodeFerretDBOpsRequest +} + +func (r *FerretDBOpsRequest) ResourceKind() string { + return ResourceKindFerretDBOpsRequest +} + +func (r *FerretDBOpsRequest) ResourceSingular() string { + return ResourceSingularFerretDBOpsRequest +} + +func (r *FerretDBOpsRequest) ResourcePlural() string { + return ResourcePluralFerretDBOpsRequest +} + +var _ Accessor = &FerretDBOpsRequest{} + +func (r *FerretDBOpsRequest) GetObjectMeta() metav1.ObjectMeta { + return r.ObjectMeta +} + +func (r *FerretDBOpsRequest) GetDBRefName() string { + return r.Spec.DatabaseRef.Name +} + +func (r *FerretDBOpsRequest) GetRequestType() any { + return r.Spec.Type +} + +func (r *FerretDBOpsRequest) GetStatus() OpsRequestStatus { + return r.Status +} + +func (r *FerretDBOpsRequest) SetStatus(s OpsRequestStatus) { + r.Status = s +} diff --git a/apis/ops/v1alpha1/openapi_generated.go b/apis/ops/v1alpha1/openapi_generated.go index 123a700a54..14d09cfbcc 100644 --- a/apis/ops/v1alpha1/openapi_generated.go +++ b/apis/ops/v1alpha1/openapi_generated.go @@ -516,6 +516,13 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/ops/v1alpha1.EtcdUpdateVersionSpec": schema_apimachinery_apis_ops_v1alpha1_EtcdUpdateVersionSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.EtcdVerticalScalingSpec": schema_apimachinery_apis_ops_v1alpha1_EtcdVerticalScalingSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.EtcdVolumeExpansionSpec": schema_apimachinery_apis_ops_v1alpha1_EtcdVolumeExpansionSpec(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBHorizontalScalingSpec": schema_apimachinery_apis_ops_v1alpha1_FerretDBHorizontalScalingSpec(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBOpsRequest": schema_apimachinery_apis_ops_v1alpha1_FerretDBOpsRequest(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBOpsRequestList": schema_apimachinery_apis_ops_v1alpha1_FerretDBOpsRequestList(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBOpsRequestSpec": schema_apimachinery_apis_ops_v1alpha1_FerretDBOpsRequestSpec(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBTLSSpec": schema_apimachinery_apis_ops_v1alpha1_FerretDBTLSSpec(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBUpdateVersionSpec": schema_apimachinery_apis_ops_v1alpha1_FerretDBUpdateVersionSpec(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBVerticalScalingSpec": schema_apimachinery_apis_ops_v1alpha1_FerretDBVerticalScalingSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.HiddenNode": schema_apimachinery_apis_ops_v1alpha1_HiddenNode(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.KafkaCustomConfigurationSpec": schema_apimachinery_apis_ops_v1alpha1_KafkaCustomConfigurationSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.KafkaHorizontalScalingSpec": schema_apimachinery_apis_ops_v1alpha1_KafkaHorizontalScalingSpec(ref), @@ -26459,6 +26466,298 @@ func schema_apimachinery_apis_ops_v1alpha1_EtcdVolumeExpansionSpec(ref common.Re } } +func schema_apimachinery_apis_ops_v1alpha1_FerretDBHorizontalScalingSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FerretDBHorizontalScalingSpec contains the horizontal scaling information of a FerretDB cluster", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "node": { + SchemaProps: spec.SchemaProps{ + Description: "Number of node", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + } +} + +func schema_apimachinery_apis_ops_v1alpha1_FerretDBOpsRequest(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + 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{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + 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{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBOpsRequestSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.OpsRequestStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBOpsRequestSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.OpsRequestStatus"}, + } +} + +func schema_apimachinery_apis_ops_v1alpha1_FerretDBOpsRequestList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FerretDBOpsRequestList is a list of FerretDBOpsRequests", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + 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{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + 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{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "Items is a list of FerretDBOpsRequest CRD objects", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBOpsRequest"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta", "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBOpsRequest"}, + } +} + +func schema_apimachinery_apis_ops_v1alpha1_FerretDBOpsRequestSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FerretDBOpsRequestSpec is the spec for FerretDBOpsRequest", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "databaseRef": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the FerretDB reference", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the ops request type: UpdateVersion, HorizontalScaling, VerticalScaling etc.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "updateVersion": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies information necessary for upgrading ferretdb", + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBUpdateVersionSpec"), + }, + }, + "horizontalScaling": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies information necessary for horizontal scaling", + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBHorizontalScalingSpec"), + }, + }, + "verticalScaling": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies information necessary for vertical scaling", + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBVerticalScalingSpec"), + }, + }, + "tls": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies information necessary for configuring TLS", + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBTLSSpec"), + }, + }, + "restart": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies information necessary for restarting database", + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.RestartSpec"), + }, + }, + "timeout": { + SchemaProps: spec.SchemaProps{ + Description: "Timeout for each step of the ops request in second. If a step doesn't finish within the specified timeout, the ops request will result in failure.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Duration"), + }, + }, + "apply": { + SchemaProps: spec.SchemaProps{ + Description: "ApplyOption is to control the execution of OpsRequest depending on the database state.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"databaseRef", "type"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.Duration", "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBHorizontalScalingSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBTLSSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBUpdateVersionSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.FerretDBVerticalScalingSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.RestartSpec"}, + } +} + +func schema_apimachinery_apis_ops_v1alpha1_FerretDBTLSSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "issuerRef": { + SchemaProps: spec.SchemaProps{ + Description: "IssuerRef is a reference to a Certificate Issuer.", + Ref: ref("k8s.io/api/core/v1.TypedLocalObjectReference"), + }, + }, + "certificates": { + SchemaProps: spec.SchemaProps{ + Description: "Certificate provides server and/or client certificate options used by application pods. These options are passed to a cert-manager Certificate object. xref: https://github.com/jetstack/cert-manager/blob/v0.16.0/pkg/apis/certmanager/v1beta1/types_certificate.go#L82-L162", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kmodules.xyz/client-go/api/v1.CertificateSpec"), + }, + }, + }, + }, + }, + "rotateCertificates": { + SchemaProps: spec.SchemaProps{ + Description: "RotateCertificates tells operator to initiate certificate rotation", + Type: []string{"boolean"}, + Format: "", + }, + }, + "remove": { + SchemaProps: spec.SchemaProps{ + Description: "Remove tells operator to remove TLS configuration", + Type: []string{"boolean"}, + Format: "", + }, + }, + "sslMode": { + SchemaProps: spec.SchemaProps{ + Description: "SSLMode for both standalone and clusters. [disable;allow;prefer;require;verify-ca;verify-full]", + Type: []string{"string"}, + Format: "", + }, + }, + "clientAuthMode": { + SchemaProps: spec.SchemaProps{ + Description: "ClientAuthMode for both standalone and clusters. (default will be md5. [md5;scram;cert])", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.TypedLocalObjectReference", "kmodules.xyz/client-go/api/v1.CertificateSpec"}, + } +} + +func schema_apimachinery_apis_ops_v1alpha1_FerretDBUpdateVersionSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FerretDBUpdateVersionSpec contains the update version information of a ferretdb cluster", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "targetVersion": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the target version name from catalog", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_apimachinery_apis_ops_v1alpha1_FerretDBVerticalScalingSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FerretDBVerticalScalingSpec contains the vertical scaling information of a FerretDB cluster", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "node": { + SchemaProps: spec.SchemaProps{ + Description: "Resource spec for nodes", + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.PodResources"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "kubedb.dev/apimachinery/apis/ops/v1alpha1.PodResources"}, + } +} + func schema_apimachinery_apis_ops_v1alpha1_HiddenNode(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/apis/ops/v1alpha1/register.go b/apis/ops/v1alpha1/register.go index 2d3d703d55..a9820f1eff 100644 --- a/apis/ops/v1alpha1/register.go +++ b/apis/ops/v1alpha1/register.go @@ -58,6 +58,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &DruidOpsRequestList{}, &ElasticsearchOpsRequest{}, &ElasticsearchOpsRequestList{}, + &FerretDBOpsRequest{}, + &FerretDBOpsRequestList{}, &EtcdOpsRequest{}, &EtcdOpsRequestList{}, &KafkaOpsRequest{}, diff --git a/apis/ops/v1alpha1/zz_generated.deepcopy.go b/apis/ops/v1alpha1/zz_generated.deepcopy.go index 9d8037cdb2..247d23519f 100644 --- a/apis/ops/v1alpha1/zz_generated.deepcopy.go +++ b/apis/ops/v1alpha1/zz_generated.deepcopy.go @@ -962,6 +962,189 @@ func (in *EtcdVolumeExpansionSpec) DeepCopy() *EtcdVolumeExpansionSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FerretDBHorizontalScalingSpec) DeepCopyInto(out *FerretDBHorizontalScalingSpec) { + *out = *in + if in.Node != nil { + in, out := &in.Node, &out.Node + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FerretDBHorizontalScalingSpec. +func (in *FerretDBHorizontalScalingSpec) DeepCopy() *FerretDBHorizontalScalingSpec { + if in == nil { + return nil + } + out := new(FerretDBHorizontalScalingSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FerretDBOpsRequest) DeepCopyInto(out *FerretDBOpsRequest) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FerretDBOpsRequest. +func (in *FerretDBOpsRequest) DeepCopy() *FerretDBOpsRequest { + if in == nil { + return nil + } + out := new(FerretDBOpsRequest) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FerretDBOpsRequest) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FerretDBOpsRequestList) DeepCopyInto(out *FerretDBOpsRequestList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]FerretDBOpsRequest, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FerretDBOpsRequestList. +func (in *FerretDBOpsRequestList) DeepCopy() *FerretDBOpsRequestList { + if in == nil { + return nil + } + out := new(FerretDBOpsRequestList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FerretDBOpsRequestList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FerretDBOpsRequestSpec) DeepCopyInto(out *FerretDBOpsRequestSpec) { + *out = *in + out.DatabaseRef = in.DatabaseRef + if in.UpdateVersion != nil { + in, out := &in.UpdateVersion, &out.UpdateVersion + *out = new(FerretDBUpdateVersionSpec) + **out = **in + } + if in.HorizontalScaling != nil { + in, out := &in.HorizontalScaling, &out.HorizontalScaling + *out = new(FerretDBHorizontalScalingSpec) + (*in).DeepCopyInto(*out) + } + if in.VerticalScaling != nil { + in, out := &in.VerticalScaling, &out.VerticalScaling + *out = new(FerretDBVerticalScalingSpec) + (*in).DeepCopyInto(*out) + } + if in.TLS != nil { + in, out := &in.TLS, &out.TLS + *out = new(FerretDBTLSSpec) + (*in).DeepCopyInto(*out) + } + if in.Restart != nil { + in, out := &in.Restart, &out.Restart + *out = new(RestartSpec) + **out = **in + } + if in.Timeout != nil { + in, out := &in.Timeout, &out.Timeout + *out = new(v1.Duration) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FerretDBOpsRequestSpec. +func (in *FerretDBOpsRequestSpec) DeepCopy() *FerretDBOpsRequestSpec { + if in == nil { + return nil + } + out := new(FerretDBOpsRequestSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FerretDBTLSSpec) DeepCopyInto(out *FerretDBTLSSpec) { + *out = *in + in.TLSSpec.DeepCopyInto(&out.TLSSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FerretDBTLSSpec. +func (in *FerretDBTLSSpec) DeepCopy() *FerretDBTLSSpec { + if in == nil { + return nil + } + out := new(FerretDBTLSSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FerretDBUpdateVersionSpec) DeepCopyInto(out *FerretDBUpdateVersionSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FerretDBUpdateVersionSpec. +func (in *FerretDBUpdateVersionSpec) DeepCopy() *FerretDBUpdateVersionSpec { + if in == nil { + return nil + } + out := new(FerretDBUpdateVersionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FerretDBVerticalScalingSpec) DeepCopyInto(out *FerretDBVerticalScalingSpec) { + *out = *in + if in.Node != nil { + in, out := &in.Node, &out.Node + *out = new(PodResources) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FerretDBVerticalScalingSpec. +func (in *FerretDBVerticalScalingSpec) DeepCopy() *FerretDBVerticalScalingSpec { + if in == nil { + return nil + } + out := new(FerretDBVerticalScalingSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HiddenNode) DeepCopyInto(out *HiddenNode) { *out = *in diff --git a/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_ferretdbopsrequest.go b/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_ferretdbopsrequest.go new file mode 100644 index 0000000000..c45f2a8c31 --- /dev/null +++ b/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_ferretdbopsrequest.go @@ -0,0 +1,142 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "kubedb.dev/apimachinery/apis/ops/v1alpha1" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeFerretDBOpsRequests implements FerretDBOpsRequestInterface +type FakeFerretDBOpsRequests struct { + Fake *FakeOpsV1alpha1 + ns string +} + +var ferretdbopsrequestsResource = v1alpha1.SchemeGroupVersion.WithResource("ferretdbopsrequests") + +var ferretdbopsrequestsKind = v1alpha1.SchemeGroupVersion.WithKind("FerretDBOpsRequest") + +// Get takes name of the ferretDBOpsRequest, and returns the corresponding ferretDBOpsRequest object, and an error if there is any. +func (c *FakeFerretDBOpsRequests) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.FerretDBOpsRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(ferretdbopsrequestsResource, c.ns, name), &v1alpha1.FerretDBOpsRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.FerretDBOpsRequest), err +} + +// List takes label and field selectors, and returns the list of FerretDBOpsRequests that match those selectors. +func (c *FakeFerretDBOpsRequests) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FerretDBOpsRequestList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(ferretdbopsrequestsResource, ferretdbopsrequestsKind, c.ns, opts), &v1alpha1.FerretDBOpsRequestList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.FerretDBOpsRequestList{ListMeta: obj.(*v1alpha1.FerretDBOpsRequestList).ListMeta} + for _, item := range obj.(*v1alpha1.FerretDBOpsRequestList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested ferretDBOpsRequests. +func (c *FakeFerretDBOpsRequests) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(ferretdbopsrequestsResource, c.ns, opts)) + +} + +// Create takes the representation of a ferretDBOpsRequest and creates it. Returns the server's representation of the ferretDBOpsRequest, and an error, if there is any. +func (c *FakeFerretDBOpsRequests) Create(ctx context.Context, ferretDBOpsRequest *v1alpha1.FerretDBOpsRequest, opts v1.CreateOptions) (result *v1alpha1.FerretDBOpsRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(ferretdbopsrequestsResource, c.ns, ferretDBOpsRequest), &v1alpha1.FerretDBOpsRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.FerretDBOpsRequest), err +} + +// Update takes the representation of a ferretDBOpsRequest and updates it. Returns the server's representation of the ferretDBOpsRequest, and an error, if there is any. +func (c *FakeFerretDBOpsRequests) Update(ctx context.Context, ferretDBOpsRequest *v1alpha1.FerretDBOpsRequest, opts v1.UpdateOptions) (result *v1alpha1.FerretDBOpsRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(ferretdbopsrequestsResource, c.ns, ferretDBOpsRequest), &v1alpha1.FerretDBOpsRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.FerretDBOpsRequest), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeFerretDBOpsRequests) UpdateStatus(ctx context.Context, ferretDBOpsRequest *v1alpha1.FerretDBOpsRequest, opts v1.UpdateOptions) (*v1alpha1.FerretDBOpsRequest, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(ferretdbopsrequestsResource, "status", c.ns, ferretDBOpsRequest), &v1alpha1.FerretDBOpsRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.FerretDBOpsRequest), err +} + +// Delete takes name of the ferretDBOpsRequest and deletes it. Returns an error if one occurs. +func (c *FakeFerretDBOpsRequests) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(ferretdbopsrequestsResource, c.ns, name, opts), &v1alpha1.FerretDBOpsRequest{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeFerretDBOpsRequests) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(ferretdbopsrequestsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.FerretDBOpsRequestList{}) + return err +} + +// Patch applies the patch and returns the patched ferretDBOpsRequest. +func (c *FakeFerretDBOpsRequests) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.FerretDBOpsRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(ferretdbopsrequestsResource, c.ns, name, pt, data, subresources...), &v1alpha1.FerretDBOpsRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.FerretDBOpsRequest), err +} diff --git a/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_ops_client.go b/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_ops_client.go index 4c7dd18990..7dc20c332b 100644 --- a/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_ops_client.go +++ b/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_ops_client.go @@ -41,6 +41,10 @@ func (c *FakeOpsV1alpha1) EtcdOpsRequests(namespace string) v1alpha1.EtcdOpsRequ return &FakeEtcdOpsRequests{c, namespace} } +func (c *FakeOpsV1alpha1) FerretDBOpsRequests(namespace string) v1alpha1.FerretDBOpsRequestInterface { + return &FakeFerretDBOpsRequests{c, namespace} +} + func (c *FakeOpsV1alpha1) KafkaOpsRequests(namespace string) v1alpha1.KafkaOpsRequestInterface { return &FakeKafkaOpsRequests{c, namespace} } diff --git a/client/clientset/versioned/typed/ops/v1alpha1/ferretdbopsrequest.go b/client/clientset/versioned/typed/ops/v1alpha1/ferretdbopsrequest.go new file mode 100644 index 0000000000..b986c5eada --- /dev/null +++ b/client/clientset/versioned/typed/ops/v1alpha1/ferretdbopsrequest.go @@ -0,0 +1,196 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "kubedb.dev/apimachinery/apis/ops/v1alpha1" + scheme "kubedb.dev/apimachinery/client/clientset/versioned/scheme" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// FerretDBOpsRequestsGetter has a method to return a FerretDBOpsRequestInterface. +// A group's client should implement this interface. +type FerretDBOpsRequestsGetter interface { + FerretDBOpsRequests(namespace string) FerretDBOpsRequestInterface +} + +// FerretDBOpsRequestInterface has methods to work with FerretDBOpsRequest resources. +type FerretDBOpsRequestInterface interface { + Create(ctx context.Context, ferretDBOpsRequest *v1alpha1.FerretDBOpsRequest, opts v1.CreateOptions) (*v1alpha1.FerretDBOpsRequest, error) + Update(ctx context.Context, ferretDBOpsRequest *v1alpha1.FerretDBOpsRequest, opts v1.UpdateOptions) (*v1alpha1.FerretDBOpsRequest, error) + UpdateStatus(ctx context.Context, ferretDBOpsRequest *v1alpha1.FerretDBOpsRequest, opts v1.UpdateOptions) (*v1alpha1.FerretDBOpsRequest, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.FerretDBOpsRequest, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.FerretDBOpsRequestList, 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 *v1alpha1.FerretDBOpsRequest, err error) + FerretDBOpsRequestExpansion +} + +// ferretDBOpsRequests implements FerretDBOpsRequestInterface +type ferretDBOpsRequests struct { + client rest.Interface + ns string +} + +// newFerretDBOpsRequests returns a FerretDBOpsRequests +func newFerretDBOpsRequests(c *OpsV1alpha1Client, namespace string) *ferretDBOpsRequests { + return &ferretDBOpsRequests{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the ferretDBOpsRequest, and returns the corresponding ferretDBOpsRequest object, and an error if there is any. +func (c *ferretDBOpsRequests) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.FerretDBOpsRequest, err error) { + result = &v1alpha1.FerretDBOpsRequest{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ferretdbopsrequests"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of FerretDBOpsRequests that match those selectors. +func (c *ferretDBOpsRequests) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FerretDBOpsRequestList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.FerretDBOpsRequestList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ferretdbopsrequests"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested ferretDBOpsRequests. +func (c *ferretDBOpsRequests) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("ferretdbopsrequests"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a ferretDBOpsRequest and creates it. Returns the server's representation of the ferretDBOpsRequest, and an error, if there is any. +func (c *ferretDBOpsRequests) Create(ctx context.Context, ferretDBOpsRequest *v1alpha1.FerretDBOpsRequest, opts v1.CreateOptions) (result *v1alpha1.FerretDBOpsRequest, err error) { + result = &v1alpha1.FerretDBOpsRequest{} + err = c.client.Post(). + Namespace(c.ns). + Resource("ferretdbopsrequests"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ferretDBOpsRequest). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a ferretDBOpsRequest and updates it. Returns the server's representation of the ferretDBOpsRequest, and an error, if there is any. +func (c *ferretDBOpsRequests) Update(ctx context.Context, ferretDBOpsRequest *v1alpha1.FerretDBOpsRequest, opts v1.UpdateOptions) (result *v1alpha1.FerretDBOpsRequest, err error) { + result = &v1alpha1.FerretDBOpsRequest{} + err = c.client.Put(). + Namespace(c.ns). + Resource("ferretdbopsrequests"). + Name(ferretDBOpsRequest.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ferretDBOpsRequest). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *ferretDBOpsRequests) UpdateStatus(ctx context.Context, ferretDBOpsRequest *v1alpha1.FerretDBOpsRequest, opts v1.UpdateOptions) (result *v1alpha1.FerretDBOpsRequest, err error) { + result = &v1alpha1.FerretDBOpsRequest{} + err = c.client.Put(). + Namespace(c.ns). + Resource("ferretdbopsrequests"). + Name(ferretDBOpsRequest.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ferretDBOpsRequest). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the ferretDBOpsRequest and deletes it. Returns an error if one occurs. +func (c *ferretDBOpsRequests) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("ferretdbopsrequests"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *ferretDBOpsRequests) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("ferretdbopsrequests"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched ferretDBOpsRequest. +func (c *ferretDBOpsRequests) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.FerretDBOpsRequest, err error) { + result = &v1alpha1.FerretDBOpsRequest{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("ferretdbopsrequests"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client/clientset/versioned/typed/ops/v1alpha1/generated_expansion.go b/client/clientset/versioned/typed/ops/v1alpha1/generated_expansion.go index e47b8248f8..65ed3e73da 100644 --- a/client/clientset/versioned/typed/ops/v1alpha1/generated_expansion.go +++ b/client/clientset/versioned/typed/ops/v1alpha1/generated_expansion.go @@ -24,6 +24,8 @@ type ElasticsearchOpsRequestExpansion interface{} type EtcdOpsRequestExpansion interface{} +type FerretDBOpsRequestExpansion interface{} + type KafkaOpsRequestExpansion interface{} type MariaDBOpsRequestExpansion interface{} diff --git a/client/clientset/versioned/typed/ops/v1alpha1/ops_client.go b/client/clientset/versioned/typed/ops/v1alpha1/ops_client.go index 74cd3315f7..e58eb6f708 100644 --- a/client/clientset/versioned/typed/ops/v1alpha1/ops_client.go +++ b/client/clientset/versioned/typed/ops/v1alpha1/ops_client.go @@ -32,6 +32,7 @@ type OpsV1alpha1Interface interface { DruidOpsRequestsGetter ElasticsearchOpsRequestsGetter EtcdOpsRequestsGetter + FerretDBOpsRequestsGetter KafkaOpsRequestsGetter MariaDBOpsRequestsGetter MemcachedOpsRequestsGetter @@ -66,6 +67,10 @@ func (c *OpsV1alpha1Client) EtcdOpsRequests(namespace string) EtcdOpsRequestInte return newEtcdOpsRequests(c, namespace) } +func (c *OpsV1alpha1Client) FerretDBOpsRequests(namespace string) FerretDBOpsRequestInterface { + return newFerretDBOpsRequests(c, namespace) +} + func (c *OpsV1alpha1Client) KafkaOpsRequests(namespace string) KafkaOpsRequestInterface { return newKafkaOpsRequests(c, namespace) } diff --git a/client/informers/externalversions/generic.go b/client/informers/externalversions/generic.go index 93661ddc96..4e488415f7 100644 --- a/client/informers/externalversions/generic.go +++ b/client/informers/externalversions/generic.go @@ -259,6 +259,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Ops().V1alpha1().ElasticsearchOpsRequests().Informer()}, nil case opsv1alpha1.SchemeGroupVersion.WithResource("etcdopsrequests"): return &genericInformer{resource: resource.GroupResource(), informer: f.Ops().V1alpha1().EtcdOpsRequests().Informer()}, nil + case opsv1alpha1.SchemeGroupVersion.WithResource("ferretdbopsrequests"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Ops().V1alpha1().FerretDBOpsRequests().Informer()}, nil case opsv1alpha1.SchemeGroupVersion.WithResource("kafkaopsrequests"): return &genericInformer{resource: resource.GroupResource(), informer: f.Ops().V1alpha1().KafkaOpsRequests().Informer()}, nil case opsv1alpha1.SchemeGroupVersion.WithResource("mariadbopsrequests"): diff --git a/client/informers/externalversions/ops/v1alpha1/ferretdbopsrequest.go b/client/informers/externalversions/ops/v1alpha1/ferretdbopsrequest.go new file mode 100644 index 0000000000..6faee3a986 --- /dev/null +++ b/client/informers/externalversions/ops/v1alpha1/ferretdbopsrequest.go @@ -0,0 +1,91 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + opsv1alpha1 "kubedb.dev/apimachinery/apis/ops/v1alpha1" + versioned "kubedb.dev/apimachinery/client/clientset/versioned" + internalinterfaces "kubedb.dev/apimachinery/client/informers/externalversions/internalinterfaces" + v1alpha1 "kubedb.dev/apimachinery/client/listers/ops/v1alpha1" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// FerretDBOpsRequestInformer provides access to a shared informer and lister for +// FerretDBOpsRequests. +type FerretDBOpsRequestInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.FerretDBOpsRequestLister +} + +type ferretDBOpsRequestInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewFerretDBOpsRequestInformer constructs a new informer for FerretDBOpsRequest type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFerretDBOpsRequestInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredFerretDBOpsRequestInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredFerretDBOpsRequestInformer constructs a new informer for FerretDBOpsRequest type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredFerretDBOpsRequestInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OpsV1alpha1().FerretDBOpsRequests(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OpsV1alpha1().FerretDBOpsRequests(namespace).Watch(context.TODO(), options) + }, + }, + &opsv1alpha1.FerretDBOpsRequest{}, + resyncPeriod, + indexers, + ) +} + +func (f *ferretDBOpsRequestInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredFerretDBOpsRequestInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *ferretDBOpsRequestInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&opsv1alpha1.FerretDBOpsRequest{}, f.defaultInformer) +} + +func (f *ferretDBOpsRequestInformer) Lister() v1alpha1.FerretDBOpsRequestLister { + return v1alpha1.NewFerretDBOpsRequestLister(f.Informer().GetIndexer()) +} diff --git a/client/informers/externalversions/ops/v1alpha1/interface.go b/client/informers/externalversions/ops/v1alpha1/interface.go index fbd344ffc3..a65f3bca52 100644 --- a/client/informers/externalversions/ops/v1alpha1/interface.go +++ b/client/informers/externalversions/ops/v1alpha1/interface.go @@ -30,6 +30,8 @@ type Interface interface { ElasticsearchOpsRequests() ElasticsearchOpsRequestInformer // EtcdOpsRequests returns a EtcdOpsRequestInformer. EtcdOpsRequests() EtcdOpsRequestInformer + // FerretDBOpsRequests returns a FerretDBOpsRequestInformer. + FerretDBOpsRequests() FerretDBOpsRequestInformer // KafkaOpsRequests returns a KafkaOpsRequestInformer. KafkaOpsRequests() KafkaOpsRequestInformer // MariaDBOpsRequests returns a MariaDBOpsRequestInformer. @@ -88,6 +90,11 @@ func (v *version) EtcdOpsRequests() EtcdOpsRequestInformer { return &etcdOpsRequestInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// FerretDBOpsRequests returns a FerretDBOpsRequestInformer. +func (v *version) FerretDBOpsRequests() FerretDBOpsRequestInformer { + return &ferretDBOpsRequestInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // KafkaOpsRequests returns a KafkaOpsRequestInformer. func (v *version) KafkaOpsRequests() KafkaOpsRequestInformer { return &kafkaOpsRequestInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/client/listers/ops/v1alpha1/expansion_generated.go b/client/listers/ops/v1alpha1/expansion_generated.go index 4709abab5c..037c57858c 100644 --- a/client/listers/ops/v1alpha1/expansion_generated.go +++ b/client/listers/ops/v1alpha1/expansion_generated.go @@ -42,6 +42,14 @@ type EtcdOpsRequestListerExpansion interface{} // EtcdOpsRequestNamespaceLister. type EtcdOpsRequestNamespaceListerExpansion interface{} +// FerretDBOpsRequestListerExpansion allows custom methods to be added to +// FerretDBOpsRequestLister. +type FerretDBOpsRequestListerExpansion interface{} + +// FerretDBOpsRequestNamespaceListerExpansion allows custom methods to be added to +// FerretDBOpsRequestNamespaceLister. +type FerretDBOpsRequestNamespaceListerExpansion interface{} + // KafkaOpsRequestListerExpansion allows custom methods to be added to // KafkaOpsRequestLister. type KafkaOpsRequestListerExpansion interface{} diff --git a/client/listers/ops/v1alpha1/ferretdbopsrequest.go b/client/listers/ops/v1alpha1/ferretdbopsrequest.go new file mode 100644 index 0000000000..ee220deae9 --- /dev/null +++ b/client/listers/ops/v1alpha1/ferretdbopsrequest.go @@ -0,0 +1,100 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "kubedb.dev/apimachinery/apis/ops/v1alpha1" + + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// FerretDBOpsRequestLister helps list FerretDBOpsRequests. +// All objects returned here must be treated as read-only. +type FerretDBOpsRequestLister interface { + // List lists all FerretDBOpsRequests in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.FerretDBOpsRequest, err error) + // FerretDBOpsRequests returns an object that can list and get FerretDBOpsRequests. + FerretDBOpsRequests(namespace string) FerretDBOpsRequestNamespaceLister + FerretDBOpsRequestListerExpansion +} + +// ferretDBOpsRequestLister implements the FerretDBOpsRequestLister interface. +type ferretDBOpsRequestLister struct { + indexer cache.Indexer +} + +// NewFerretDBOpsRequestLister returns a new FerretDBOpsRequestLister. +func NewFerretDBOpsRequestLister(indexer cache.Indexer) FerretDBOpsRequestLister { + return &ferretDBOpsRequestLister{indexer: indexer} +} + +// List lists all FerretDBOpsRequests in the indexer. +func (s *ferretDBOpsRequestLister) List(selector labels.Selector) (ret []*v1alpha1.FerretDBOpsRequest, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.FerretDBOpsRequest)) + }) + return ret, err +} + +// FerretDBOpsRequests returns an object that can list and get FerretDBOpsRequests. +func (s *ferretDBOpsRequestLister) FerretDBOpsRequests(namespace string) FerretDBOpsRequestNamespaceLister { + return ferretDBOpsRequestNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// FerretDBOpsRequestNamespaceLister helps list and get FerretDBOpsRequests. +// All objects returned here must be treated as read-only. +type FerretDBOpsRequestNamespaceLister interface { + // List lists all FerretDBOpsRequests in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.FerretDBOpsRequest, err error) + // Get retrieves the FerretDBOpsRequest from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.FerretDBOpsRequest, error) + FerretDBOpsRequestNamespaceListerExpansion +} + +// ferretDBOpsRequestNamespaceLister implements the FerretDBOpsRequestNamespaceLister +// interface. +type ferretDBOpsRequestNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all FerretDBOpsRequests in the indexer for a given namespace. +func (s ferretDBOpsRequestNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.FerretDBOpsRequest, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.FerretDBOpsRequest)) + }) + return ret, err +} + +// Get retrieves the FerretDBOpsRequest from the indexer for a given namespace and name. +func (s ferretDBOpsRequestNamespaceLister) Get(name string) (*v1alpha1.FerretDBOpsRequest, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("ferretdbopsrequest"), name) + } + return obj.(*v1alpha1.FerretDBOpsRequest), nil +} diff --git a/crds/ops.kubedb.com_ferretdbopsrequests.yaml b/crds/ops.kubedb.com_ferretdbopsrequests.yaml new file mode 100644 index 0000000000..9da67451de --- /dev/null +++ b/crds/ops.kubedb.com_ferretdbopsrequests.yaml @@ -0,0 +1,314 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + labels: + app.kubernetes.io/name: kubedb + name: ferretdbopsrequests.ops.kubedb.com +spec: + group: ops.kubedb.com + names: + categories: + - datastore + - kubedb + - appscode + kind: FerretDBOpsRequest + listKind: FerretDBOpsRequestList + plural: ferretdbopsrequests + shortNames: + - frops + singular: ferretdbopsrequest + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.type + name: Type + type: string + - jsonPath: .status.phase + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + apply: + default: IfReady + enum: + - IfReady + - Always + type: string + databaseRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + horizontalScaling: + properties: + node: + format: int32 + type: integer + type: object + restart: + type: object + timeout: + type: string + tls: + properties: + certificates: + items: + properties: + alias: + type: string + dnsNames: + items: + type: string + type: array + duration: + type: string + emailAddresses: + items: + type: string + type: array + ipAddresses: + items: + type: string + type: array + issuerRef: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + required: + - kind + - name + type: object + x-kubernetes-map-type: atomic + privateKey: + properties: + encoding: + enum: + - PKCS1 + - PKCS8 + type: string + type: object + renewBefore: + type: string + secretName: + type: string + subject: + properties: + countries: + items: + type: string + type: array + localities: + items: + type: string + type: array + organizationalUnits: + items: + type: string + type: array + organizations: + items: + type: string + type: array + postalCodes: + items: + type: string + type: array + provinces: + items: + type: string + type: array + serialNumber: + type: string + streetAddresses: + items: + type: string + type: array + type: object + uris: + items: + type: string + type: array + required: + - alias + type: object + type: array + clientAuthMode: + enum: + - keyFile + - sendKeyFile + - sendX509 + - x509 + type: string + issuerRef: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + required: + - kind + - name + type: object + x-kubernetes-map-type: atomic + remove: + type: boolean + rotateCertificates: + type: boolean + sslMode: + enum: + - disabled + - allowSSL + - preferSSL + - requireSSL + type: string + type: object + type: + enum: + - UpdateVersion + - VerticalScaling + - Restart + - HorizontalScaling + - ReconfigureTLS + type: string + updateVersion: + properties: + targetVersion: + type: string + type: object + verticalScaling: + properties: + node: + properties: + nodeSelectionPolicy: + type: string + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + topology: + properties: + key: + type: string + value: + type: string + required: + - key + - value + type: object + type: object + type: object + required: + - databaseRef + - type + type: object + status: + properties: + conditions: + items: + properties: + lastTransitionTime: + format: date-time + type: string + message: + type: string + observedGeneration: + format: int64 + type: integer + reason: + type: string + severity: + type: string + status: + type: string + type: + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + observedGeneration: + format: int64 + type: integer + pausedBackups: + items: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + namespace: + type: string + required: + - name + type: object + type: array + phase: + enum: + - Pending + - Progressing + - Successful + - WaitingForApproval + - Failed + - Approved + - Denied + - Skipped + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} From 6d44bfc1c0d43657a9555263795978fcac27a5f4 Mon Sep 17 00:00:00 2001 From: Raihan Khan Date: Fri, 2 Aug 2024 10:53:13 +0600 Subject: [PATCH 4/7] Upsert config-merger initContainer via ES defaults (#1259) Signed-off-by: raihankhan --- apis/kubedb/v1/elasticsearch_helpers.go | 61 +++++++++++++++++-------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/apis/kubedb/v1/elasticsearch_helpers.go b/apis/kubedb/v1/elasticsearch_helpers.go index ab49933269..a8a4ac2915 100644 --- a/apis/kubedb/v1/elasticsearch_helpers.go +++ b/apis/kubedb/v1/elasticsearch_helpers.go @@ -389,7 +389,7 @@ func (e Elasticsearch) StatsServiceLabels() map[string]string { return e.ServiceLabels(StatsServiceAlias, map[string]string{kubedb.LabelRole: kubedb.RoleStats}) } -func (e Elasticsearch) setContainerSecurityContextDefaults(esVersion *catalog.ElasticsearchVersion, podTemplate *ofstv2.PodTemplateSpec) { +func (e Elasticsearch) setContainerSecurityContextDefaults(esVersion *catalog.ElasticsearchVersion, podTemplate *ofstv2.PodTemplateSpec, containerName string) { if podTemplate == nil { return } @@ -400,17 +400,27 @@ func (e Elasticsearch) setContainerSecurityContextDefaults(esVersion *catalog.El if podTemplate.Spec.SecurityContext.FSGroup == nil { podTemplate.Spec.SecurityContext.FSGroup = esVersion.Spec.SecurityContext.RunAsUser } - dbContainer := core_util.GetContainerByName(podTemplate.Spec.Containers, kubedb.ElasticsearchContainerName) - if dbContainer == nil { - dbContainer = &core.Container{ - Name: kubedb.ElasticsearchContainerName, + getContainers := func() []core.Container { + if containerName == kubedb.ElasticsearchInitConfigMergerContainerName { + return podTemplate.Spec.InitContainers } + return podTemplate.Spec.Containers } - if dbContainer.SecurityContext == nil { - dbContainer.SecurityContext = &core.SecurityContext{} + container := core_util.GetContainerByName(getContainers(), containerName) + if container == nil { + container = &core.Container{ + Name: containerName, + } + } + if container.SecurityContext == nil { + container.SecurityContext = &core.SecurityContext{} + } + e.assignDefaultContainerSecurityContext(esVersion, container.SecurityContext) + if containerName == kubedb.ElasticsearchInitConfigMergerContainerName { + podTemplate.Spec.InitContainers = core_util.UpsertContainer(podTemplate.Spec.InitContainers, *container) + return } - e.assignDefaultContainerSecurityContext(esVersion, dbContainer.SecurityContext) - podTemplate.Spec.Containers = core_util.UpsertContainer(podTemplate.Spec.Containers, *dbContainer) + podTemplate.Spec.Containers = core_util.UpsertContainer(podTemplate.Spec.Containers, *container) } func (e Elasticsearch) assignDefaultContainerSecurityContext(esVersion *catalog.ElasticsearchVersion, sc *core.SecurityContext) { @@ -460,7 +470,8 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion) { if e.Spec.Topology.Ingest.Suffix == "" { e.Spec.Topology.Ingest.Suffix = string(ElasticsearchNodeRoleTypeIngest) } - e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.Ingest.PodTemplate) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.Ingest.PodTemplate, kubedb.ElasticsearchContainerName) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.Ingest.PodTemplate, kubedb.ElasticsearchInitConfigMergerContainerName) dbContainer := core_util.GetContainerByName(e.Spec.Topology.Ingest.PodTemplate.Spec.Containers, kubedb.ElasticsearchContainerName) if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { apis.SetDefaultResourceLimits(&dbContainer.Resources, kubedb.DefaultResourcesMemoryIntensive) @@ -477,7 +488,8 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion) { if e.Spec.Topology.Master.Suffix == "" { e.Spec.Topology.Master.Suffix = string(ElasticsearchNodeRoleTypeMaster) } - e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.Master.PodTemplate) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.Master.PodTemplate, kubedb.ElasticsearchContainerName) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.Master.PodTemplate, kubedb.ElasticsearchInitConfigMergerContainerName) dbContainer = core_util.GetContainerByName(e.Spec.Topology.Master.PodTemplate.Spec.Containers, kubedb.ElasticsearchContainerName) if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { apis.SetDefaultResourceLimits(&dbContainer.Resources, kubedb.DefaultResourcesMemoryIntensive) @@ -496,7 +508,8 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion) { if e.Spec.Topology.Data.Suffix == "" { e.Spec.Topology.Data.Suffix = string(ElasticsearchNodeRoleTypeData) } - e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.Data.PodTemplate) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.Data.PodTemplate, kubedb.ElasticsearchContainerName) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.Data.PodTemplate, kubedb.ElasticsearchInitConfigMergerContainerName) dbContainer = core_util.GetContainerByName(e.Spec.Topology.Data.PodTemplate.Spec.Containers, kubedb.ElasticsearchContainerName) if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { apis.SetDefaultResourceLimits(&dbContainer.Resources, kubedb.DefaultResourcesMemoryIntensive) @@ -515,7 +528,8 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion) { if e.Spec.Topology.DataHot.Suffix == "" { e.Spec.Topology.DataHot.Suffix = string(ElasticsearchNodeRoleTypeDataHot) } - e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataHot.PodTemplate) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataHot.PodTemplate, kubedb.ElasticsearchContainerName) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataHot.PodTemplate, kubedb.ElasticsearchInitConfigMergerContainerName) dbContainer = core_util.GetContainerByName(e.Spec.Topology.DataHot.PodTemplate.Spec.Containers, kubedb.ElasticsearchContainerName) if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { apis.SetDefaultResourceLimits(&dbContainer.Resources, kubedb.DefaultResourcesMemoryIntensive) @@ -534,7 +548,8 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion) { if e.Spec.Topology.DataWarm.Suffix == "" { e.Spec.Topology.DataWarm.Suffix = string(ElasticsearchNodeRoleTypeDataWarm) } - e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataWarm.PodTemplate) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataWarm.PodTemplate, kubedb.ElasticsearchContainerName) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataWarm.PodTemplate, kubedb.ElasticsearchInitConfigMergerContainerName) dbContainer = core_util.GetContainerByName(e.Spec.Topology.DataWarm.PodTemplate.Spec.Containers, kubedb.ElasticsearchContainerName) if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { apis.SetDefaultResourceLimits(&dbContainer.Resources, kubedb.DefaultResourcesMemoryIntensive) @@ -553,7 +568,8 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion) { if e.Spec.Topology.DataCold.Suffix == "" { e.Spec.Topology.DataCold.Suffix = string(ElasticsearchNodeRoleTypeDataCold) } - e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataCold.PodTemplate) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataCold.PodTemplate, kubedb.ElasticsearchContainerName) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataCold.PodTemplate, kubedb.ElasticsearchInitConfigMergerContainerName) dbContainer = core_util.GetContainerByName(e.Spec.Topology.DataCold.PodTemplate.Spec.Containers, kubedb.ElasticsearchContainerName) if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { apis.SetDefaultResourceLimits(&dbContainer.Resources, kubedb.DefaultResourcesMemoryIntensive) @@ -572,7 +588,8 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion) { if e.Spec.Topology.DataFrozen.Suffix == "" { e.Spec.Topology.DataFrozen.Suffix = string(ElasticsearchNodeRoleTypeDataFrozen) } - e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataFrozen.PodTemplate) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataFrozen.PodTemplate, kubedb.ElasticsearchContainerName) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataFrozen.PodTemplate, kubedb.ElasticsearchInitConfigMergerContainerName) dbContainer = core_util.GetContainerByName(e.Spec.Topology.DataFrozen.PodTemplate.Spec.Containers, kubedb.ElasticsearchContainerName) if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { apis.SetDefaultResourceLimits(&dbContainer.Resources, kubedb.DefaultResourcesMemoryIntensive) @@ -591,7 +608,8 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion) { if e.Spec.Topology.DataContent.Suffix == "" { e.Spec.Topology.DataContent.Suffix = string(ElasticsearchNodeRoleTypeDataContent) } - e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataContent.PodTemplate) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataContent.PodTemplate, kubedb.ElasticsearchContainerName) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.DataContent.PodTemplate, kubedb.ElasticsearchInitConfigMergerContainerName) dbContainer = core_util.GetContainerByName(e.Spec.Topology.DataContent.PodTemplate.Spec.Containers, kubedb.ElasticsearchContainerName) if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { apis.SetDefaultResourceLimits(&dbContainer.Resources, kubedb.DefaultResourcesMemoryIntensive) @@ -610,7 +628,8 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion) { if e.Spec.Topology.ML.Suffix == "" { e.Spec.Topology.ML.Suffix = string(ElasticsearchNodeRoleTypeML) } - e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.ML.PodTemplate) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.ML.PodTemplate, kubedb.ElasticsearchContainerName) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.ML.PodTemplate, kubedb.ElasticsearchInitConfigMergerContainerName) dbContainer = core_util.GetContainerByName(e.Spec.Topology.ML.PodTemplate.Spec.Containers, kubedb.ElasticsearchContainerName) if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { apis.SetDefaultResourceLimits(&dbContainer.Resources, kubedb.DefaultResourcesMemoryIntensive) @@ -629,7 +648,8 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion) { if e.Spec.Topology.Transform.Suffix == "" { e.Spec.Topology.Transform.Suffix = string(ElasticsearchNodeRoleTypeTransform) } - e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.Transform.PodTemplate) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.Transform.PodTemplate, kubedb.ElasticsearchContainerName) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.Topology.Transform.PodTemplate, kubedb.ElasticsearchInitConfigMergerContainerName) dbContainer = core_util.GetContainerByName(e.Spec.Topology.Transform.PodTemplate.Spec.Containers, kubedb.ElasticsearchContainerName) if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { apis.SetDefaultResourceLimits(&dbContainer.Resources, kubedb.DefaultResourcesMemoryIntensive) @@ -643,7 +663,8 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion) { } } else { - e.setContainerSecurityContextDefaults(esVersion, &e.Spec.PodTemplate) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.PodTemplate, kubedb.ElasticsearchContainerName) + e.setContainerSecurityContextDefaults(esVersion, &e.Spec.PodTemplate, kubedb.ElasticsearchInitConfigMergerContainerName) dbContainer := core_util.GetContainerByName(e.Spec.PodTemplate.Spec.Containers, kubedb.ElasticsearchContainerName) if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { apis.SetDefaultResourceLimits(&dbContainer.Resources, kubedb.DefaultResourcesMemoryIntensive) From 3f96b9077c7ace49e9cb62c28db9f6ba837b3bfa Mon Sep 17 00:00:00 2001 From: SK Ali Arman Date: Fri, 2 Aug 2024 11:06:27 +0600 Subject: [PATCH 5/7] Add ExtractDatabaseInfo Func for ClickHouse (#1270) Signed-off-by: SK Ali Arman --- apis/kubedb/v1alpha2/clickhouse_helpers.go | 23 ++++++++++++++++++---- pkg/controller/petset/util.go | 11 +++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/apis/kubedb/v1alpha2/clickhouse_helpers.go b/apis/kubedb/v1alpha2/clickhouse_helpers.go index b7627aa529..e82cf96fa7 100644 --- a/apis/kubedb/v1alpha2/clickhouse_helpers.go +++ b/apis/kubedb/v1alpha2/clickhouse_helpers.go @@ -30,6 +30,7 @@ import ( "gomodules.xyz/pointer" core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" "k8s.io/klog/v2" "kmodules.xyz/client-go/apiextensions" @@ -38,6 +39,7 @@ import ( "kmodules.xyz/client-go/policy/secomp" appcat "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1" ofst "kmodules.xyz/offshoot-api/api/v2" + pslister "kubeops.dev/petset/client/listers/apps/v1" ) type ClickhouseApp struct { @@ -269,7 +271,7 @@ func (c *ClickHouse) SetDefaults() { } } -func (r *ClickHouse) setDefaultContainerSecurityContext(chVersion *catalog.ClickHouseVersion, podTemplate *ofst.PodTemplateSpec) { +func (c *ClickHouse) setDefaultContainerSecurityContext(chVersion *catalog.ClickHouseVersion, podTemplate *ofst.PodTemplateSpec) { if podTemplate == nil { return } @@ -290,7 +292,7 @@ func (r *ClickHouse) setDefaultContainerSecurityContext(chVersion *catalog.Click if container.SecurityContext == nil { container.SecurityContext = &core.SecurityContext{} } - r.assignDefaultContainerSecurityContext(chVersion, container.SecurityContext) + c.assignDefaultContainerSecurityContext(chVersion, container.SecurityContext) initContainer := coreutil.GetContainerByName(podTemplate.Spec.InitContainers, kubedb.ClickHouseInitContainerName) if initContainer == nil { @@ -302,10 +304,10 @@ func (r *ClickHouse) setDefaultContainerSecurityContext(chVersion *catalog.Click if initContainer.SecurityContext == nil { initContainer.SecurityContext = &core.SecurityContext{} } - r.assignDefaultContainerSecurityContext(chVersion, initContainer.SecurityContext) + c.assignDefaultContainerSecurityContext(chVersion, initContainer.SecurityContext) } -func (r *ClickHouse) assignDefaultContainerSecurityContext(chVersion *catalog.ClickHouseVersion, rc *core.SecurityContext) { +func (c *ClickHouse) assignDefaultContainerSecurityContext(chVersion *catalog.ClickHouseVersion, rc *core.SecurityContext) { if rc.AllowPrivilegeEscalation == nil { rc.AllowPrivilegeEscalation = pointer.BoolP(false) } @@ -324,3 +326,16 @@ func (r *ClickHouse) assignDefaultContainerSecurityContext(chVersion *catalog.Cl rc.SeccompProfile = secomp.DefaultSeccompProfile() } } + +func (c *ClickHouse) ReplicasAreReady(lister pslister.PetSetLister) (bool, string, error) { + // Desire number of petSets + expectedItems := 0 + if c.Spec.ClusterTopology != nil { + for _, cluster := range c.Spec.ClusterTopology.Cluster { + expectedItems += int(*cluster.Shards) + } + } else { + expectedItems += 1 + } + return checkReplicasOfPetSet(lister.PetSets(c.Namespace), labels.SelectorFromSet(c.OffshootLabels()), expectedItems) +} diff --git a/pkg/controller/petset/util.go b/pkg/controller/petset/util.go index e02942d244..8a1519fa1c 100644 --- a/pkg/controller/petset/util.go +++ b/pkg/controller/petset/util.go @@ -64,6 +64,17 @@ func (c *Controller) extractDatabaseInfo(ps *petsetapps.PetSet) (*databaseInfo, } switch owner.Kind { + case olddbapi.ResourceKindClickHouse: + dbInfo.opts.GVR.Resource = olddbapi.ResourcePluralClickHouse + ch, err := c.DBClient.KubedbV1alpha2().ClickHouses(dbInfo.opts.Namespace).Get(context.TODO(), dbInfo.opts.Name, metav1.GetOptions{}) + if err != nil { + return nil, err + } + dbInfo.replicasReady, dbInfo.msg, err = ch.ReplicasAreReady(c.PSLister) + if err != nil { + return nil, err + } + case olddbapi.ResourceKindDruid: dbInfo.opts.GVR.Resource = olddbapi.ResourcePluralDruid dr, err := c.DBClient.KubedbV1alpha2().Druids(dbInfo.opts.Namespace).Get(context.TODO(), dbInfo.opts.Name, metav1.GetOptions{}) From 739f7f6f131f2405182ad49f79cb16bbf8e0773e Mon Sep 17 00:00:00 2001 From: Neaj Morshad Date: Fri, 2 Aug 2024 11:46:53 +0600 Subject: [PATCH 6/7] Add MSSQL Server Monitoring APIs (#1271) * Add MSSQL Server Monitoring API Signed-off-by: Neaj Morshad * Add MSSQL Server StatsService helpers Signed-off-by: Neaj Morshad * refactor Signed-off-by: Neaj Morshad * Add Exporter API Signed-off-by: Neaj Morshad * Update deps Signed-off-by: Neaj Morshad * make gen Signed-off-by: Neaj Morshad * Review changes Signed-off-by: Neaj Morshad --------- Signed-off-by: Neaj Morshad --- apis/catalog/v1alpha1/mssql_version_types.go | 7 + apis/catalog/v1alpha1/openapi_generated.go | 33 ++- .../catalog/v1alpha1/zz_generated.deepcopy.go | 17 ++ apis/kubedb/v1alpha2/mssqlserver_helpers.go | 47 +++- apis/kubedb/v1alpha2/mssqlserver_types.go | 5 + apis/kubedb/v1alpha2/openapi_generated.go | 29 ++- apis/kubedb/v1alpha2/zz_generated.deepcopy.go | 5 + ...atalog.kubedb.com_mssqlserverversions.yaml | 8 + crds/kubedb.com_mssqlservers.yaml | 201 ++++++++++++++++++ 9 files changed, 344 insertions(+), 8 deletions(-) diff --git a/apis/catalog/v1alpha1/mssql_version_types.go b/apis/catalog/v1alpha1/mssql_version_types.go index 9ba860097d..ccf3e40ffd 100644 --- a/apis/catalog/v1alpha1/mssql_version_types.go +++ b/apis/catalog/v1alpha1/mssql_version_types.go @@ -55,6 +55,8 @@ type MSSQLServerVersionSpec struct { // Coordinator Image // +optional Coordinator MSSQLServerCoordinator `json:"coordinator,omitempty"` + // Exporter Image + Exporter MSSQLServerVersionExporter `json:"exporter"` // Init container Image InitContainer MSSQLServerInitContainer `json:"initContainer"` // Deprecated versions usable but regarded as obsolete and best avoided, typically due to having been superseded. @@ -82,6 +84,11 @@ type MSSQLServerCoordinator struct { Image string `json:"image"` } +// MSSQLServerVersionExporter is the image for the MSSQL Server exporter +type MSSQLServerVersionExporter struct { + Image string `json:"image"` +} + // MSSQLServerInitContainer is the MSSQLServer Container initializer type MSSQLServerInitContainer struct { Image string `json:"image"` diff --git a/apis/catalog/v1alpha1/openapi_generated.go b/apis/catalog/v1alpha1/openapi_generated.go index e874ce3928..05b3a36d96 100644 --- a/apis/catalog/v1alpha1/openapi_generated.go +++ b/apis/catalog/v1alpha1/openapi_generated.go @@ -538,6 +538,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerDatabase": schema_apimachinery_apis_catalog_v1alpha1_MSSQLServerDatabase(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerInitContainer": schema_apimachinery_apis_catalog_v1alpha1_MSSQLServerInitContainer(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerVersion": schema_apimachinery_apis_catalog_v1alpha1_MSSQLServerVersion(ref), + "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerVersionExporter": schema_apimachinery_apis_catalog_v1alpha1_MSSQLServerVersionExporter(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerVersionList": schema_apimachinery_apis_catalog_v1alpha1_MSSQLServerVersionList(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerVersionSpec": schema_apimachinery_apis_catalog_v1alpha1_MSSQLServerVersionSpec(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ManifestBackup": schema_apimachinery_apis_catalog_v1alpha1_ManifestBackup(ref), @@ -27104,6 +27105,27 @@ func schema_apimachinery_apis_catalog_v1alpha1_MSSQLServerVersion(ref common.Ref } } +func schema_apimachinery_apis_catalog_v1alpha1_MSSQLServerVersionExporter(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "MSSQLServerVersionExporter is the image for the MSSQL Server exporter", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "image": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"image"}, + }, + }, + } +} + func schema_apimachinery_apis_catalog_v1alpha1_MSSQLServerVersionList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -27182,6 +27204,13 @@ func schema_apimachinery_apis_catalog_v1alpha1_MSSQLServerVersionSpec(ref common Ref: ref("kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerCoordinator"), }, }, + "exporter": { + SchemaProps: spec.SchemaProps{ + Description: "Exporter Image", + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerVersionExporter"), + }, + }, "initContainer": { SchemaProps: spec.SchemaProps{ Description: "Init container Image", @@ -27231,11 +27260,11 @@ func schema_apimachinery_apis_catalog_v1alpha1_MSSQLServerVersionSpec(ref common }, }, }, - Required: []string{"version", "db", "initContainer"}, + Required: []string{"version", "db", "exporter", "initContainer"}, }, }, Dependencies: []string{ - "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1.StashAddonSpec", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ChartInfo", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerCoordinator", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerDatabase", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerInitContainer", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SecurityContext", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.UpdateConstraints"}, + "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1.StashAddonSpec", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ChartInfo", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerCoordinator", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerDatabase", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerInitContainer", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.MSSQLServerVersionExporter", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SecurityContext", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.UpdateConstraints"}, } } diff --git a/apis/catalog/v1alpha1/zz_generated.deepcopy.go b/apis/catalog/v1alpha1/zz_generated.deepcopy.go index 1fb4f4477d..08b195ffff 100644 --- a/apis/catalog/v1alpha1/zz_generated.deepcopy.go +++ b/apis/catalog/v1alpha1/zz_generated.deepcopy.go @@ -1134,6 +1134,22 @@ func (in *MSSQLServerVersion) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MSSQLServerVersionExporter) DeepCopyInto(out *MSSQLServerVersionExporter) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MSSQLServerVersionExporter. +func (in *MSSQLServerVersionExporter) DeepCopy() *MSSQLServerVersionExporter { + if in == nil { + return nil + } + out := new(MSSQLServerVersionExporter) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MSSQLServerVersionList) DeepCopyInto(out *MSSQLServerVersionList) { *out = *in @@ -1172,6 +1188,7 @@ func (in *MSSQLServerVersionSpec) DeepCopyInto(out *MSSQLServerVersionSpec) { *out = *in out.DB = in.DB out.Coordinator = in.Coordinator + out.Exporter = in.Exporter out.InitContainer = in.InitContainer in.Stash.DeepCopyInto(&out.Stash) in.SecurityContext.DeepCopyInto(&out.SecurityContext) diff --git a/apis/kubedb/v1alpha2/mssqlserver_helpers.go b/apis/kubedb/v1alpha2/mssqlserver_helpers.go index bdbe5e3c92..4824469d5a 100644 --- a/apis/kubedb/v1alpha2/mssqlserver_helpers.go +++ b/apis/kubedb/v1alpha2/mssqlserver_helpers.go @@ -20,7 +20,6 @@ import ( "context" "fmt" "regexp" - "strings" "time" "kubedb.dev/apimachinery/apis" @@ -28,6 +27,7 @@ import ( "kubedb.dev/apimachinery/apis/kubedb" "kubedb.dev/apimachinery/crds" + promapi "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" "gomodules.xyz/pointer" core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -40,6 +40,7 @@ import ( metautil "kmodules.xyz/client-go/meta" "kmodules.xyz/client-go/policy/secomp" appcat "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1" + mona "kmodules.xyz/monitoring-agent-api/api/v1" ofst "kmodules.xyz/offshoot-api/api/v2" pslister "kubeops.dev/petset/client/listers/apps/v1" ) @@ -93,10 +94,6 @@ func (m *MSSQLServer) GoverningServiceName() string { return metautil.NameWithSuffix(m.ServiceName(), "pods") } -func (m *MSSQLServer) DefaultUserCredSecretName(username string) string { - return metautil.NameWithSuffix(m.Name, strings.ReplaceAll(fmt.Sprintf("%s-cred", username), "_", "-")) -} - func (m *MSSQLServer) offshootLabels(selector, override map[string]string) map[string]string { selector[metautil.ComponentLabelKey] = kubedb.ComponentDatabase return metautil.FilterKeys(kubedb.GroupName, selector, metautil.OverwriteKeys(nil, m.Labels, override)) @@ -120,6 +117,46 @@ func (m *MSSQLServer) OffshootSelectors(extraSelectors ...map[string]string) map return metautil.OverwriteKeys(selector, extraSelectors...) } +type mssqlserverStatsService struct { + *MSSQLServer +} + +func (m mssqlserverStatsService) GetNamespace() string { + return m.MSSQLServer.GetNamespace() +} + +func (m mssqlserverStatsService) ServiceName() string { + return m.OffshootName() + "-stats" +} + +func (m mssqlserverStatsService) ServiceMonitorName() string { + return m.ServiceName() +} + +func (m mssqlserverStatsService) ServiceMonitorAdditionalLabels() map[string]string { + return m.OffshootLabels() +} + +func (m mssqlserverStatsService) Path() string { + return kubedb.DefaultStatsPath +} + +func (m mssqlserverStatsService) Scheme() string { + return "" +} + +func (m mssqlserverStatsService) TLSConfig() *promapi.TLSConfig { + return nil +} + +func (m MSSQLServer) StatsService() mona.StatsAccessor { + return &mssqlserverStatsService{&m} +} + +func (m MSSQLServer) StatsServiceLabels() map[string]string { + return m.ServiceLabels(StatsServiceAlias, map[string]string{kubedb.LabelRole: kubedb.RoleStats}) +} + func (m *MSSQLServer) IsAvailabilityGroup() bool { return m.Spec.Topology != nil && m.Spec.Topology.Mode != nil && diff --git a/apis/kubedb/v1alpha2/mssqlserver_types.go b/apis/kubedb/v1alpha2/mssqlserver_types.go index 1a08746ecf..e340b78f71 100644 --- a/apis/kubedb/v1alpha2/mssqlserver_types.go +++ b/apis/kubedb/v1alpha2/mssqlserver_types.go @@ -20,6 +20,7 @@ import ( core "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kmapi "kmodules.xyz/client-go/api/v1" + mona "kmodules.xyz/monitoring-agent-api/api/v1" ofst "kmodules.xyz/offshoot-api/api/v2" ) @@ -129,6 +130,10 @@ type MSSQLServerSpec struct { // +optional // +kubebuilder:default={periodSeconds: 10, timeoutSeconds: 10, failureThreshold: 1} HealthChecker kmapi.HealthCheckSpec `json:"healthChecker"` + + // Monitor is used monitor database instance + // +optional + Monitor *mona.AgentSpec `json:"monitor,omitempty"` } // InternalAuthentication provides different way of endpoint authentication diff --git a/apis/kubedb/v1alpha2/openapi_generated.go b/apis/kubedb/v1alpha2/openapi_generated.go index bb77c0167e..d5990d1dbe 100644 --- a/apis/kubedb/v1alpha2/openapi_generated.go +++ b/apis/kubedb/v1alpha2/openapi_generated.go @@ -667,6 +667,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.memcachedStatsService": schema_apimachinery_apis_kubedb_v1alpha2_memcachedStatsService(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.mongoDBApp": schema_apimachinery_apis_kubedb_v1alpha2_mongoDBApp(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.mongoDBStatsService": schema_apimachinery_apis_kubedb_v1alpha2_mongoDBStatsService(ref), + "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.mssqlserverStatsService": schema_apimachinery_apis_kubedb_v1alpha2_mssqlserverStatsService(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.mysqlApp": schema_apimachinery_apis_kubedb_v1alpha2_mysqlApp(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.mysqlStatsService": schema_apimachinery_apis_kubedb_v1alpha2_mysqlStatsService(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.perconaXtraDBApp": schema_apimachinery_apis_kubedb_v1alpha2_perconaXtraDBApp(ref), @@ -28752,12 +28753,18 @@ func schema_apimachinery_apis_kubedb_v1alpha2_MSSQLServerSpec(ref common.Referen Ref: ref("kmodules.xyz/client-go/api/v1.HealthCheckSpec"), }, }, + "monitor": { + SchemaProps: spec.SchemaProps{ + Description: "Monitor is used monitor database instance", + Ref: ref("kmodules.xyz/monitoring-agent-api/api/v1.AgentSpec"), + }, + }, }, Required: []string{"version"}, }, }, Dependencies: []string{ - "k8s.io/api/core/v1.PersistentVolumeClaimSpec", "kmodules.xyz/client-go/api/v1.HealthCheckSpec", "kmodules.xyz/offshoot-api/api/v2.PodTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.CoordinatorSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.InitSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.InternalAuthentication", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MSSQLServerLeaderElectionConfig", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MSSQLServerTopology", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.NamedServiceTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SQLServerTLSConfig", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SecretReference"}, + "k8s.io/api/core/v1.PersistentVolumeClaimSpec", "kmodules.xyz/client-go/api/v1.HealthCheckSpec", "kmodules.xyz/monitoring-agent-api/api/v1.AgentSpec", "kmodules.xyz/offshoot-api/api/v2.PodTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.CoordinatorSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.InitSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.InternalAuthentication", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MSSQLServerLeaderElectionConfig", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MSSQLServerTopology", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.NamedServiceTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SQLServerTLSConfig", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SecretReference"}, } } @@ -34838,6 +34845,26 @@ func schema_apimachinery_apis_kubedb_v1alpha2_mongoDBStatsService(ref common.Ref } } +func schema_apimachinery_apis_kubedb_v1alpha2_mssqlserverStatsService(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "MSSQLServer": { + SchemaProps: spec.SchemaProps{ + Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MSSQLServer"), + }, + }, + }, + Required: []string{"MSSQLServer"}, + }, + }, + Dependencies: []string{ + "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MSSQLServer"}, + } +} + func schema_apimachinery_apis_kubedb_v1alpha2_mysqlApp(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/apis/kubedb/v1alpha2/zz_generated.deepcopy.go b/apis/kubedb/v1alpha2/zz_generated.deepcopy.go index 115171a022..c6e67b16cb 100644 --- a/apis/kubedb/v1alpha2/zz_generated.deepcopy.go +++ b/apis/kubedb/v1alpha2/zz_generated.deepcopy.go @@ -2182,6 +2182,11 @@ func (in *MSSQLServerSpec) DeepCopyInto(out *MSSQLServerSpec) { (*in).DeepCopyInto(*out) } in.HealthChecker.DeepCopyInto(&out.HealthChecker) + if in.Monitor != nil { + in, out := &in.Monitor, &out.Monitor + *out = new(monitoringagentapiapiv1.AgentSpec) + (*in).DeepCopyInto(*out) + } return } diff --git a/crds/catalog.kubedb.com_mssqlserverversions.yaml b/crds/catalog.kubedb.com_mssqlserverversions.yaml index af8a50990e..c0d686a554 100644 --- a/crds/catalog.kubedb.com_mssqlserverversions.yaml +++ b/crds/catalog.kubedb.com_mssqlserverversions.yaml @@ -61,6 +61,13 @@ spec: type: object deprecated: type: boolean + exporter: + properties: + image: + type: string + required: + - image + type: object initContainer: properties: image: @@ -151,6 +158,7 @@ spec: type: string required: - db + - exporter - initContainer - version type: object diff --git a/crds/kubedb.com_mssqlservers.yaml b/crds/kubedb.com_mssqlservers.yaml index 2d5bb0fa6e..69448c4b74 100644 --- a/crds/kubedb.com_mssqlservers.yaml +++ b/crds/kubedb.com_mssqlservers.yaml @@ -1321,6 +1321,207 @@ spec: default: 60s type: string type: object + monitor: + properties: + agent: + enum: + - prometheus.io/operator + - prometheus.io + - prometheus.io/builtin + type: string + prometheus: + properties: + exporter: + properties: + args: + items: + type: string + type: array + env: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: + properties: + key: + type: string + name: + default: "" + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + properties: + containerName: + type: string + divisor: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + properties: + key: + type: string + name: + default: "" + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + port: + default: 56790 + format: int32 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + securityContext: + properties: + allowPrivilegeEscalation: + type: boolean + appArmorProfile: + properties: + localhostProfile: + type: string + type: + type: string + required: + - type + type: object + capabilities: + properties: + add: + items: + type: string + type: array + x-kubernetes-list-type: atomic + drop: + items: + type: string + type: array + x-kubernetes-list-type: atomic + type: object + privileged: + type: boolean + procMount: + type: string + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + required: + - type + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + type: object + type: object + type: object + serviceMonitor: + properties: + interval: + type: string + labels: + additionalProperties: + type: string + type: object + type: object + type: object + type: object podTemplate: properties: controller: From 9cb2a307683a1d4c018433e5a2923e9635c06032 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Thu, 1 Aug 2024 23:55:52 -0700 Subject: [PATCH 7/7] Update deps Signed-off-by: Tamal Saha --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/docker/docker/AUTHORS | 49 +++++++++++++++++-- .../docker/docker/pkg/homedir/homedir.go | 44 +++++++++++++++++ .../docker/pkg/homedir/homedir_others.go | 1 - .../docker/docker/pkg/homedir/homedir_unix.go | 37 ++------------ .../docker/pkg/homedir/homedir_windows.go | 24 ++------- vendor/modules.txt | 2 +- 8 files changed, 98 insertions(+), 65 deletions(-) create mode 100644 vendor/github.com/docker/docker/pkg/homedir/homedir.go diff --git a/go.mod b/go.mod index 131cea1772..19218def28 100644 --- a/go.mod +++ b/go.mod @@ -82,7 +82,7 @@ require ( github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/docker/cli v24.0.9+incompatible // indirect github.com/docker/distribution v2.8.2+incompatible // indirect - github.com/docker/docker v24.0.9+incompatible // indirect + github.com/docker/docker v25.0.6+incompatible // indirect github.com/docker/docker-credential-helpers v0.7.0 // indirect github.com/emicklei/go-restful/v3 v3.12.1 // indirect github.com/evanphx/json-patch/v5 v5.9.0 // indirect diff --git a/go.sum b/go.sum index f1e850795d..7122dcc812 100644 --- a/go.sum +++ b/go.sum @@ -96,8 +96,8 @@ github.com/docker/cli v24.0.9+incompatible h1:OxbimnP/z+qVjDLpq9wbeFU3Nc30XhSe+L github.com/docker/cli v24.0.9+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v24.0.9+incompatible h1:HPGzNmwfLZWdxHqK9/II92pyi1EpYKsAqcl4G0Of9v0= -github.com/docker/docker v24.0.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v25.0.6+incompatible h1:5cPwbwriIcsua2REJe8HqQV+6WlWc1byg2QSXzBxBGg= +github.com/docker/docker v25.0.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= diff --git a/vendor/github.com/docker/docker/AUTHORS b/vendor/github.com/docker/docker/AUTHORS index b314181925..48d04f9a98 100644 --- a/vendor/github.com/docker/docker/AUTHORS +++ b/vendor/github.com/docker/docker/AUTHORS @@ -27,6 +27,7 @@ Adam Miller Adam Mills Adam Pointer Adam Singer +Adam Thornton Adam Walz Adam Williams AdamKorcz @@ -173,6 +174,7 @@ Andy Rothfusz Andy Smith Andy Wilson Andy Zhang +Aneesh Kulkarni Anes Hasicic Angel Velazquez Anil Belur @@ -236,6 +238,7 @@ Ben Golub Ben Gould Ben Hall Ben Langfeld +Ben Lovy Ben Sargent Ben Severson Ben Toews @@ -262,7 +265,7 @@ Billy Ridgway Bily Zhang Bin Liu Bingshen Wang -Bjorn Neergaard +Bjorn Neergaard Blake Geno Boaz Shuster bobby abbott @@ -279,6 +282,7 @@ Brandon Liu Brandon Philips Brandon Rhodes Brendan Dixon +Brennan Kinney <5098581+polarathene@users.noreply.github.com> Brent Salisbury Brett Higgins Brett Kochendorfer @@ -363,6 +367,7 @@ chenyuzhu Chetan Birajdar Chewey Chia-liang Kao +Chiranjeevi Tirunagari chli Cholerae Hu Chris Alfonso @@ -433,8 +438,8 @@ Cristian Staretu cristiano balducci Cristina Yenyxe Gonzalez Garcia Cruceru Calin-Cristian +cui fliter CUI Wei -cuishuang Cuong Manh Le Cyprian Gracz Cyril F @@ -513,6 +518,7 @@ David Dooling David Gageot David Gebler David Glasser +David Karlsson <35727626+dvdksn@users.noreply.github.com> David Lawrence David Lechner David M. Karr @@ -602,6 +608,7 @@ Donald Huang Dong Chen Donghwa Kim Donovan Jones +Dorin Geman Doron Podoleanu Doug Davis Doug MacEachern @@ -636,6 +643,7 @@ Emily Rose Emir Ozer Eng Zer Jun Enguerran +Enrico Weigelt, metux IT consult Eohyung Lee epeterso er0k @@ -676,6 +684,7 @@ Evan Allrich Evan Carmi Evan Hazlett Evan Krall +Evan Lezar Evan Phoenix Evan Wies Evelyn Xu @@ -744,6 +753,7 @@ Frank Groeneveld Frank Herrmann Frank Macreery Frank Rosquin +Frank Villaro-Dixon Frank Yang Fred Lifton Frederick F. Kautz IV @@ -983,6 +993,7 @@ Jean Rouge Jean-Baptiste Barth Jean-Baptiste Dalido Jean-Christophe Berthon +Jean-Michel Rouet Jean-Paul Calderone Jean-Pierre Huynh Jean-Tiare Le Bigot @@ -1013,6 +1024,7 @@ Jeroen Jacobs Jesse Dearing Jesse Dubay Jessica Frazelle +Jeyanthinath Muthuram Jezeniel Zapanta Jhon Honce Ji.Zhilong @@ -1141,6 +1153,7 @@ junxu Jussi Nummelin Justas Brazauskas Justen Martin +Justin Chadwell Justin Cormack Justin Force Justin Keller <85903732+jk-vb@users.noreply.github.com> @@ -1183,6 +1196,7 @@ Ke Xu Kei Ohmura Keith Hudgins Keli Hu +Ken Bannister Ken Cochrane Ken Herner Ken ICHIKAWA @@ -1192,7 +1206,7 @@ Kenjiro Nakayama Kent Johnson Kenta Tada Kevin "qwazerty" Houdebert -Kevin Alvarez +Kevin Alvarez Kevin Burke Kevin Clark Kevin Feyrer @@ -1225,6 +1239,7 @@ Konstantin Gribov Konstantin L Konstantin Pelykh Kostadin Plachkov +kpcyrd Krasi Georgiev Krasimir Georgiev Kris-Mikael Krister @@ -1306,6 +1321,7 @@ Lorenzo Fontana Lotus Fenn Louis Delossantos Louis Opter +Luboslav Pivarc Luca Favatella Luca Marturana Luca Orlandi @@ -1344,6 +1360,7 @@ Manuel Meurer Manuel Rüger Manuel Woelker mapk0y +Marat Radchenko Marc Abramowitz Marc Kuo Marc Tamsky @@ -1383,6 +1400,7 @@ Martijn van Oosterhout Martin Braun Martin Dojcak Martin Honermeyer +Martin Jirku Martin Kelly Martin Mosegaard Amdisen Martin Muzatko @@ -1461,6 +1479,7 @@ Michael Holzheu Michael Hudson-Doyle Michael Huettermann Michael Irwin +Michael Kebe Michael Kuehn Michael Käufl Michael Neale @@ -1509,10 +1528,11 @@ Mike Lundy Mike MacCana Mike Naberezny Mike Snitzer +Mike Sul mikelinjie <294893458@qq.com> Mikhail Sobolev Miklos Szegedi -Milas Bowman +Milas Bowman Milind Chawre Miloslav Trmač mingqing @@ -1524,6 +1544,7 @@ mlarcher Mohammad Banikazemi Mohammad Nasirifar Mohammed Aaqib Ansari +Mohd Sadiq Mohit Soni Moorthy RS Morgan Bauer @@ -1606,6 +1627,7 @@ Noah Treuhaft NobodyOnSE noducks Nolan Darilek +Nolan Miles Noriki Nakamura nponeccop Nurahmadie @@ -1661,6 +1683,7 @@ Paul Lietar Paul Liljenberg Paul Morie Paul Nasrat +Paul Seiffert Paul Weaver Paulo Gomes Paulo Ribeiro @@ -1674,6 +1697,7 @@ Pavlos Ratis Pavol Vargovcik Pawel Konczalski Paweł Gronowski +payall4u Peeyush Gupta Peggy Li Pei Su @@ -1703,7 +1727,9 @@ Phil Estes Phil Sphicas Phil Spitler Philip Alexander Etling +Philip K. Warren Philip Monroe +Philipp Fruck Philipp Gillé Philipp Wahala Philipp Weissensteiner @@ -1741,6 +1767,7 @@ Quentin Brossard Quentin Perez Quentin Tayssier r0n22 +Rachit Sharma Radostin Stoyanov Rafal Jeczalik Rafe Colton @@ -1773,6 +1800,7 @@ Rich Horwood Rich Moyse Rich Seymour Richard Burnison +Richard Hansen Richard Harvey Richard Mathie Richard Metzler @@ -1788,6 +1816,7 @@ Ritesh H Shukla Riyaz Faizullabhoy Rob Cowsill <42620235+rcowsill@users.noreply.github.com> Rob Gulewich +Rob Murray Rob Vesse Robert Bachmann Robert Bittle @@ -1869,6 +1898,7 @@ ryancooper7 RyanDeng Ryo Nakao Ryoga Saito +Régis Behmo Rémy Greinhofer s. rannou Sabin Basyal @@ -1885,6 +1915,7 @@ Sam J Sharpe Sam Neirinck Sam Reis Sam Rijs +Sam Thibault Sam Whited Sambuddha Basu Sami Wagiaalla @@ -1908,6 +1939,7 @@ Satoshi Tagomori Scott Bessler Scott Collier Scott Johnston +Scott Moser Scott Percival Scott Stamp Scott Walls @@ -1923,6 +1955,7 @@ Sebastiaan van Steenis Sebastiaan van Stijn Sebastian Höffner Sebastian Radloff +Sebastian Thomschke Sebastien Goasguen Senthil Kumar Selvaraj Senthil Kumaran @@ -1996,6 +2029,7 @@ Stanislav Bondarenko Stanislav Levin Steeve Morin Stefan Berger +Stefan Gehrig Stefan J. Wernli Stefan Praszalowicz Stefan S. @@ -2003,6 +2037,7 @@ Stefan Scherer Stefan Staudenmeyer Stefan Weil Steffen Butzer +Stephan Henningsen Stephan Spindler Stephen Benjamin Stephen Crosby @@ -2204,6 +2239,7 @@ Vinod Kulkarni Vishal Doshi Vishnu Kannan Vitaly Ostrosablin +Vitor Anjos Vitor Monteiro Vivek Agarwal Vivek Dasgupta @@ -2250,6 +2286,7 @@ Wenxuan Zhao Wenyu You <21551128@zju.edu.cn> Wenzhi Liang Wes Morgan +Wesley Pettit Wewang Xiaorenfine Wiktor Kwapisiewicz Will Dietz @@ -2289,7 +2326,7 @@ xiekeyang Ximo Guanter Gonzálbez xin.li Xinbo Weng -Xinfeng Liu +Xinfeng Liu Xinzi Zhou Xiuming Chen Xuecong Liao @@ -2355,6 +2392,7 @@ Zen Lin(Zhinan Lin) Zhang Kun Zhang Wei Zhang Wentao +zhangguanzhang ZhangHang zhangxianwei Zhenan Ye <21551168@zju.edu.cn> @@ -2381,6 +2419,7 @@ Zuhayr Elahi Zunayed Ali Álvaro Lázaro Átila Camurça Alves +吴小白 <296015668@qq.com> 尹吉峰 屈骏 徐俊杰 diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir.go b/vendor/github.com/docker/docker/pkg/homedir/homedir.go new file mode 100644 index 0000000000..590683206c --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/homedir/homedir.go @@ -0,0 +1,44 @@ +package homedir + +import ( + "os" + "os/user" + "runtime" +) + +// Key returns the env var name for the user's home dir based on +// the platform being run on. +// +// Deprecated: this function is no longer used, and will be removed in the next release. +func Key() string { + return envKeyName +} + +// Get returns the home directory of the current user with the help of +// environment variables depending on the target operating system. +// Returned path should be used with "path/filepath" to form new paths. +// +// On non-Windows platforms, it falls back to nss lookups, if the home +// directory cannot be obtained from environment-variables. +// +// If linking statically with cgo enabled against glibc, ensure the +// osusergo build tag is used. +// +// If needing to do nss lookups, do not disable cgo or set osusergo. +func Get() string { + home, _ := os.UserHomeDir() + if home == "" && runtime.GOOS != "windows" { + if u, err := user.Current(); err == nil { + return u.HomeDir + } + } + return home +} + +// GetShortcutString returns the string that is shortcut to user's home directory +// in the native shell of the platform running on. +// +// Deprecated: this function is no longer used, and will be removed in the next release. +func GetShortcutString() string { + return homeShortCut +} diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go b/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go index 11f1bec985..4eeb26b5dc 100644 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go +++ b/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go @@ -1,5 +1,4 @@ //go:build !linux -// +build !linux package homedir // import "github.com/docker/docker/pkg/homedir" diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go b/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go index d1732dee52..feae4d736c 100644 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go +++ b/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go @@ -1,39 +1,8 @@ //go:build !windows -// +build !windows package homedir // import "github.com/docker/docker/pkg/homedir" -import ( - "os" - "os/user" +const ( + envKeyName = "HOME" + homeShortCut = "~" ) - -// Key returns the env var name for the user's home dir based on -// the platform being run on -func Key() string { - return "HOME" -} - -// Get returns the home directory of the current user with the help of -// environment variables depending on the target operating system. -// Returned path should be used with "path/filepath" to form new paths. -// -// If linking statically with cgo enabled against glibc, ensure the -// osusergo build tag is used. -// -// If needing to do nss lookups, do not disable cgo or set osusergo. -func Get() string { - home := os.Getenv(Key()) - if home == "" { - if u, err := user.Current(); err == nil { - return u.HomeDir - } - } - return home -} - -// GetShortcutString returns the string that is shortcut to user's home directory -// in the native shell of the platform running on. -func GetShortcutString() string { - return "~" -} diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go b/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go index 2f81813b28..37f4ee6701 100644 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go +++ b/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go @@ -1,24 +1,6 @@ package homedir // import "github.com/docker/docker/pkg/homedir" -import ( - "os" +const ( + envKeyName = "USERPROFILE" + homeShortCut = "%USERPROFILE%" // be careful while using in format functions ) - -// Key returns the env var name for the user's home dir based on -// the platform being run on -func Key() string { - return "USERPROFILE" -} - -// Get returns the home directory of the current user with the help of -// environment variables depending on the target operating system. -// Returned path should be used with "path/filepath" to form new paths. -func Get() string { - return os.Getenv(Key()) -} - -// GetShortcutString returns the string that is shortcut to user's home directory -// in the native shell of the platform running on. -func GetShortcutString() string { - return "%USERPROFILE%" // be careful while using in format functions -} diff --git a/vendor/modules.txt b/vendor/modules.txt index c13cfb5490..54566cbc69 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -196,7 +196,7 @@ github.com/docker/cli/cli/config/types # github.com/docker/distribution v2.8.2+incompatible ## explicit github.com/docker/distribution/registry/client/auth/challenge -# github.com/docker/docker v24.0.9+incompatible +# github.com/docker/docker v25.0.6+incompatible ## explicit github.com/docker/docker/pkg/homedir # github.com/docker/docker-credential-helpers v0.7.0