From e8210401d4958f8db4d1d4d25f5c2ff6acb75b7e Mon Sep 17 00:00:00 2001 From: sabbir-hossain70 <103355337+sabbir-hossain70@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:07:16 +0600 Subject: [PATCH] Update Cassandra/client.go (#143) Signed-off-by: Sabbir --- cassandra/client.go | 71 +++---- cassandra/kubedb_client_builder.go | 10 +- go.mod | 2 +- go.sum | 4 +- .../v1alpha1/cassandra_version_types.go | 8 + .../catalog/v1alpha1/openapi_generated.go | 33 ++- .../catalog/v1alpha1/zz_generated.deepcopy.go | 17 ++ .../apimachinery/apis/kubedb/constants.go | 5 +- .../apis/kubedb/v1alpha2/cassandra_helpers.go | 91 +++++++- .../apis/kubedb/v1alpha2/cassandra_types.go | 5 + .../apis/kubedb/v1alpha2/cassandra_webhook.go | 5 +- .../kubedb/v1alpha2/mssqlserver_helpers.go | 10 +- .../apis/kubedb/v1alpha2/openapi_generated.go | 29 ++- .../kubedb/v1alpha2/zz_generated.deepcopy.go | 26 +++ ...ing.kubedb.com_mssqlserverautoscalers.yaml | 2 - .../catalog.kubedb.com_cassandraversions.yaml | 8 + .../crds/kubedb.com_cassandras.yaml | 201 ++++++++++++++++++ .../ops.kubedb.com_pgbounceropsrequests.yaml | 16 +- .../crds/postgres.kubedb.com_publishers.yaml | 16 +- .../crds/postgres.kubedb.com_subscribers.yaml | 16 +- .../ui.kubedb.com_databaseconnections.yaml | 3 + vendor/modules.txt | 2 +- 22 files changed, 484 insertions(+), 96 deletions(-) diff --git a/cassandra/client.go b/cassandra/client.go index 09dd5912..eb137072 100644 --- a/cassandra/client.go +++ b/cassandra/client.go @@ -2,12 +2,10 @@ package cassandra import ( "fmt" - "log" - - "k8s.io/klog/v2" - health "kmodules.xyz/client-go/tools/healthchecker" + "time" "github.com/gocql/gocql" + "k8s.io/klog/v2" ) type Client struct { @@ -16,78 +14,73 @@ type Client struct { // CreateKeyspace creates a keyspace func (c *Client) CreateKeyspace() error { - return c.Query(`CREATE KEYSPACE IF NOT EXISTS mykeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '2'}`).Exec() + return c.Query(`CREATE KEYSPACE IF NOT EXISTS kubedb_keyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '2'}`).Exec() } // CreateTable creates a table func (c *Client) CreateTable() error { - return c.Query(`CREATE TABLE IF NOT EXISTS mykeyspace.users ( - id UUID PRIMARY KEY, - name TEXT, - age INT, - email TEXT + return c.Query(`CREATE TABLE IF NOT EXISTS kubedb_keyspace.healthcheck_table ( + name TEXT PRIMARY KEY, + product TEXT )`).Exec() } -// InsertUser inserts a user into the table -func (c *Client) InsertUser(id gocql.UUID, name string, age int, email string) error { - return c.Query(`INSERT INTO mykeyspace.users (id, name, age, email) VALUES (?, ?, ?, ?)`, - id, name, age, email).Exec() -} +// UpdateData updates a record in the table +func (c *Client) UpdateData(name string, product string) error { + currentTime := time.Now().Format("2006-01-02 15:04:05") + updatedProduct := fmt.Sprintf("%s - %s", product, currentTime) -func (c *Client) DeleteUser(id gocql.UUID) error { - return c.Query(`DELETE FROM mykeyspace.users WHERE id = ?`, id).Exec() + return c.Query(`UPDATE kubedb_keyspace.healthcheck_table SET product = ? where name = ? `, + updatedProduct, name).Exec() } -// QueryUser queries a user by ID -func (c *Client) QueryUser(id gocql.UUID) (string, int, string, error) { - var name string - var age int - var email string +// queries a Data by ID +func (c *Client) QueryData(name string) error { + var product string - iter := c.Query(`SELECT name, age, email FROM mykeyspace.users WHERE id = ?`, id).Iter() - if iter.Scan(&name, &age, &email) { + iter := c.Query(`SELECT product FROM kubedb_keyspace.healthcheck_table WHERE name = ?`, name).Iter() + if iter.Scan(&product) { if err := iter.Close(); err != nil { - return "", 0, "", fmt.Errorf("unable to query data: %v", err) + return fmt.Errorf("unable to query data: %v", err) } - return name, age, email, nil + return nil } - return "", 0, "", fmt.Errorf("no data found") + return fmt.Errorf("no data found") } func (c *Client) CheckDbReadWrite() error { if err := c.CreateKeyspace(); err != nil { - log.Fatal("Unable to create keyspace:", err) + klog.Error("Unable to create keyspace:", err) + return err } if err := c.CreateTable(); err != nil { - log.Fatal("Unable to create table:", err) + klog.Error("Unable to create table:", err) + return err } - id := gocql.TimeUUID() - if err := c.InsertUser(id, "John Doe", 30, "john.doe@example.com"); err != nil { - log.Fatal("Unable to insert data:", err) + if err := c.UpdateData("Appscode", "KubeDB"); err != nil { + klog.Error("Unable to update data:", err) + return err } - name, age, email, err := c.QueryUser(id) + err := c.QueryData("Appscode") if err != nil { + klog.Error("Unable to query data:", err) return err } - klog.Infoln("DB Read Write Successful") - fmt.Printf("Name: %s, Age: %d, Email: %s\n", name, age, email) - err = c.DeleteUser(id) - return err + return nil } func (c *Client) PingCassandra() error { query := c.Query("SELECT now() FROM system.local") if err := query.Exec(); err != nil { + klog.Error("Unable to ping cassandra:", err) return err } return nil } -func (c *Client) CloseCassandraClient(hcf *health.HealthCard) { +func (c *Client) CloseCassandraClient() { if c != nil { c.Close() } - hcf.ClientClosed() } diff --git a/cassandra/kubedb_client_builder.go b/cassandra/kubedb_client_builder.go index 73ca46b5..414c8742 100644 --- a/cassandra/kubedb_client_builder.go +++ b/cassandra/kubedb_client_builder.go @@ -45,8 +45,8 @@ func (o *KubeDBClientBuilder) WithContext(ctx context.Context) *KubeDBClientBuil o.ctx = ctx return o } -func (o *KubeDBClientBuilder) GetCassandraClient(dns string) (*Client, error) { - host := dns +func (o *KubeDBClientBuilder) GetCassandraClient() (*Client, error) { + host := o.url cluster := gocql.NewCluster(host) cluster.Port = kubedb.CassandraNativeTcpPort cluster.Keyspace = "system" @@ -56,15 +56,11 @@ func (o *KubeDBClientBuilder) GetCassandraClient(dns string) (*Client, error) { cluster.Consistency = gocql.Quorum } if !o.db.Spec.DisableSecurity { - if o.db.Spec.AuthSecret == nil { - klog.Error("AuthSecret not set") - return nil, errors.New("auth-secret is not set") - } authSecret := &core.Secret{} err := o.kc.Get(o.ctx, types.NamespacedName{ Namespace: o.db.Namespace, - Name: o.db.Spec.AuthSecret.Name, + Name: o.db.GetAuthSecretName(), }, authSecret) if err != nil { if kerr.IsNotFound(err) { diff --git a/go.mod b/go.mod index 53e29b68..d7144d02 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( k8s.io/klog/v2 v2.130.1 kmodules.xyz/client-go v0.30.28 kmodules.xyz/custom-resources v0.30.0 - kubedb.dev/apimachinery v0.48.1-0.20241031104503-a7bc124e382b + kubedb.dev/apimachinery v0.48.1-0.20241101074809-3a305bf59ab1 sigs.k8s.io/controller-runtime v0.18.4 xorm.io/xorm v1.3.6 ) diff --git a/go.sum b/go.sum index 6d10aac1..2c9ce916 100644 --- a/go.sum +++ b/go.sum @@ -804,8 +804,8 @@ kmodules.xyz/monitoring-agent-api v0.30.2 h1:sAgz5P5EXZqhlj1NzJ+QltAgeIx5bGSMj+a kmodules.xyz/monitoring-agent-api v0.30.2/go.mod h1:BoZFPDDRB7J39CcUsSDlzgW8PQCwik4ILPleyUob+Mg= kmodules.xyz/offshoot-api v0.30.1 h1:TrulAYO+oBsXe9sZZGTmNWIuI8qD2izMpgcTSPvgAmI= kmodules.xyz/offshoot-api v0.30.1/go.mod h1:T3mpjR6fui0QzOcmQvIuANytW48fe9ytmy/1cgx6D4g= -kubedb.dev/apimachinery v0.48.1-0.20241031104503-a7bc124e382b h1:4XiqS+WHcF21LkS0Fcsvn3F5y+PhX8oMKBAD3dh4zzg= -kubedb.dev/apimachinery v0.48.1-0.20241031104503-a7bc124e382b/go.mod h1:NCiS4uS+F8DUyU9/tUQO3wqyNRNf0busab5/0Q2nYA0= +kubedb.dev/apimachinery v0.48.1-0.20241101074809-3a305bf59ab1 h1:wSfneVFQ57FYIpV+XHA3xsfi8cCr4fWUSKetlI9AlIM= +kubedb.dev/apimachinery v0.48.1-0.20241101074809-3a305bf59ab1/go.mod h1:NCiS4uS+F8DUyU9/tUQO3wqyNRNf0busab5/0Q2nYA0= kubeops.dev/petset v0.0.7 h1:F77BTRfUqRVO7kNc8q2oFSSviDmYBqni/osXqu0kgJ4= kubeops.dev/petset v0.0.7/go.mod h1:lt0SZV4ohRy7RiwLNUnMoauG4lCbcRbSqhMg20rdUQg= lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= diff --git a/vendor/kubedb.dev/apimachinery/apis/catalog/v1alpha1/cassandra_version_types.go b/vendor/kubedb.dev/apimachinery/apis/catalog/v1alpha1/cassandra_version_types.go index 7d5a4c01..c9e03bdf 100644 --- a/vendor/kubedb.dev/apimachinery/apis/catalog/v1alpha1/cassandra_version_types.go +++ b/vendor/kubedb.dev/apimachinery/apis/catalog/v1alpha1/cassandra_version_types.go @@ -60,6 +60,9 @@ type CassandraVersionSpec struct { // Database Image DB CassandraVersionDatabase `json:"db"` + // Exporter Image + Exporter CassandraVersionExporter `json:"exporter"` + // Database Image InitContainer CassandraInitContainer `json:"initContainer"` @@ -71,6 +74,11 @@ type CassandraVersionSpec struct { UI []ChartInfo `json:"ui,omitempty"` } +// CassandraVersionExporter is the image for the Cassandra exporter +type CassandraVersionExporter struct { + Image string `json:"image"` +} + // CassandraVersionDatabase is the Cassandra Database image type CassandraVersionDatabase struct { Image string `json:"image"` diff --git a/vendor/kubedb.dev/apimachinery/apis/catalog/v1alpha1/openapi_generated.go b/vendor/kubedb.dev/apimachinery/apis/catalog/v1alpha1/openapi_generated.go index a2df12e5..17d3f843 100644 --- a/vendor/kubedb.dev/apimachinery/apis/catalog/v1alpha1/openapi_generated.go +++ b/vendor/kubedb.dev/apimachinery/apis/catalog/v1alpha1/openapi_generated.go @@ -498,6 +498,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraInitContainer": schema_apimachinery_apis_catalog_v1alpha1_CassandraInitContainer(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraVersion": schema_apimachinery_apis_catalog_v1alpha1_CassandraVersion(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraVersionDatabase": schema_apimachinery_apis_catalog_v1alpha1_CassandraVersionDatabase(ref), + "kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraVersionExporter": schema_apimachinery_apis_catalog_v1alpha1_CassandraVersionExporter(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraVersionList": schema_apimachinery_apis_catalog_v1alpha1_CassandraVersionList(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraVersionSpec": schema_apimachinery_apis_catalog_v1alpha1_CassandraVersionSpec(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraVersionStatus": schema_apimachinery_apis_catalog_v1alpha1_CassandraVersionStatus(ref), @@ -25681,6 +25682,27 @@ func schema_apimachinery_apis_catalog_v1alpha1_CassandraVersionDatabase(ref comm } } +func schema_apimachinery_apis_catalog_v1alpha1_CassandraVersionExporter(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "CassandraVersionExporter is the image for the Cassandra 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_CassandraVersionList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -25752,6 +25774,13 @@ func schema_apimachinery_apis_catalog_v1alpha1_CassandraVersionSpec(ref common.R Ref: ref("kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraVersionDatabase"), }, }, + "exporter": { + SchemaProps: spec.SchemaProps{ + Description: "Exporter Image", + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraVersionExporter"), + }, + }, "initContainer": { SchemaProps: spec.SchemaProps{ Description: "Database Image", @@ -25780,11 +25809,11 @@ func schema_apimachinery_apis_catalog_v1alpha1_CassandraVersionSpec(ref common.R }, }, }, - Required: []string{"version", "db", "initContainer"}, + Required: []string{"version", "db", "exporter", "initContainer"}, }, }, Dependencies: []string{ - "kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraInitContainer", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraVersionDatabase", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ChartInfo", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SecurityContext"}, + "kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraInitContainer", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraVersionDatabase", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.CassandraVersionExporter", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ChartInfo", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SecurityContext"}, } } diff --git a/vendor/kubedb.dev/apimachinery/apis/catalog/v1alpha1/zz_generated.deepcopy.go b/vendor/kubedb.dev/apimachinery/apis/catalog/v1alpha1/zz_generated.deepcopy.go index 56c3f13b..8d1ebcb3 100644 --- a/vendor/kubedb.dev/apimachinery/apis/catalog/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/kubedb.dev/apimachinery/apis/catalog/v1alpha1/zz_generated.deepcopy.go @@ -158,6 +158,22 @@ func (in *CassandraVersionDatabase) DeepCopy() *CassandraVersionDatabase { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CassandraVersionExporter) DeepCopyInto(out *CassandraVersionExporter) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CassandraVersionExporter. +func (in *CassandraVersionExporter) DeepCopy() *CassandraVersionExporter { + if in == nil { + return nil + } + out := new(CassandraVersionExporter) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CassandraVersionList) DeepCopyInto(out *CassandraVersionList) { *out = *in @@ -195,6 +211,7 @@ func (in *CassandraVersionList) DeepCopyObject() runtime.Object { func (in *CassandraVersionSpec) DeepCopyInto(out *CassandraVersionSpec) { *out = *in out.DB = in.DB + out.Exporter = in.Exporter out.InitContainer = in.InitContainer in.SecurityContext.DeepCopyInto(&out.SecurityContext) if in.UI != nil { diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/constants.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/constants.go index d738f9e4..bf945df8 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/constants.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/constants.go @@ -400,6 +400,7 @@ const ( MSSQLDatabasePort = 1433 MSSQLDatabaseMirroringEndpointPort = 5022 MSSQLCoordinatorPort = 2381 + MSSQLMonitoringDefaultServicePort = 9399 // environment variables EnvAcceptEula = "ACCEPT_EULA" @@ -1478,15 +1479,17 @@ const ( CassandraInterNodePort = 7000 CassandraInterNodeSslPort = 7001 CassandraJmxPort = 7199 + CassandraExporterPort = 8080 CassandraNativeTcpPortName = "cql" CassandraInterNodePortName = "internode" CassandraInterNodeSslPortName = "internode-ssl" CassandraJmxPortName = "jmx" + CassandraExporterPortName = "exporter" CassandraUserAdmin = "admin" - CassandraAuthCommand = "/usr/local/bin/docker-entrypoint.sh cassandra -f & /tmp/sc/cassandra-auth.sh" + CassandraAuthCommand = "/tmp/sc/cassandra-auth.sh" CassandraMetadataName = "metadata.name" CassandraMetadataNamespace = "metadata.namespace" CassandraStatusPodIP = "status.podIP" diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/cassandra_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/cassandra_helpers.go index ffb341f4..c9774862 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/cassandra_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/cassandra_helpers.go @@ -27,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" @@ -37,6 +38,7 @@ import ( meta_util "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" ) @@ -178,6 +180,73 @@ func (r *Cassandra) GetConnectionScheme() string { return scheme } +func (r *Cassandra) OffShootSelectors(extraSelectors ...map[string]string) map[string]string { + selector := map[string]string{ + meta_util.NameLabelKey: r.ResourceFQN(), + meta_util.InstanceLabelKey: r.Name, + meta_util.ManagedByLabelKey: kubedb.GroupName, + } + return meta_util.OverwriteKeys(selector, extraSelectors...) +} + +func (r *Cassandra) offShootLabels(selector, override map[string]string) map[string]string { + selector[meta_util.ComponentLabelKey] = kubedb.ComponentDatabase + return meta_util.FilterKeys(kubedb.GroupName, selector, meta_util.OverwriteKeys(nil, r.Labels, override)) +} + +func (r *Cassandra) OffShootLabels() map[string]string { + return r.offShootLabels(r.OffShootSelectors(), nil) +} + +func (r *Cassandra) ServiceLabels(alias ServiceAlias, extraLabels ...map[string]string) map[string]string { + svcTemplate := GetServiceTemplate(r.Spec.ServiceTemplates, alias) + return r.offShootLabels(meta_util.OverwriteKeys(r.OffShootSelectors(), extraLabels...), svcTemplate.Labels) +} + +func (r *Cassandra) OffShootName() string { + return r.Name +} + +type CassandraStatsService struct { + *Cassandra +} + +func (ks CassandraStatsService) TLSConfig() *promapi.TLSConfig { + return nil +} + +func (ks CassandraStatsService) GetNamespace() string { + return ks.Cassandra.GetNamespace() +} + +func (ks CassandraStatsService) ServiceName() string { + return ks.OffShootName() + "-stats" +} + +func (ks CassandraStatsService) ServiceMonitorName() string { + return ks.ServiceName() +} + +func (ks CassandraStatsService) ServiceMonitorAdditionalLabels() map[string]string { + return ks.OffshootLabels() +} + +func (ks CassandraStatsService) Path() string { + return kubedb.DefaultStatsPath +} + +func (ks CassandraStatsService) Scheme() string { + return "" +} + +func (r *Cassandra) StatsService() mona.StatsAccessor { + return &CassandraStatsService{r} +} + +func (r *Cassandra) StatsServiceLabels() map[string]string { + return r.ServiceLabels(StatsServiceAlias, map[string]string{kubedb.LabelRole: kubedb.RoleStats}) +} + func (r *Cassandra) SetHealthCheckerDefaults() { if r.Spec.HealthChecker.PeriodSeconds == nil { r.Spec.HealthChecker.PeriodSeconds = pointer.Int32P(30) @@ -203,17 +272,6 @@ func (r *Cassandra) SetDefaults() { r.Spec.DeletionPolicy = TerminationPolicyDelete } - if !r.Spec.DisableSecurity { - if r.Spec.AuthSecret == nil { - r.Spec.AuthSecret = &SecretReference{ - LocalObjectReference: core.LocalObjectReference{ - Name: r.DefaultUserCredSecretName(kubedb.CassandraUserAdmin), - }, - ExternallyManaged: false, - } - } - } - var casVersion catalog.CassandraVersion err := DefaultClient.Get(context.TODO(), types.NamespacedName{ Name: r.Spec.Version, @@ -274,6 +332,17 @@ func (r *Cassandra) SetDefaults() { } r.SetHealthCheckerDefaults() } + + r.Spec.Monitor.SetDefaults() + + if r.Spec.Monitor != nil && r.Spec.Monitor.Prometheus != nil { + if r.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { + r.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = casVersion.Spec.SecurityContext.RunAsUser + } + if r.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup == nil { + r.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup = casVersion.Spec.SecurityContext.RunAsUser + } + } } func (r *Cassandra) setDefaultContainerSecurityContext(csVersion *catalog.CassandraVersion, podTemplate *ofst.PodTemplateSpec) { diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/cassandra_types.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/cassandra_types.go index 5cf6a657..0ff02c71 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/cassandra_types.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/cassandra_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" ) @@ -90,6 +91,10 @@ type CassandraSpec struct { // +optional ServiceTemplates []NamedServiceTemplateSpec `json:"serviceTemplates,omitempty"` + // Monitor is used monitor database instance + // +optional + Monitor *mona.AgentSpec `json:"monitor,omitempty"` + // DeletionPolicy controls the delete operation for database // +optional DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/cassandra_webhook.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/cassandra_webhook.go index c85e1e89..a948bfa7 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/cassandra_webhook.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/cassandra_webhook.go @@ -230,10 +230,9 @@ func (c *Cassandra) validateClusterStorageType(rack RackSpec, allErr field.Error } func (r *Cassandra) ValidateVersion(db *Cassandra) error { - chVersion := catalog.CassandraVersion{} - err := DefaultClient.Get(context.TODO(), types.NamespacedName{Name: db.Spec.Version}, &chVersion) + casVersion := catalog.CassandraVersion{} + err := DefaultClient.Get(context.TODO(), types.NamespacedName{Name: db.Spec.Version}, &casVersion) if err != nil { - // fmt.Sprint(db.Spec.Version, "version not supported") return errors.New(fmt.Sprint("version ", db.Spec.Version, " not supported")) } return nil diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/mssqlserver_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/mssqlserver_helpers.go index b0aab5c9..d3747960 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/mssqlserver_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/mssqlserver_helpers.go @@ -379,8 +379,14 @@ func (m *MSSQLServer) SetDefaults() { m.setDefaultContainerResourceLimits(m.Spec.PodTemplate) - m.Spec.Monitor.SetDefaults() - if m.Spec.Monitor != nil && m.Spec.Monitor.Prometheus != nil { + if m.Spec.Monitor != nil { + if m.Spec.Monitor.Prometheus == nil { + m.Spec.Monitor.Prometheus = &mona.PrometheusSpec{} + } + if m.Spec.Monitor.Prometheus.Exporter.Port == 0 { + m.Spec.Monitor.Prometheus.Exporter.Port = kubedb.MSSQLMonitoringDefaultServicePort + } + m.Spec.Monitor.SetDefaults() if m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = mssqlVersion.Spec.SecurityContext.RunAsUser } diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/openapi_generated.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/openapi_generated.go index 142bff05..594eddfe 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/openapi_generated.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/openapi_generated.go @@ -501,6 +501,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.CassandraApp": schema_apimachinery_apis_kubedb_v1alpha2_CassandraApp(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.CassandraList": schema_apimachinery_apis_kubedb_v1alpha2_CassandraList(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.CassandraSpec": schema_apimachinery_apis_kubedb_v1alpha2_CassandraSpec(ref), + "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.CassandraStatsService": schema_apimachinery_apis_kubedb_v1alpha2_CassandraStatsService(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.CassandraStatus": schema_apimachinery_apis_kubedb_v1alpha2_CassandraStatus(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.ClickHouse": schema_apimachinery_apis_kubedb_v1alpha2_ClickHouse(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.ClickHouseKeeper": schema_apimachinery_apis_kubedb_v1alpha2_ClickHouseKeeper(ref), @@ -25888,6 +25889,12 @@ func schema_apimachinery_apis_kubedb_v1alpha2_CassandraSpec(ref common.Reference }, }, }, + "monitor": { + SchemaProps: spec.SchemaProps{ + Description: "Monitor is used monitor database instance", + Ref: ref("kmodules.xyz/monitoring-agent-api/api/v1.AgentSpec"), + }, + }, "deletionPolicy": { SchemaProps: spec.SchemaProps{ Description: "DeletionPolicy controls the delete operation for database", @@ -25907,7 +25914,27 @@ func schema_apimachinery_apis_kubedb_v1alpha2_CassandraSpec(ref common.Reference }, }, Dependencies: []string{ - "k8s.io/api/core/v1.LocalObjectReference", "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.NamedServiceTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SecretReference", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.Topology"}, + "k8s.io/api/core/v1.LocalObjectReference", "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.NamedServiceTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SecretReference", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.Topology"}, + } +} + +func schema_apimachinery_apis_kubedb_v1alpha2_CassandraStatsService(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "Cassandra": { + SchemaProps: spec.SchemaProps{ + Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1alpha2.Cassandra"), + }, + }, + }, + Required: []string{"Cassandra"}, + }, + }, + Dependencies: []string{ + "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.Cassandra"}, } } diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/zz_generated.deepcopy.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/zz_generated.deepcopy.go index 23f433f1..f3ecdcc6 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/zz_generated.deepcopy.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/zz_generated.deepcopy.go @@ -293,6 +293,11 @@ func (in *CassandraSpec) DeepCopyInto(out *CassandraSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.Monitor != nil { + in, out := &in.Monitor, &out.Monitor + *out = new(monitoringagentapiapiv1.AgentSpec) + (*in).DeepCopyInto(*out) + } in.HealthChecker.DeepCopyInto(&out.HealthChecker) return } @@ -307,6 +312,27 @@ func (in *CassandraSpec) DeepCopy() *CassandraSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CassandraStatsService) DeepCopyInto(out *CassandraStatsService) { + *out = *in + if in.Cassandra != nil { + in, out := &in.Cassandra, &out.Cassandra + *out = new(Cassandra) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CassandraStatsService. +func (in *CassandraStatsService) DeepCopy() *CassandraStatsService { + if in == nil { + return nil + } + out := new(CassandraStatsService) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CassandraStatus) DeepCopyInto(out *CassandraStatus) { *out = *in diff --git a/vendor/kubedb.dev/apimachinery/crds/autoscaling.kubedb.com_mssqlserverautoscalers.yaml b/vendor/kubedb.dev/apimachinery/crds/autoscaling.kubedb.com_mssqlserverautoscalers.yaml index 3d90d677..839b853b 100644 --- a/vendor/kubedb.dev/apimachinery/crds/autoscaling.kubedb.com_mssqlserverautoscalers.yaml +++ b/vendor/kubedb.dev/apimachinery/crds/autoscaling.kubedb.com_mssqlserverautoscalers.yaml @@ -107,8 +107,6 @@ spec: - IfReady - Always type: string - readinessCriteria: - type: object timeout: type: string type: object diff --git a/vendor/kubedb.dev/apimachinery/crds/catalog.kubedb.com_cassandraversions.yaml b/vendor/kubedb.dev/apimachinery/crds/catalog.kubedb.com_cassandraversions.yaml index 59bdb6b2..31fbd9d6 100644 --- a/vendor/kubedb.dev/apimachinery/crds/catalog.kubedb.com_cassandraversions.yaml +++ b/vendor/kubedb.dev/apimachinery/crds/catalog.kubedb.com_cassandraversions.yaml @@ -52,6 +52,13 @@ spec: required: - image type: object + exporter: + properties: + image: + type: string + required: + - image + type: object initContainer: properties: image: @@ -84,6 +91,7 @@ spec: type: string required: - db + - exporter - initContainer - version type: object diff --git a/vendor/kubedb.dev/apimachinery/crds/kubedb.com_cassandras.yaml b/vendor/kubedb.dev/apimachinery/crds/kubedb.com_cassandras.yaml index cc6a62ae..297e4fbc 100644 --- a/vendor/kubedb.dev/apimachinery/crds/kubedb.com_cassandras.yaml +++ b/vendor/kubedb.dev/apimachinery/crds/kubedb.com_cassandras.yaml @@ -97,6 +97,207 @@ spec: format: int32 type: integer 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: diff --git a/vendor/kubedb.dev/apimachinery/crds/ops.kubedb.com_pgbounceropsrequests.yaml b/vendor/kubedb.dev/apimachinery/crds/ops.kubedb.com_pgbounceropsrequests.yaml index d48f5bac..cbe5dca2 100644 --- a/vendor/kubedb.dev/apimachinery/crds/ops.kubedb.com_pgbounceropsrequests.yaml +++ b/vendor/kubedb.dev/apimachinery/crds/ops.kubedb.com_pgbounceropsrequests.yaml @@ -79,6 +79,13 @@ spec: required: - pgbouncer type: object + databaseRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic horizontalScaling: properties: replicas: @@ -87,13 +94,6 @@ spec: type: object restart: type: object - serverRef: - properties: - name: - default: "" - type: string - type: object - x-kubernetes-map-type: atomic timeout: type: string tls: @@ -298,7 +298,7 @@ spec: type: object type: object required: - - serverRef + - databaseRef - type type: object status: diff --git a/vendor/kubedb.dev/apimachinery/crds/postgres.kubedb.com_publishers.yaml b/vendor/kubedb.dev/apimachinery/crds/postgres.kubedb.com_publishers.yaml index 772c3611..8fe95cf8 100644 --- a/vendor/kubedb.dev/apimachinery/crds/postgres.kubedb.com_publishers.yaml +++ b/vendor/kubedb.dev/apimachinery/crds/postgres.kubedb.com_publishers.yaml @@ -111,6 +111,13 @@ spec: type: object databaseName: type: string + databaseRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic deletionPolicy: default: Delete enum: @@ -137,21 +144,14 @@ spec: type: object publishAllTables: type: boolean - serverRef: - properties: - name: - default: "" - type: string - type: object - x-kubernetes-map-type: atomic tables: items: type: string type: array required: - databaseName + - databaseRef - name - - serverRef type: object status: properties: diff --git a/vendor/kubedb.dev/apimachinery/crds/postgres.kubedb.com_subscribers.yaml b/vendor/kubedb.dev/apimachinery/crds/postgres.kubedb.com_subscribers.yaml index 9f6295d2..6f750520 100644 --- a/vendor/kubedb.dev/apimachinery/crds/postgres.kubedb.com_subscribers.yaml +++ b/vendor/kubedb.dev/apimachinery/crds/postgres.kubedb.com_subscribers.yaml @@ -41,6 +41,13 @@ spec: properties: databaseName: type: string + databaseRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic deletionPolicy: default: Delete enum: @@ -113,18 +120,11 @@ spec: - refs type: object type: object - serverRef: - properties: - name: - default: "" - type: string - type: object - x-kubernetes-map-type: atomic required: - databaseName + - databaseRef - name - publisher - - serverRef type: object status: properties: diff --git a/vendor/kubedb.dev/apimachinery/crds/ui.kubedb.com_databaseconnections.yaml b/vendor/kubedb.dev/apimachinery/crds/ui.kubedb.com_databaseconnections.yaml index 053c4742..29091f54 100644 --- a/vendor/kubedb.dev/apimachinery/crds/ui.kubedb.com_databaseconnections.yaml +++ b/vendor/kubedb.dev/apimachinery/crds/ui.kubedb.com_databaseconnections.yaml @@ -26,6 +26,9 @@ spec: type: object spec: properties: + caCert: + format: byte + type: string connectOptions: additionalProperties: type: string diff --git a/vendor/modules.txt b/vendor/modules.txt index 51a94779..0a8b32fa 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1564,7 +1564,7 @@ kmodules.xyz/offshoot-api/api/v1 kmodules.xyz/offshoot-api/api/v1/conversion kmodules.xyz/offshoot-api/api/v2 kmodules.xyz/offshoot-api/util -# kubedb.dev/apimachinery v0.48.1-0.20241031104503-a7bc124e382b +# kubedb.dev/apimachinery v0.48.1-0.20241101074809-3a305bf59ab1 ## explicit; go 1.22.1 kubedb.dev/apimachinery/apis kubedb.dev/apimachinery/apis/catalog