From cf969edcaf8d7cdec1b2a243c7f9cdb47cbf0ef8 Mon Sep 17 00:00:00 2001 From: 1gtm <1gtm@appscode.com> Date: Sat, 27 Jan 2024 02:35:51 +0000 Subject: [PATCH] Prepare for release v0.0.9 ProductLine: KubeDB Release: v2024.1.26-rc.0 Release-tracker: https://github.com/kubedb/CHANGELOG/pull/82 Signed-off-by: 1gtm <1gtm@appscode.com> --- go.mod | 6 +- go.sum | 11 +- vendor/github.com/go-sql-driver/mysql/AUTHORS | 2 + .../go-sql-driver/mysql/CHANGELOG.md | 13 ++ .../github.com/go-sql-driver/mysql/README.md | 4 +- .../go-sql-driver/mysql/connection.go | 4 +- .../github.com/go-sql-driver/mysql/const.go | 2 +- .../github.com/go-sql-driver/mysql/errors.go | 2 +- .../appcatalog/v1alpha1/appbinding_helpers.go | 16 +- .../apis/appcatalog/v1alpha1/mysql.go | 93 ++++++++++++ .../apis/elasticsearch/v1alpha1/constants.go | 8 +- .../apis/elasticsearch/v1alpha1/types.go | 6 +- .../kafka/v1alpha1/connect_cluster_helpers.go | 11 ++ .../kafka/v1alpha1/connect_cluster_webhook.go | 8 +- .../apis/kafka/v1alpha1/connector_webhook.go | 86 +++++++++++ .../apis/kubedb/v1alpha2/constants.go | 53 ++++++- .../apis/kubedb/v1alpha2/druid_helpers.go | 75 +++++----- .../apis/kubedb/v1alpha2/druid_types.go | 27 ++-- .../apis/kubedb/v1alpha2/druid_webhook.go | 47 +++--- .../kubedb/v1alpha2/elasticsearch_helpers.go | 9 +- .../apis/kubedb/v1alpha2/ferretdb_helpers.go | 72 ++++++++- .../apis/kubedb/v1alpha2/ferretdb_types.go | 13 +- .../apis/kubedb/v1alpha2/ferretdb_webhook.go | 35 +++-- .../apis/kubedb/v1alpha2/kafka_helpers.go | 20 ++- .../apis/kubedb/v1alpha2/mariadb_helpers.go | 12 +- .../apis/kubedb/v1alpha2/mysql_helpers.go | 11 +- .../apis/kubedb/v1alpha2/openapi_generated.go | 42 +++--- .../kubedb/v1alpha2/perconaxtradb_helpers.go | 11 +- .../apis/kubedb/v1alpha2/pgbouncer_helpers.go | 9 +- .../apis/kubedb/v1alpha2/pgpool_webhook.go | 4 +- .../apis/kubedb/v1alpha2/postgres_helpers.go | 12 +- .../apis/kubedb/v1alpha2/rabbitmq_helpers.go | 139 ++++++++++++++++-- .../apis/kubedb/v1alpha2/rabbitmq_webhook.go | 20 ++- .../apis/kubedb/v1alpha2/redis_helpers.go | 9 +- .../kubedb/v1alpha2/redis_sentinel_helpers.go | 9 +- .../apis/kubedb/v1alpha2/zookeeper_helpers.go | 2 +- .../apis/kubedb/v1alpha2/zookeeper_webhook.go | 5 +- .../kubedb/v1alpha2/zz_generated.deepcopy.go | 37 ++++- .../apimachinery/crds/kubedb.com_druids.yaml | 12 +- .../crds/kubedb.com_ferretdbs.yaml | 2 + vendor/modules.txt | 6 +- 41 files changed, 749 insertions(+), 216 deletions(-) create mode 100644 vendor/kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1/mysql.go create mode 100644 vendor/kubedb.dev/apimachinery/apis/kafka/v1alpha1/connector_webhook.go diff --git a/go.mod b/go.mod index 38a2511d1..732adeb7b 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/elastic/go-elasticsearch/v7 v7.15.1 github.com/elastic/go-elasticsearch/v8 v8.4.0 github.com/go-resty/resty/v2 v2.11.0 - github.com/go-sql-driver/mysql v1.7.0 + github.com/go-sql-driver/mysql v1.7.1 github.com/lib/pq v1.10.7 github.com/opensearch-project/opensearch-go v1.1.0 github.com/opensearch-project/opensearch-go/v2 v2.2.0 @@ -21,8 +21,8 @@ require ( k8s.io/apimachinery v0.29.0 k8s.io/klog/v2 v2.110.1 kmodules.xyz/client-go v0.29.6 - kmodules.xyz/custom-resources v0.29.0 - kubedb.dev/apimachinery v0.41.0-beta.1.0.20240124061503-ce4799bb0e5c + kmodules.xyz/custom-resources v0.29.1 + kubedb.dev/apimachinery v0.41.0-rc.0 sigs.k8s.io/controller-runtime v0.16.3 xorm.io/xorm v1.3.6 ) diff --git a/go.sum b/go.sum index 5ddd5cf3a..5de0e684e 100644 --- a/go.sum +++ b/go.sum @@ -98,8 +98,9 @@ github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogB github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-resty/resty/v2 v2.11.0 h1:i7jMfNOJYMp69lq7qozJP+bjgzfAzeOhuGlyDrqxT/8= github.com/go-resty/resty/v2 v2.11.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A= -github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= +github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= @@ -574,14 +575,14 @@ kmodules.xyz/apiversion v0.2.0 h1:vAQYqZFm4xu4pbB1cAdHbFEPES6EQkcR4wc06xdTOWk= kmodules.xyz/apiversion v0.2.0/go.mod h1:oPX8g8LvlPdPX3Yc5YvCzJHQnw3YF/X4/jdW0b1am80= kmodules.xyz/client-go v0.29.6 h1:xTVq5LZvsPBUTLY7PORq7zveLOj/vpuTDvkpHWOk3RM= kmodules.xyz/client-go v0.29.6/go.mod h1:pHuzpwzEcDUIGjVVvwz9N8lY+6A7HXwvs2d7NtK7Hho= -kmodules.xyz/custom-resources v0.29.0 h1:RaDM2+wSVXiwIvLqmkTVYpwoH83AC8wruXe2p2rOZNY= -kmodules.xyz/custom-resources v0.29.0/go.mod h1:MzZyXtxdg1PDxGk3RTTO1Xv3KiVqZnIonSwmxVbagOY= +kmodules.xyz/custom-resources v0.29.1 h1:xiNylhs3ILRbcUhxxy306AOy9GMA4Mq7xFIptZKgal4= +kmodules.xyz/custom-resources v0.29.1/go.mod h1:829zDY1EjaxPP52h1T73LZx/vgv8Pld9/uTT/ViZTc0= kmodules.xyz/monitoring-agent-api v0.29.0 h1:gpFl6OZrlMLb/ySMHdREI9EwGtnJ91oZBn9H1UFRwB4= kmodules.xyz/monitoring-agent-api v0.29.0/go.mod h1:iNbvaMTgVFOI5q2LJtGK91j4Dmjv4ZRiRdasGmWLKQI= kmodules.xyz/offshoot-api v0.29.0 h1:GHLhxxT9jU1N8+FvOCCeJNyU5g0duYS46UGrs6AHNLY= kmodules.xyz/offshoot-api v0.29.0/go.mod h1:5NxhBblXoDHWStx9HCDJR2KFTwYjEZ7i1Id3jelIunw= -kubedb.dev/apimachinery v0.41.0-beta.1.0.20240124061503-ce4799bb0e5c h1:QdnEBPdmd/Z3JOFJKMQ3nCFiJYiWxsuIAqMLgXep880= -kubedb.dev/apimachinery v0.41.0-beta.1.0.20240124061503-ce4799bb0e5c/go.mod h1:IqIwU4I/UfmcMi4X7G01M7XAEFUPehtiFAKZNKwH8Ek= +kubedb.dev/apimachinery v0.41.0-rc.0 h1:229M2WXAQ47ELuwkHCBXOAeDcrGX9lbSbMyk++esRlY= +kubedb.dev/apimachinery v0.41.0-rc.0/go.mod h1:DghpLFmqVyQX0kUcZRTbdV9omaxRwtw9IzdJsPqdqiI= lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= diff --git a/vendor/github.com/go-sql-driver/mysql/AUTHORS b/vendor/github.com/go-sql-driver/mysql/AUTHORS index 051327519..fb1478c3b 100644 --- a/vendor/github.com/go-sql-driver/mysql/AUTHORS +++ b/vendor/github.com/go-sql-driver/mysql/AUTHORS @@ -78,11 +78,13 @@ Olivier MenguĂ© oscarzhao Paul Bonser Peter Schultz +Phil Porada Rebecca Chin Reed Allman Richard Wilkes Robert Russell Runrioter Wung +Samantha Frank Santhosh Kumar Tekuri Sho Iizuka Sho Ikeda diff --git a/vendor/github.com/go-sql-driver/mysql/CHANGELOG.md b/vendor/github.com/go-sql-driver/mysql/CHANGELOG.md index 77024a820..5166e4adb 100644 --- a/vendor/github.com/go-sql-driver/mysql/CHANGELOG.md +++ b/vendor/github.com/go-sql-driver/mysql/CHANGELOG.md @@ -1,3 +1,16 @@ +## Version 1.7.1 (2023-04-25) + +Changes: + + - bump actions/checkout@v3 and actions/setup-go@v3 (#1375) + - Add go1.20 and mariadb10.11 to the testing matrix (#1403) + - Increase default maxAllowedPacket size. (#1411) + +Bugfixes: + + - Use SET syntax as specified in the MySQL documentation (#1402) + + ## Version 1.7 (2022-11-29) Changes: diff --git a/vendor/github.com/go-sql-driver/mysql/README.md b/vendor/github.com/go-sql-driver/mysql/README.md index 25de2e5aa..3b5d229aa 100644 --- a/vendor/github.com/go-sql-driver/mysql/README.md +++ b/vendor/github.com/go-sql-driver/mysql/README.md @@ -282,10 +282,10 @@ Please keep in mind, that param values must be [url.QueryEscape](https://golang. ##### `maxAllowedPacket` ``` Type: decimal number -Default: 4194304 +Default: 64*1024*1024 ``` -Max packet size allowed in bytes. The default value is 4 MiB and should be adjusted to match the server settings. `maxAllowedPacket=0` can be used to automatically fetch the `max_allowed_packet` variable from server *on every connection*. +Max packet size allowed in bytes. The default value is 64 MiB and should be adjusted to match the server settings. `maxAllowedPacket=0` can be used to automatically fetch the `max_allowed_packet` variable from server *on every connection*. ##### `multiStatements` diff --git a/vendor/github.com/go-sql-driver/mysql/connection.go b/vendor/github.com/go-sql-driver/mysql/connection.go index 9539077cb..947a883e3 100644 --- a/vendor/github.com/go-sql-driver/mysql/connection.go +++ b/vendor/github.com/go-sql-driver/mysql/connection.go @@ -71,10 +71,10 @@ func (mc *mysqlConn) handleParams() (err error) { cmdSet.Grow(4 + len(param) + 1 + len(val) + 30*(len(mc.cfg.Params)-1)) cmdSet.WriteString("SET ") } else { - cmdSet.WriteByte(',') + cmdSet.WriteString(", ") } cmdSet.WriteString(param) - cmdSet.WriteByte('=') + cmdSet.WriteString(" = ") cmdSet.WriteString(val) } } diff --git a/vendor/github.com/go-sql-driver/mysql/const.go b/vendor/github.com/go-sql-driver/mysql/const.go index b1e6b85ef..64e2bced6 100644 --- a/vendor/github.com/go-sql-driver/mysql/const.go +++ b/vendor/github.com/go-sql-driver/mysql/const.go @@ -10,7 +10,7 @@ package mysql const ( defaultAuthPlugin = "mysql_native_password" - defaultMaxAllowedPacket = 4 << 20 // 4 MiB + defaultMaxAllowedPacket = 64 << 20 // 64 MiB. See https://github.com/go-sql-driver/mysql/issues/1355 minProtocolVersion = 10 maxPacketSize = 1<<24 - 1 timeFormat = "2006-01-02 15:04:05.999999" diff --git a/vendor/github.com/go-sql-driver/mysql/errors.go b/vendor/github.com/go-sql-driver/mysql/errors.go index 7c037e7d6..ff9a8f088 100644 --- a/vendor/github.com/go-sql-driver/mysql/errors.go +++ b/vendor/github.com/go-sql-driver/mysql/errors.go @@ -27,7 +27,7 @@ var ( ErrOldProtocol = errors.New("MySQL server does not support required protocol 41+") ErrPktSync = errors.New("commands out of sync. You can't run this command now") ErrPktSyncMul = errors.New("commands out of sync. Did you run multiple statements at once?") - ErrPktTooLarge = errors.New("packet for query is too large. Try adjusting the 'max_allowed_packet' variable on the server") + ErrPktTooLarge = errors.New("packet for query is too large. Try adjusting the `Config.MaxAllowedPacket`") ErrBusyBuffer = errors.New("busy buffer") // errBadConnNoWrite is used for connection errors where nothing was sent to the database yet. diff --git a/vendor/kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1/appbinding_helpers.go b/vendor/kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1/appbinding_helpers.go index 622297bf3..b24ead9ef 100644 --- a/vendor/kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1/appbinding_helpers.go +++ b/vendor/kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1/appbinding_helpers.go @@ -81,7 +81,7 @@ func (a AppBinding) Host() (string, error) { } else if c.URL != nil { u, err := url.Parse(*c.URL) if err != nil { - return "", err + return ParseMySQLHost(*c.URL) } return u.Host, nil } @@ -99,7 +99,7 @@ func (a AppBinding) Hostname() (string, error) { } else if c.URL != nil { u, err := url.Parse(*c.URL) if err != nil { - return "", err + return ParseMySQLHostname(*c.URL) } return u.Hostname(), nil } @@ -111,12 +111,18 @@ func (a AppBinding) Port() (int32, error) { if c.Service != nil { // preferred source for MYSQL app binding return c.Service.Port, nil } else if c.URL != nil { + var port string u, err := url.Parse(*c.URL) if err != nil { - return 0, err + port, err = ParseMySQLPort(*c.URL) + if err != nil { + return 0, nil + } + } else { + port = u.Port() } - port, err := strconv.ParseInt(u.Port(), 10, 32) - return int32(port), err + result, err := strconv.ParseInt(port, 10, 32) + return int32(result), err } return 0, errors.New("connection url is missing") } diff --git a/vendor/kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1/mysql.go b/vendor/kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1/mysql.go new file mode 100644 index 000000000..62cc24bb0 --- /dev/null +++ b/vendor/kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1/mysql.go @@ -0,0 +1,93 @@ +/* +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 ( + "net" + "net/url" + "strings" + + "github.com/go-sql-driver/mysql" +) + +/* +MySQL Go driver (https://github.com/go-sql-driver/mysql) uses a custom connection string (DSN) format. +[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN] +*/ + +func (a AppBinding) MySQLDSN() (string, error) { + dsn, err := a.URL() + if err != nil { + return "", err + } + return CanonicalMySQLDSN(dsn) +} + +// CanonicalMySQLDSN will convert a regular URL into MySQL DSN format +func CanonicalMySQLDSN(dsn string) (string, error) { + _, err := mysql.ParseDSN(dsn) + if err == nil { + return dsn, nil + } + + u, err := url.Parse(dsn) + if err != nil { + return "", err + } + + rebuild := mysql.NewConfig() + rebuild.Net = u.Scheme + rebuild.Addr = u.Host + rebuild.DBName = strings.TrimPrefix(u.Path, "/") + if u.User != nil { + rebuild.User = u.User.Username() + if pass, found := u.User.Password(); found { + rebuild.Passwd = pass + } + } + rebuild.Params = map[string]string{} + for k, v := range u.Query() { + rebuild.Params[k] = v[0] + } + return rebuild.FormatDSN(), nil +} + +func ParseMySQLHost(dsn string) (string, error) { + cfg, err := mysql.ParseDSN(dsn) + if err != nil { + return "", err + } + return cfg.Addr, err +} + +func ParseMySQLHostname(dsn string) (string, error) { + cfg, err := mysql.ParseDSN(dsn) + if err != nil { + return "", err + } + host, _, err := net.SplitHostPort(cfg.Addr) + return host, err +} + +func ParseMySQLPort(dsn string) (string, error) { + cfg, err := mysql.ParseDSN(dsn) + if err != nil { + return "", err + } + _, port, err := net.SplitHostPort(cfg.Addr) + return port, err +} diff --git a/vendor/kubedb.dev/apimachinery/apis/elasticsearch/v1alpha1/constants.go b/vendor/kubedb.dev/apimachinery/apis/elasticsearch/v1alpha1/constants.go index 20f7a745f..4c871b112 100644 --- a/vendor/kubedb.dev/apimachinery/apis/elasticsearch/v1alpha1/constants.go +++ b/vendor/kubedb.dev/apimachinery/apis/elasticsearch/v1alpha1/constants.go @@ -40,11 +40,11 @@ const ( KibanaStatusEndpoint = "/api/status" KibanaConfigFileName = "kibana.yml" - OpensearchDashboardsConfigDir = "/usr/share/opensearch-elasticsearchs/config" - OpensearchDashboardsTempConfigDir = "/opensearch-elasticsearchs/temp-config" - OpensearchDashboardsCustomConfigDir = "/opensearch-elasticsearchs/custom-config" + OpensearchDashboardsConfigDir = "/usr/share/opensearch-dashboards/config" + OpensearchDashboardsTempConfigDir = "/opensearch-dashboards/temp-config" + OpensearchDashboardsCustomConfigDir = "/opensearch-dashboards/custom-config" OpensearchDashboardsStatusEndpoint = "/api/status" - OpensearchDasboardsConfigFileName = "opensearch_elasticsearchs.yml" + OpensearchDasboardsConfigFileName = "opensearch_dashboards.yml" ElasticsearchHostsKey = "elasticsearch.hosts" ElasticsearchSSLCaKey = "elasticsearch.ssl.certificateAuthorities" diff --git a/vendor/kubedb.dev/apimachinery/apis/elasticsearch/v1alpha1/types.go b/vendor/kubedb.dev/apimachinery/apis/elasticsearch/v1alpha1/types.go index 62c904d62..89722b8d9 100644 --- a/vendor/kubedb.dev/apimachinery/apis/elasticsearch/v1alpha1/types.go +++ b/vendor/kubedb.dev/apimachinery/apis/elasticsearch/v1alpha1/types.go @@ -91,9 +91,9 @@ const ( type DashboardVolumeName string const ( - DashboardVolumeCustomConfig DashboardVolumeName = "elasticsearch-custom-config" - DashboardVolumeOperatorGeneratedConfig DashboardVolumeName = "elasticsearch-temp-config" - DashboardVolumeConfig DashboardVolumeName = "elasticsearch-config" + DashboardVolumeCustomConfig DashboardVolumeName = "dashboard-custom-config" + DashboardVolumeOperatorGeneratedConfig DashboardVolumeName = "dashboard-temp-config" + DashboardVolumeConfig DashboardVolumeName = "dashboard-config" DashboardVolumeServerTLS DashboardVolumeName = "server-tls" DashboardVolumeDatabaseClient DashboardVolumeName = "database-client" ) diff --git a/vendor/kubedb.dev/apimachinery/apis/kafka/v1alpha1/connect_cluster_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kafka/v1alpha1/connect_cluster_helpers.go index 72db16090..2cec62295 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kafka/v1alpha1/connect_cluster_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kafka/v1alpha1/connect_cluster_helpers.go @@ -180,6 +180,17 @@ func (k *ConnectCluster) ConfigSecretName() string { return meta_util.NameWithSuffix(k.OffshootName(), "config") } +func (k *ConnectCluster) GetPersistentSecrets() []string { + var secrets []string + if k.Spec.AuthSecret != nil { + secrets = append(secrets, k.Spec.AuthSecret.Name) + } + if k.Spec.KeystoreCredSecret != nil { + secrets = append(secrets, k.Spec.KeystoreCredSecret.Name) + } + return secrets +} + func (k *ConnectCluster) KafkaClientCredentialsSecretName() string { return meta_util.NameWithSuffix(k.Name, "kafka-client-cred") } diff --git a/vendor/kubedb.dev/apimachinery/apis/kafka/v1alpha1/connect_cluster_webhook.go b/vendor/kubedb.dev/apimachinery/apis/kafka/v1alpha1/connect_cluster_webhook.go index 95f88422f..c61aaa26a 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kafka/v1alpha1/connect_cluster_webhook.go +++ b/vendor/kubedb.dev/apimachinery/apis/kafka/v1alpha1/connect_cluster_webhook.go @@ -78,7 +78,7 @@ func (k *ConnectCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, if len(allErr) == 0 { return nil, nil } - return nil, apierrors.NewInvalid(schema.GroupKind{Group: "kafka.kubedb.com", Kind: "Kafka"}, k.Name, allErr) + return nil, apierrors.NewInvalid(schema.GroupKind{Group: "kafka.kubedb.com", Kind: "ConnectCluster"}, k.Name, allErr) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type @@ -111,6 +111,12 @@ func (k *ConnectCluster) ValidateCreateOrUpdate() field.ErrorList { } } + if k.Spec.TerminationPolicy == api.TerminationPolicyHalt { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), + k.Name, + "TerminationPolicyHalt is not supported for ConnectCluster")) + } + // number of replicas can not be 0 or less if k.Spec.Replicas != nil && *k.Spec.Replicas <= 0 { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("replicas"), diff --git a/vendor/kubedb.dev/apimachinery/apis/kafka/v1alpha1/connector_webhook.go b/vendor/kubedb.dev/apimachinery/apis/kafka/v1alpha1/connector_webhook.go new file mode 100644 index 000000000..5028666ce --- /dev/null +++ b/vendor/kubedb.dev/apimachinery/apis/kafka/v1alpha1/connector_webhook.go @@ -0,0 +1,86 @@ +/* +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 ( + api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" + + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/validation/field" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +// log is for logging in this package. +var connectorlog = logf.Log.WithName("connector-resource") + +var _ webhook.Defaulter = &Connector{} + +// Default implements webhook.Defaulter so a webhook will be registered for the type +func (k *Connector) Default() { + if k == nil { + return + } + connectClusterLog.Info("default", "name", k.Name) + if k.Spec.TerminationPolicy == "" { + k.Spec.TerminationPolicy = api.TerminationPolicyDelete + } +} + +var _ webhook.Validator = &Connector{} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type +func (k *Connector) ValidateCreate() (admission.Warnings, error) { + connectClusterLog.Info("validate create", "name", k.Name) + return nil, k.ValidateCreateOrUpdate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type +func (k *Connector) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + connectClusterLog.Info("validate update", "name", k.Name) + return nil, k.ValidateCreateOrUpdate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type +func (k *Connector) ValidateDelete() (admission.Warnings, error) { + connectorlog.Info("validate delete", "name", k.Name) + + var allErr field.ErrorList + if k.Spec.TerminationPolicy == api.TerminationPolicyDoNotTerminate { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), + k.Name, + "Can not delete as terminationPolicy is set to \"DoNotTerminate\"")) + return nil, apierrors.NewInvalid(schema.GroupKind{Group: "kafka.kubedb.com", Kind: "Connector"}, k.Name, allErr) + } + return nil, nil +} + +func (k *Connector) ValidateCreateOrUpdate() error { + var allErr field.ErrorList + if k.Spec.TerminationPolicy == api.TerminationPolicyHalt { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), + k.Name, + "TerminationPolicyHalt isn't supported for Connector")) + } + if len(allErr) == 0 { + return nil + } + return apierrors.NewInvalid(schema.GroupKind{Group: "kafka.kubedb.com", Kind: "ConnectCluster"}, k.Name, allErr) +} diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/constants.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/constants.go index 3800e604b..4cf912be8 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/constants.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/constants.go @@ -1015,11 +1015,54 @@ const ( RabbitMQVolumeTempConfig = "temp-config" RabbitMQVolumeCustomConfig = "custom-config" - RabbitMQDataDir = "/var/lib/rabbitmq/mnesia" - RabbitMQPluginsDir = "/etc/rabbitmq/" - RabbitMQCertDir = "/var/private/ssl" - RabbitMQConfigDir = "/config/" - RabbitMQTempConfigDir = "/tmp/config/" + RabbitMQDataDir = "/var/lib/rabbitmq/mnesia" + RabbitMQConfigDir = "/config/" + RabbitMQPluginsDir = "/etc/rabbitmq/" + RabbitMQCertDir = "/var/private/ssl" + RabbitMQTempConfigDir = "/tmp/config/" + RabbitMQCustomConfigDir = "/tmp/config/custom_config/" + + RabbitMQConfigVolName = "rabbitmq-config" + RabbitMQPluginsVolName = "rabbitmq-plugins" + RabbitMQTempConfigVolName = "temp-config" + + RabbitMQContainerName = "rabbitmq" + RabbitMQInitContainerName = "rabbitmq-init" + RabbitMQManagementPlugin = "rabbitmq_management" + RabbitMQPeerdiscoveryPlugin = "rabbitmq_peer_discovery_k8s" + RabbitMQLoopBackUserKey = "loopback_users" + RabbitMQLoopBackUserVal = "none" + RabbitMQDefaultTCPListenerKey = "listeners.tcp.default" + RabbitMQDefaultTCPListenerVal = "5672" + RabbitMQQueueMasterLocatorKey = "queue_master_locator" + RabbitMQQueueMasterLocatorVal = "min-masters" + RabbitMQDiskFreeLimitKey = "disk_free_limit.absolute" + RabbitMQDiskFreeLimitVal = "2GB" + RabbitMQPartitionHandingKey = "cluster_partition_handling" + RabbitMQPartitionHandingVal = "pause_minority" + RabbitMQPeerDiscoveryKey = "cluster_formation.peer_discovery_backend" + RabbitMQPeerDiscoveryVal = "rabbit_peer_discovery_k8s" + RabbitMQK8sHostKey = "cluster_formation.k8s.host" + RabbitMQK8sHostVal = "kubernetes.default.svc.cluster.local" + RabbitMQK8sAddressTypeKey = "cluster_formation.k8s.address_type" + RabbitMQK8sAddressTypeVal = "hostname" + RabbitMQNodeCleanupWarningKey = "cluster_formation.node_cleanup.only_log_warning" + RabbitMQNodeCleanupWarningVal = "true" + RabbitMQLogFileLevelKey = "log.file.level" + RabbitMQLogFileLevelVal = "info" + RabbitMQLogConsoleKey = "log.console" + RabbitMQLogConsoleVal = "true" + RabbitMQLogConsoleLevelKey = "log.console.level" + RabbitMQLogConsoleLevelVal = "info" + RabbitMQDefaultUserKey = "default_user" + RabbitMQDefaultUserVal = "$(RABBITMQ_DEFAULT_USER)" + RabbitMQDefaultPasswordKey = "default_pass" + RabbitMQDefaultPasswordVal = "$(RABBITMQ_DEFAULT_PASS)" + RabbitMQClusterNameKey = "cluster_name" + RabbitMQK8sSvcNameKey = "cluster_formation.k8s.service_name" + RabbitMQConfigFileName = "rabbitmq.conf" + RabbitMQEnabledPluginsFileName = "enabled_plugins" + RabbitMQHealthCheckerQueueName = "kubedb-system" ) // =========================== FerretDB Constants ============================ diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_helpers.go index 467c95657..02b94210b 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_helpers.go @@ -22,7 +22,6 @@ import ( "strconv" "strings" - "kubedb.dev/apimachinery/apis" catalog "kubedb.dev/apimachinery/apis/catalog/v1alpha1" "kubedb.dev/apimachinery/apis/kubedb" "kubedb.dev/apimachinery/crds" @@ -37,6 +36,7 @@ import ( "kmodules.xyz/client-go/apiextensions" coreutil "kmodules.xyz/client-go/core/v1" meta_util "kmodules.xyz/client-go/meta" + "kmodules.xyz/client-go/policy/secomp" appcat "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1" ofst "kmodules.xyz/offshoot-api/api/v2" ) @@ -214,7 +214,7 @@ func (d *Druid) GetMetadataStorageConnectURI(appbinding *appcat.AppBinding, meta } func (d *Druid) GetZKServiceHost(appbinding *appcat.AppBinding) string { - return appbinding.Spec.ClientConfig.Service.Name + ":" + strconv.Itoa(int(appbinding.Spec.ClientConfig.Service.Port)) + return fmt.Sprintf("%s.%s.svc:%d", appbinding.Spec.ClientConfig.Service.Name, appbinding.Namespace, int(appbinding.Spec.ClientConfig.Service.Port)) } func (d *Druid) AddDruidExtensionLoadList(druidExtensionLoadList string, extension string) string { @@ -229,7 +229,7 @@ func (d *Druid) AddDruidExtensionLoadList(druidExtensionLoadList string, extensi } func (d *Druid) GetMetadataStorageType(metadataStorage string) DruidMetadataStorageType { - if metadataStorage == string(DruidMetadataStorageMySQL) { + if metadataStorage == string(DruidMetadataStorageMySQL) || metadataStorage == strings.ToLower(string(DruidMetadataStorageMySQL)) { return DruidMetadataStorageMySQL } else { return DruidMetadataStoragePostgreSQL @@ -256,10 +256,16 @@ func (d *Druid) GetDruidSegmentCacheConfig() string { } func (d *Druid) GetDruidStorageSize(storageSize string) string { - storageSize = storageSize[:len(storageSize)-1] - storageSize = strings.ToLower(storageSize) + lastTwoCharacters := storageSize[len(storageSize)-2:] + storageSize = storageSize[:len(storageSize)-2] + intSorageSize, _ := strconv.Atoi(storageSize) - return storageSize + if lastTwoCharacters == "Gi" { + intSorageSize *= 1000000000 + } else { + intSorageSize *= 1000000 + } + return strconv.Itoa(intSorageSize) } func (d *Druid) OffshootSelectors(extraSelectors ...map[string]string) map[string]string { @@ -315,11 +321,9 @@ func (d *Druid) SetDefaults() { if d.Spec.Topology.Coordinators.Replicas == nil { d.Spec.Topology.Coordinators.Replicas = pointer.Int32P(1) } - if d.Spec.Topology.Coordinators.PodTemplate.Spec.SecurityContext == nil { d.Spec.Topology.Coordinators.PodTemplate.Spec.SecurityContext = &v1.PodSecurityContext{FSGroup: druidVersion.Spec.SecurityContext.RunAsUser} } - d.Spec.Topology.Coordinators.PodTemplate.Spec.SecurityContext.RunAsGroup = druidVersion.Spec.SecurityContext.RunAsUser d.setDefaultContainerSecurityContext(&druidVersion, &d.Spec.Topology.Coordinators.PodTemplate) d.setDefaultInitContainerSecurityContext(&druidVersion, &d.Spec.Topology.Coordinators.PodTemplate) } @@ -327,11 +331,9 @@ func (d *Druid) SetDefaults() { if d.Spec.Topology.Overlords.Replicas == nil { d.Spec.Topology.Overlords.Replicas = pointer.Int32P(1) } - if d.Spec.Topology.Overlords.PodTemplate.Spec.SecurityContext == nil { d.Spec.Topology.Overlords.PodTemplate.Spec.SecurityContext = &v1.PodSecurityContext{FSGroup: druidVersion.Spec.SecurityContext.RunAsUser} } - d.Spec.Topology.Overlords.PodTemplate.Spec.SecurityContext.RunAsGroup = druidVersion.Spec.SecurityContext.RunAsUser d.setDefaultContainerSecurityContext(&druidVersion, &d.Spec.Topology.Overlords.PodTemplate) d.setDefaultInitContainerSecurityContext(&druidVersion, &d.Spec.Topology.Overlords.PodTemplate) } @@ -339,11 +341,9 @@ func (d *Druid) SetDefaults() { if d.Spec.Topology.MiddleManagers.Replicas == nil { d.Spec.Topology.MiddleManagers.Replicas = pointer.Int32P(1) } - if d.Spec.Topology.MiddleManagers.PodTemplate.Spec.SecurityContext == nil { d.Spec.Topology.MiddleManagers.PodTemplate.Spec.SecurityContext = &v1.PodSecurityContext{FSGroup: druidVersion.Spec.SecurityContext.RunAsUser} } - d.Spec.Topology.MiddleManagers.PodTemplate.Spec.SecurityContext.RunAsGroup = druidVersion.Spec.SecurityContext.RunAsUser d.setDefaultContainerSecurityContext(&druidVersion, &d.Spec.Topology.MiddleManagers.PodTemplate) d.setDefaultInitContainerSecurityContext(&druidVersion, &d.Spec.Topology.MiddleManagers.PodTemplate) } @@ -351,11 +351,9 @@ func (d *Druid) SetDefaults() { if d.Spec.Topology.Historicals.Replicas == nil { d.Spec.Topology.Historicals.Replicas = pointer.Int32P(1) } - if d.Spec.Topology.Historicals.PodTemplate.Spec.SecurityContext == nil { d.Spec.Topology.Historicals.PodTemplate.Spec.SecurityContext = &v1.PodSecurityContext{FSGroup: druidVersion.Spec.SecurityContext.RunAsUser} } - d.Spec.Topology.Historicals.PodTemplate.Spec.SecurityContext.RunAsGroup = druidVersion.Spec.SecurityContext.RunAsUser d.setDefaultContainerSecurityContext(&druidVersion, &d.Spec.Topology.Historicals.PodTemplate) d.setDefaultInitContainerSecurityContext(&druidVersion, &d.Spec.Topology.Historicals.PodTemplate) } @@ -363,11 +361,9 @@ func (d *Druid) SetDefaults() { if d.Spec.Topology.Brokers.Replicas == nil { d.Spec.Topology.Brokers.Replicas = pointer.Int32P(1) } - if d.Spec.Topology.Brokers.PodTemplate.Spec.SecurityContext == nil { d.Spec.Topology.Brokers.PodTemplate.Spec.SecurityContext = &v1.PodSecurityContext{FSGroup: druidVersion.Spec.SecurityContext.RunAsUser} } - d.Spec.Topology.Brokers.PodTemplate.Spec.SecurityContext.RunAsGroup = druidVersion.Spec.SecurityContext.RunAsUser d.setDefaultContainerSecurityContext(&druidVersion, &d.Spec.Topology.Brokers.PodTemplate) d.setDefaultInitContainerSecurityContext(&druidVersion, &d.Spec.Topology.Brokers.PodTemplate) } @@ -375,18 +371,21 @@ func (d *Druid) SetDefaults() { if d.Spec.Topology.Routers.Replicas == nil { d.Spec.Topology.Routers.Replicas = pointer.Int32P(1) } - if d.Spec.Topology.Routers.PodTemplate.Spec.SecurityContext == nil { d.Spec.Topology.Routers.PodTemplate.Spec.SecurityContext = &v1.PodSecurityContext{FSGroup: druidVersion.Spec.SecurityContext.RunAsUser} } - d.Spec.Topology.Routers.PodTemplate.Spec.SecurityContext.RunAsGroup = druidVersion.Spec.SecurityContext.RunAsUser d.setDefaultContainerSecurityContext(&druidVersion, &d.Spec.Topology.Routers.PodTemplate) d.setDefaultInitContainerSecurityContext(&druidVersion, &d.Spec.Topology.Routers.PodTemplate) } } + if d.Spec.MetadataStorage != nil { + if d.Spec.MetadataStorage.Name != nil && d.Spec.MetadataStorage.Namespace == nil { + *d.Spec.MetadataStorage.Namespace = d.Namespace + } + } } -func (d *Druid) setDefaultInitContainerSecurityContext(slVersion *catalog.DruidVersion, podTemplate *ofst.PodTemplateSpec) { +func (d *Druid) setDefaultInitContainerSecurityContext(druidVersion *catalog.DruidVersion, podTemplate *ofst.PodTemplateSpec) { initContainer := coreutil.GetContainerByName(podTemplate.Spec.InitContainers, DruidInitContainer) if initContainer == nil { initContainer = &v1.Container{ @@ -396,8 +395,7 @@ func (d *Druid) setDefaultInitContainerSecurityContext(slVersion *catalog.DruidV if initContainer.SecurityContext == nil { initContainer.SecurityContext = &v1.SecurityContext{} } - apis.SetDefaultResourceLimits(&initContainer.Resources, DefaultResources) - d.assignDefaultContainerSecurityContext(slVersion, initContainer.SecurityContext) + d.assignDefaultContainerSecurityContext(druidVersion, initContainer.SecurityContext) podTemplate.Spec.InitContainers = coreutil.UpsertContainer(podTemplate.Spec.InitContainers, *initContainer) } @@ -411,29 +409,28 @@ func (d *Druid) setDefaultContainerSecurityContext(druidVersion *catalog.DruidVe if container.SecurityContext == nil { container.SecurityContext = &v1.SecurityContext{} } - apis.SetDefaultResourceLimits(&container.Resources, DefaultResources) d.assignDefaultContainerSecurityContext(druidVersion, container.SecurityContext) podTemplate.Spec.Containers = coreutil.UpsertContainer(podTemplate.Spec.Containers, *container) } func (d *Druid) assignDefaultContainerSecurityContext(druidVersion *catalog.DruidVersion, sc *v1.SecurityContext) { - //if sc.AllowPrivilegeEscalation == nil { - // sc.AllowPrivilegeEscalation = pointer.BoolP(false) - //} - //if sc.Capabilities == nil { - // sc.Capabilities = &v1.Capabilities{ - // Drop: []v1.Capability{"ALL"}, - // } - //} - //if sc.RunAsNonRoot == nil { - // sc.RunAsNonRoot = pointer.BoolP(true) - //} - //if sc.RunAsUser == nil { - // sc.RunAsUser = druidVersion.Spec.SecurityContext.RunAsUser - //} - //if sc.SeccompProfile == nil { - // sc.SeccompProfile = secomp.DefaultSeccompProfile() - //} + if sc.AllowPrivilegeEscalation == nil { + sc.AllowPrivilegeEscalation = pointer.BoolP(false) + } + if sc.Capabilities == nil { + sc.Capabilities = &v1.Capabilities{ + Drop: []v1.Capability{"ALL"}, + } + } + if sc.RunAsNonRoot == nil { + sc.RunAsNonRoot = pointer.BoolP(true) + } + if sc.RunAsUser == nil { + sc.RunAsUser = druidVersion.Spec.SecurityContext.RunAsUser + } + if sc.SeccompProfile == nil { + sc.SeccompProfile = secomp.DefaultSeccompProfile() + } } func (d *Druid) GetPersistentSecrets() []string { diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_types.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_types.go index a0de52708..5e3c70d8b 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_types.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_types.go @@ -59,10 +59,6 @@ type DruidSpec struct { // Version of Druid to be deployed. Version string `json:"version"` - // Number of instances to deploy for a Druid database - // +optional - Replicas *int32 `json:"replicas,omitempty"` - // Druid topology for node specification // +optional Topology *DruidClusterTopology `json:"topology,omitempty"` @@ -96,14 +92,14 @@ type DruidSpec struct { //TLS *kmapi.TLSConfig `json:"tls,omitempty"` // MetadataStorage contains information for Druid to connect to external dependency metadata storage - // +optional - MetadataStorage *MetadataStorage `json:"metadataStorage,omitempty"` + MetadataStorage *MetadataStorage `json:"metadataStorage"` // DeepStorage contains specification for druid to connect to the deep storage DeepStorage *DeepStorageSpec `json:"deepStorage"` // ZooKeeper contains information for Druid to connect to external dependency metadata storage - ZooKeeper *ZooKeeperRef `json:"zooKeeper"` + // +optional + ZooKeeper *ZooKeeperRef `json:"zooKeeper,omitempty"` // PodTemplate is an optional configuration // +optional @@ -171,11 +167,16 @@ type DruidNode struct { type MetadataStorage struct { // Name of the appbinding of metadata storage - Name string `json:"name"` + // +optional + Name *string `json:"name,omitempty"` // Namespace of the appbinding of metadata storage // +optional - Namespace string `json:"namespace,omitempty"` + Namespace *string `json:"namespace,omitempty"` + + // If not KubeDB managed, then specify type of the metadata storage + // +optional + Type *string `json:"type,omitempty"` // If Druid has the permission to create new tables // +optional @@ -189,20 +190,22 @@ type DeepStorageSpec struct { // deepStorage.configSecret should contain the necessary data // to connect to the deep storage + // +optional ConfigSecret *core.LocalObjectReference `json:"configSecret"` } type ZooKeeperRef struct { // Name of the appbinding of zookeeper - Name *string `json:"name"` + // +optional + Name *string `json:"name,omitempty"` // Namespace of the appbinding of zookeeper // +optional - Namespace string `json:"namespace"` + Namespace string `json:"namespace,omitempty"` // Base ZooKeeperSpec path // +optional - PathsBase string `json:"pathsBase"` + PathsBase string `json:"pathsBase,omitempty"` } // DruidStatus defines the observed state of Druid diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_webhook.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_webhook.go index e1ea8fb89..4b4873e3d 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_webhook.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_webhook.go @@ -17,11 +17,15 @@ limitations under the License. package v1alpha2 import ( + "context" "errors" + catalog "kubedb.dev/apimachinery/apis/catalog/v1alpha1" + apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation/field" ofst "kmodules.xyz/offshoot-api/api/v2" logf "sigs.k8s.io/controller-runtime/pkg/log" @@ -78,10 +82,6 @@ func (d *Druid) ValidateDelete() (admission.Warnings, error) { return nil, nil } -var druidAvailableVersions = []string{ - "25.0.0", -} - var druidReservedVolumes = []string{ DruidVolumeOperatorConfig, DruidVolumeMainConfig, @@ -102,7 +102,7 @@ func (d *Druid) validateCreateOrUpdate() field.ErrorList { if d.Spec.Version == "" { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("version"), d.Name, - "spec.version' is missing")) + "spec.version is missing")) } else { err := druidValidateVersion(d) if err != nil { @@ -127,31 +127,27 @@ func (d *Druid) validateCreateOrUpdate() field.ErrorList { if d.Spec.DeepStorage == nil { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("deepStorage"), d.Name, - "spec.deepStorage' is missing")) + "spec.deepStorage is missing")) } else { if d.Spec.DeepStorage.Type == nil { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("deepStorage").Child("type"), d.Name, - "spec.deepStorage.type' is missing")) - } - if d.Spec.DeepStorage.ConfigSecret == nil { - allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("deepStorage").Child("configSecret"), - d.Name, - "spec.deepStorage.configSecret' is missing")) + "spec.deepStorage.type is missing")) } } - if d.Spec.ZooKeeper == nil { - allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("zooKeeper"), + if d.Spec.MetadataStorage == nil { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("metadataStorage"), d.Name, - "spec.zooKeeper' is missing")) + "spec.metadataStorage is missing")) } else { - if d.Spec.ZooKeeper.Name == nil { - allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("zooKeeper").Child("name"), + if d.Spec.MetadataStorage.Name == nil && d.Spec.MetadataStorage.Type == nil { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("metadataStorage").Child("name"), d.Name, - "spec.zooKeeper.name' is missing")) + "spec.metadataStorage.type and spec.metadataStorage.name both can not be empty simultaneously")) } } + if d.Spec.Topology == nil { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("topology"), d.Name, @@ -236,7 +232,7 @@ func (d *Druid) validateCreateOrUpdate() field.ErrorList { if d.Spec.Topology.Brokers == nil { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("topology").Child("brokers").Child("replicas"), d.Name, - "spec.topology.brokers.replicas' can not be empty")) + "spec.topology.brokers.replicas can not be empty")) } else { if *d.Spec.Topology.Brokers.Replicas <= 0 { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("topology").Child("brokers").Child("replicas"), @@ -306,13 +302,14 @@ func (d *Druid) validateCreateOrUpdate() field.ErrorList { } func druidValidateVersion(d *Druid) error { - version := d.Spec.Version - for _, v := range druidAvailableVersions { - if v == version { - return nil - } + var druidVersion catalog.DruidVersion + err := DefaultClient.Get(context.TODO(), types.NamespacedName{ + Name: d.Spec.Version, + }, &druidVersion) + if err != nil { + return errors.New("version not supported") } - return errors.New("version not supported") + return nil } func druidValidateVolumes(podTemplate *ofst.PodTemplateSpec, nodeType DruidNodeRoleType) error { diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/elasticsearch_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/elasticsearch_helpers.go index 93ca42deb..7107043b7 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/elasticsearch_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/elasticsearch_helpers.go @@ -639,8 +639,13 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion, top func (e *Elasticsearch) SetMetricsExporterDefaults(esVersion *catalog.ElasticsearchVersion) { e.Spec.Monitor.SetDefaults() - if e.Spec.Monitor != nil && e.Spec.Monitor.Prometheus != nil && e.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { - e.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = esVersion.Spec.SecurityContext.RunAsUser + if e.Spec.Monitor != nil && e.Spec.Monitor.Prometheus != nil { + if e.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { + e.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = esVersion.Spec.SecurityContext.RunAsUser + } + if e.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup == nil { + e.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup = esVersion.Spec.SecurityContext.RunAsUser + } } } diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/ferretdb_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/ferretdb_helpers.go index 1dc77e90f..62058fdfe 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/ferretdb_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/ferretdb_helpers.go @@ -17,9 +17,11 @@ limitations under the License. package v1alpha2 import ( + "context" "fmt" "kubedb.dev/apimachinery/apis" + catalog "kubedb.dev/apimachinery/apis/catalog/v1alpha1" "kubedb.dev/apimachinery/apis/kubedb" "kubedb.dev/apimachinery/crds" @@ -29,11 +31,14 @@ import ( core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/types" appslister "k8s.io/client-go/listers/apps/v1" + "k8s.io/klog/v2" kmapi "kmodules.xyz/client-go/api/v1" "kmodules.xyz/client-go/apiextensions" coreutil "kmodules.xyz/client-go/core/v1" 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" @@ -155,7 +160,7 @@ func (f *FerretDB) SetDefaults() { } if f.Spec.TerminationPolicy == "" { - f.Spec.TerminationPolicy = TerminationPolicyDelete + f.Spec.TerminationPolicy = TerminationPolicyWipeOut } if f.Spec.SSLMode == "" { @@ -170,6 +175,14 @@ func (f *FerretDB) SetDefaults() { f.Spec.PodTemplate = &ofst.PodTemplateSpec{} } + var frVersion catalog.FerretDBVersion + err := DefaultClient.Get(context.TODO(), types.NamespacedName{ + Name: f.Spec.Version, + }, &frVersion) + if err != nil { + klog.Errorf("can't get the FerretDB version object %s for %s \n", err.Error(), f.Spec.Version) + return + } dbContainer := coreutil.GetContainerByName(f.Spec.PodTemplate.Spec.Containers, FerretDBContainerName) if dbContainer == nil { dbContainer = &core.Container{ @@ -180,6 +193,11 @@ func (f *FerretDB) SetDefaults() { if structs.IsZero(dbContainer.Resources) { apis.SetDefaultResourceLimits(&dbContainer.Resources, DefaultResources) } + if dbContainer.SecurityContext == nil { + dbContainer.SecurityContext = &core.SecurityContext{} + } + f.setDefaultContainerSecurityContext(&frVersion, dbContainer.SecurityContext) + f.setDefaultPodTemplateSecurityContext(&frVersion, f.Spec.PodTemplate) if f.Spec.Backend.LinkedDB == "" { if f.Spec.Backend.ExternallyManaged { @@ -188,10 +206,21 @@ func (f *FerretDB) SetDefaults() { f.Spec.Backend.LinkedDB = "ferretdb" } } - if f.Spec.Monitor != nil && f.Spec.Monitor.Prometheus.Exporter.Port == 0 { - // 56790 is default port for Prometheus operator. - f.Spec.Monitor.Prometheus.Exporter.Port = 56790 + if f.Spec.AuthSecret == nil { + f.Spec.AuthSecret = &SecretReference{ + ExternallyManaged: f.Spec.Backend.ExternallyManaged, + } + } + f.Spec.Monitor.SetDefaults() + if f.Spec.Monitor != nil && f.Spec.Monitor.Prometheus != nil { + if f.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { + f.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = frVersion.Spec.SecurityContext.RunAsUser + } + if f.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup == nil { + f.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup = frVersion.Spec.SecurityContext.RunAsUser + } } + defaultVersion := "13.13" if !f.Spec.Backend.ExternallyManaged && f.Spec.Backend.Postgres == nil { f.Spec.Backend.Postgres = &PostgresRef{ @@ -202,6 +231,41 @@ func (f *FerretDB) SetDefaults() { f.SetHealthCheckerDefaults() } +func (f *FerretDB) setDefaultPodTemplateSecurityContext(frVersion *catalog.FerretDBVersion, podTemplate *ofst.PodTemplateSpec) { + if podTemplate == nil { + return + } + if podTemplate.Spec.SecurityContext == nil { + podTemplate.Spec.SecurityContext = &core.PodSecurityContext{} + } + if podTemplate.Spec.SecurityContext.FSGroup == nil { + podTemplate.Spec.SecurityContext.FSGroup = frVersion.Spec.SecurityContext.RunAsUser + } +} + +func (f *FerretDB) setDefaultContainerSecurityContext(frVersion *catalog.FerretDBVersion, sc *core.SecurityContext) { + if sc.AllowPrivilegeEscalation == nil { + sc.AllowPrivilegeEscalation = pointer.BoolP(false) + } + if sc.Capabilities == nil { + sc.Capabilities = &core.Capabilities{ + Drop: []core.Capability{"ALL"}, + } + } + if sc.RunAsNonRoot == nil { + sc.RunAsNonRoot = pointer.BoolP(true) + } + if sc.RunAsUser == nil { + sc.RunAsUser = frVersion.Spec.SecurityContext.RunAsUser + } + if sc.RunAsGroup == nil { + sc.RunAsGroup = frVersion.Spec.SecurityContext.RunAsUser + } + if sc.SeccompProfile == nil { + sc.SeccompProfile = secomp.DefaultSeccompProfile() + } +} + func (f *FerretDB) SetTLSDefaults() { if f.Spec.TLS == nil || f.Spec.TLS.IssuerRef == nil { return diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/ferretdb_types.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/ferretdb_types.go index 8999ca08a..c465967c5 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/ferretdb_types.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/ferretdb_types.go @@ -57,7 +57,8 @@ type FerretDBSpec struct { // Number of instances to deploy for a FerretDB database. Replicas *int32 `json:"replicas,omitempty"` - // Database authentication secret + // Database authentication secret. + // If authSecret is nil, authSecret.externallyManaged will set to backend.externallyManaged // +optional AuthSecret *SecretReference `json:"authSecret,omitempty"` @@ -131,7 +132,7 @@ type Backend struct { // A DB inside backend specifically made for ferretdb // +optional LinkedDB string `json:"linkedDB,omitempty"` - ExternallyManaged bool `json:"externallyManaged,omitempty"` + ExternallyManaged bool `json:"externallyManaged"` } type PostgresRef struct { @@ -143,16 +144,16 @@ type PostgresRef struct { Service *PostgresServiceRef `json:"service,omitempty"` // Which versions pg will be used as backend of ferretdb // +optional - Version *string `json:"version"` + Version *string `json:"version,omitempty"` } type PostgresServiceRef struct { - Name string `json:"name"` - Namespace string `json:"namespace"` + Name *string `json:"name"` + Namespace *string `json:"namespace"` // PgPort is used because the service referred to the // pg pod can have any port between 1 and 65535, inclusive // but targetPort is fixed to 5432 - PgPort string `json:"pgPort"` + PgPort *string `json:"pgPort"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/ferretdb_webhook.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/ferretdb_webhook.go index bb604adde..2d8695f92 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/ferretdb_webhook.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/ferretdb_webhook.go @@ -122,6 +122,7 @@ func (f *FerretDB) ValidateCreateOrUpdate() field.ErrorList { } } + // Storage related if f.Spec.StorageType == "" { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("storageType"), f.Name, @@ -137,45 +138,47 @@ func (f *FerretDB) ValidateCreateOrUpdate() field.ErrorList { f.Name, `'spec.storageType' is set to Ephemeral, so 'spec.storage' needs to be empty`)) } + if !f.Spec.Backend.ExternallyManaged && f.Spec.StorageType == StorageTypeDurable && f.Spec.Storage == nil { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("storage"), + f.Name, + `'spec.storage' is missing for durable storage type when postgres is internally managed`)) + } + // Auth secret related if f.Spec.AuthSecret != nil && f.Spec.AuthSecret.ExternallyManaged != f.Spec.Backend.ExternallyManaged { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("authSecret"), f.Name, - `when 'spec.backend' is internally manager, 'spec.authSecret' can't be externally managed and vice versa`)) + `when 'spec.backend' is internally managed, 'spec.authSecret' can't be externally managed and vice versa`)) } - if f.Spec.AuthSecret != nil && f.Spec.AuthSecret.ExternallyManaged && f.Spec.AuthSecret.Name == "" { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("authSecret"), f.Name, - `for externallyManaged auth secret, user must configure "spec.authSecret.name"`)) + `'spec.authSecret.name' needs to specify when auth secret is externally managed`)) } + if f.Spec.StorageType == StorageTypeEphemeral && f.Spec.TerminationPolicy == TerminationPolicyHalt { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("storageType"), f.Name, `'spec.terminationPolicy: Halt' can not be used for 'Ephemeral' storage`)) } - if f.Spec.TerminationPolicy == "" { - allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), - f.Name, - `'spec.terminationPolicy' is missing`)) - } if f.Spec.TerminationPolicy == TerminationPolicyHalt || f.Spec.TerminationPolicy == TerminationPolicyDelete { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), f.Name, `'spec.terminationPolicy' value 'Halt' or 'Delete' is not supported yet for FerretDB`)) } + // Backend related if f.Spec.Backend.ExternallyManaged { if f.Spec.Backend.Postgres == nil { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("backend"), f.Name, `'spec.postgres' is missing when backend is externally managed`)) } - } - if f.Spec.SSLMode == SSLModeAllowSSL || f.Spec.SSLMode == SSLModePreferSSL { - allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("sslMode"), - f.Name, - `'spec.sslMode' value 'allowSSL' or 'preferSSL' is not supported yet for FerretDB`)) + if f.Spec.Backend.Postgres != nil && f.Spec.Backend.Postgres.URL == nil && f.Spec.Backend.Postgres.Service == nil { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("backend"), + f.Name, + `Have to provide 'backend.postgres.url' or 'backend.postgres.service' when backend is externally managed`)) + } } if !f.Spec.Backend.ExternallyManaged && f.Spec.Backend.Postgres != nil && f.Spec.Backend.Postgres.Version != nil { err := f.validatePostgresVersion() @@ -186,6 +189,12 @@ func (f *FerretDB) ValidateCreateOrUpdate() field.ErrorList { } } + if f.Spec.SSLMode == SSLModeAllowSSL || f.Spec.SSLMode == SSLModePreferSSL { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("sslMode"), + f.Name, + `'spec.sslMode' value 'allowSSL' or 'preferSSL' is not supported yet for FerretDB`)) + } + return allErr } diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/kafka_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/kafka_helpers.go index e29bb14ec..73aef5e6c 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/kafka_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/kafka_helpers.go @@ -224,6 +224,17 @@ func (k *Kafka) ConfigSecretName(role KafkaNodeRoleType) string { return meta_util.NameWithSuffix(k.OffshootName(), "config") } +func (k *Kafka) GetPersistentSecrets() []string { + var secrets []string + if k.Spec.AuthSecret != nil { + secrets = append(secrets, k.Spec.AuthSecret.Name) + } + if k.Spec.KeystoreCredSecret != nil { + secrets = append(secrets, k.Spec.KeystoreCredSecret.Name) + } + return secrets +} + func (k *Kafka) CruiseControlConfigSecretName() string { return meta_util.NameWithSuffix(k.OffshootName(), "cruise-control-config") } @@ -309,8 +320,13 @@ func (k *Kafka) SetDefaults() { } k.Spec.Monitor.SetDefaults() - if k.Spec.Monitor != nil && k.Spec.Monitor.Prometheus != nil && k.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { - k.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = kfVersion.Spec.SecurityContext.RunAsUser + if k.Spec.Monitor != nil && k.Spec.Monitor.Prometheus != nil { + if k.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { + k.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = kfVersion.Spec.SecurityContext.RunAsUser + } + if k.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup == nil { + k.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup = kfVersion.Spec.SecurityContext.RunAsUser + } } if k.Spec.Topology != nil { diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/mariadb_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/mariadb_helpers.go index d8ddfb3e2..a5b76aa7d 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/mariadb_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/mariadb_helpers.go @@ -219,13 +219,19 @@ func (m *MariaDB) SetDefaults(mdVersion *v1alpha1.MariaDBVersion, topology *core m.setDefaultContainerSecurityContext(mdVersion, &m.Spec.PodTemplate) - m.Spec.Monitor.SetDefaults() m.setDefaultAffinity(&m.Spec.PodTemplate, m.OffshootSelectors(), topology) m.SetTLSDefaults() m.SetHealthCheckerDefaults() apis.SetDefaultResourceLimits(&m.Spec.PodTemplate.Spec.Resources, DefaultResources) - if m.Spec.Monitor != nil && m.Spec.Monitor.Prometheus != nil && m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { - m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = mdVersion.Spec.SecurityContext.RunAsUser + + m.Spec.Monitor.SetDefaults() + if m.Spec.Monitor != nil && m.Spec.Monitor.Prometheus != nil { + if m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { + m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = mdVersion.Spec.SecurityContext.RunAsUser + } + if m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup == nil { + m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup = mdVersion.Spec.SecurityContext.RunAsUser + } } } diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/mysql_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/mysql_helpers.go index 1c9685e00..aa9ac3c65 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/mysql_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/mysql_helpers.go @@ -287,13 +287,18 @@ func (m *MySQL) SetDefaults(myVersion *v1alpha1.MySQLVersion, topology *core_uti m.setDefaultContainerSecurityContext(myVersion, &m.Spec.PodTemplate) - m.Spec.Monitor.SetDefaults() m.setDefaultAffinity(&m.Spec.PodTemplate, m.OffshootSelectors(), topology) m.SetTLSDefaults() m.SetHealthCheckerDefaults() apis.SetDefaultResourceLimits(&m.Spec.PodTemplate.Spec.Resources, DefaultResources) - if m.Spec.Monitor != nil && m.Spec.Monitor.Prometheus != nil && m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { - m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = myVersion.Spec.SecurityContext.RunAsUser + m.Spec.Monitor.SetDefaults() + if m.Spec.Monitor != nil && m.Spec.Monitor.Prometheus != nil { + if m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { + m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = myVersion.Spec.SecurityContext.RunAsUser + } + if m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup == nil { + m.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup = myVersion.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 19c0c8e56..82a5a0d39 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/openapi_generated.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/openapi_generated.go @@ -23006,11 +23006,13 @@ func schema_apimachinery_apis_kubedb_v1alpha2_Backend(ref common.ReferenceCallba }, "externallyManaged": { SchemaProps: spec.SchemaProps{ - Type: []string{"boolean"}, - Format: "", + Default: false, + Type: []string{"boolean"}, + Format: "", }, }, }, + Required: []string{"externallyManaged"}, }, }, Dependencies: []string{ @@ -23228,7 +23230,7 @@ func schema_apimachinery_apis_kubedb_v1alpha2_DeepStorageSpec(ref common.Referen }, }, }, - Required: []string{"type", "configSecret"}, + Required: []string{"type"}, }, }, Dependencies: []string{ @@ -23487,13 +23489,6 @@ func schema_apimachinery_apis_kubedb_v1alpha2_DruidSpec(ref common.ReferenceCall Format: "", }, }, - "replicas": { - SchemaProps: spec.SchemaProps{ - Description: "Number of instances to deploy for a Druid database", - Type: []string{"integer"}, - Format: "int32", - }, - }, "topology": { SchemaProps: spec.SchemaProps{ Description: "Druid topology for node specification", @@ -23587,7 +23582,7 @@ func schema_apimachinery_apis_kubedb_v1alpha2_DruidSpec(ref common.ReferenceCall }, }, }, - Required: []string{"version", "deepStorage", "zooKeeper"}, + Required: []string{"version", "metadataStorage", "deepStorage"}, }, }, Dependencies: []string{ @@ -24750,7 +24745,7 @@ func schema_apimachinery_apis_kubedb_v1alpha2_FerretDBSpec(ref common.ReferenceC }, "authSecret": { SchemaProps: spec.SchemaProps{ - Description: "Database authentication secret", + Description: "Database authentication secret. If authSecret is nil, authSecret.externallyManaged will set to backend.externallyManaged", Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SecretReference"), }, }, @@ -26068,7 +26063,6 @@ func schema_apimachinery_apis_kubedb_v1alpha2_MetadataStorage(ref common.Referen "name": { SchemaProps: spec.SchemaProps{ Description: "Name of the appbinding of metadata storage", - Default: "", Type: []string{"string"}, Format: "", }, @@ -26080,6 +26074,13 @@ func schema_apimachinery_apis_kubedb_v1alpha2_MetadataStorage(ref common.Referen Format: "", }, }, + "type": { + SchemaProps: spec.SchemaProps{ + Description: "If not KubeDB managed, then specify type of the metadata storage", + Type: []string{"string"}, + Format: "", + }, + }, "createTables": { SchemaProps: spec.SchemaProps{ Description: "If Druid has the permission to create new tables", @@ -26088,7 +26089,6 @@ func schema_apimachinery_apis_kubedb_v1alpha2_MetadataStorage(ref common.Referen }, }, }, - Required: []string{"name"}, }, }, } @@ -28338,22 +28338,19 @@ func schema_apimachinery_apis_kubedb_v1alpha2_PostgresServiceRef(ref common.Refe Properties: map[string]spec.Schema{ "name": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "namespace": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "pgPort": { SchemaProps: spec.SchemaProps{ Description: "PgPort is used because the service referred to the pg pod can have any port between 1 and 65535, inclusive but targetPort is fixed to 5432", - Default: "", Type: []string{"string"}, Format: "", }, @@ -31069,7 +31066,6 @@ func schema_apimachinery_apis_kubedb_v1alpha2_ZooKeeperRef(ref common.ReferenceC "namespace": { SchemaProps: spec.SchemaProps{ Description: "Namespace of the appbinding of zookeeper", - Default: "", Type: []string{"string"}, Format: "", }, @@ -31077,13 +31073,11 @@ func schema_apimachinery_apis_kubedb_v1alpha2_ZooKeeperRef(ref common.ReferenceC "pathsBase": { SchemaProps: spec.SchemaProps{ Description: "Base ZooKeeperSpec path", - Default: "", Type: []string{"string"}, Format: "", }, }, }, - Required: []string{"name"}, }, }, } diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/perconaxtradb_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/perconaxtradb_helpers.go index 8d2ab393a..1449c70cf 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/perconaxtradb_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/perconaxtradb_helpers.go @@ -231,12 +231,17 @@ func (p *PerconaXtraDB) SetDefaults(pVersion *v1alpha1.PerconaXtraDBVersion, top // Otherwise, We will get write permission denied. p.setDefaultContainerSecurityContext(pVersion, &p.Spec.PodTemplate) - p.Spec.Monitor.SetDefaults() p.setDefaultAffinity(&p.Spec.PodTemplate, p.OffshootSelectors(), topology) p.SetTLSDefaults() apis.SetDefaultResourceLimits(&p.Spec.PodTemplate.Spec.Resources, DefaultResources) - if p.Spec.Monitor != nil && p.Spec.Monitor.Prometheus != nil && p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { - p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = pVersion.Spec.SecurityContext.RunAsUser + p.Spec.Monitor.SetDefaults() + if p.Spec.Monitor != nil && p.Spec.Monitor.Prometheus != nil { + if p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { + p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = pVersion.Spec.SecurityContext.RunAsUser + } + if p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup == nil { + p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup = pVersion.Spec.SecurityContext.RunAsUser + } } } diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/pgbouncer_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/pgbouncer_helpers.go index 3bb1f2257..e3445716e 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/pgbouncer_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/pgbouncer_helpers.go @@ -211,8 +211,13 @@ func (p *PgBouncer) SetDefaults(pgBouncerVersion *catalog.PgBouncerVersion, uses } p.Spec.Monitor.SetDefaults() - if p.Spec.Monitor != nil && p.Spec.Monitor.Prometheus != nil && p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { - p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = pgBouncerVersion.Spec.SecurityContext.RunAsUser + if p.Spec.Monitor != nil && p.Spec.Monitor.Prometheus != nil { + if p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { + p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = pgBouncerVersion.Spec.SecurityContext.RunAsUser + } + if p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup == nil { + p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup = pgBouncerVersion.Spec.SecurityContext.RunAsUser + } } apis.SetDefaultResourceLimits(&p.Spec.PodTemplate.Spec.Resources, DefaultResources) } diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/pgpool_webhook.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/pgpool_webhook.go index dd997172d..73c6390b8 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/pgpool_webhook.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/pgpool_webhook.go @@ -126,9 +126,9 @@ func (p *Pgpool) ValidateCreateOrUpdate() field.ErrorList { "`spec.replica` must be greater than 0", )) } - if *p.Spec.Replicas > 3 { + if *p.Spec.Replicas > 9 { errorList = append(errorList, field.Required(field.NewPath("spec").Child("replicas"), - "`spec.replica` must be less than 4", + "`spec.replica` must be less than 10", )) } } diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/postgres_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/postgres_helpers.go index 5f0aab2b4..c912c7f5b 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/postgres_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/postgres_helpers.go @@ -262,13 +262,19 @@ func (p *Postgres) SetDefaults(postgresVersion *catalog.PostgresVersion, topolog // Otherwise, We will get write permission denied. p.Spec.PodTemplate.Spec.SecurityContext.FSGroup = p.Spec.PodTemplate.Spec.ContainerSecurityContext.RunAsGroup p.SetArbiterDefault() - p.Spec.Monitor.SetDefaults() p.SetTLSDefaults() p.SetHealthCheckerDefaults() apis.SetDefaultResourceLimits(&p.Spec.PodTemplate.Spec.Resources, DefaultResources) p.setDefaultAffinity(&p.Spec.PodTemplate, p.OffshootSelectors(), topology) - if p.Spec.Monitor != nil && p.Spec.Monitor.Prometheus != nil && p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { - p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = postgresVersion.Spec.SecurityContext.RunAsUser + + p.Spec.Monitor.SetDefaults() + if p.Spec.Monitor != nil && p.Spec.Monitor.Prometheus != nil { + if p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { + p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = postgresVersion.Spec.SecurityContext.RunAsUser + } + if p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup == nil { + p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup = postgresVersion.Spec.SecurityContext.RunAsUser + } } } diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/rabbitmq_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/rabbitmq_helpers.go index 60c8d69c8..1fe0dd389 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/rabbitmq_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/rabbitmq_helpers.go @@ -17,23 +17,32 @@ limitations under the License. package v1alpha2 import ( + "context" "fmt" "path/filepath" "strings" + "kubedb.dev/apimachinery/apis" + catalog "kubedb.dev/apimachinery/apis/catalog/v1alpha1" "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" "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/types" appslister "k8s.io/client-go/listers/apps/v1" + "k8s.io/klog/v2" kmapi "kmodules.xyz/client-go/api/v1" "kmodules.xyz/client-go/apiextensions" + coreutil "kmodules.xyz/client-go/core/v1" 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" ) func (r *RabbitMQ) CustomResourceDefinition() *apiextensions.CustomResourceDefinition { @@ -64,6 +73,20 @@ func (r *RabbitMQ) GetConnectionScheme() string { return scheme } +func (r *RabbitMQ) GetAuthSecretName() string { + if r.Spec.AuthSecret != nil && r.Spec.AuthSecret.Name != "" { + return r.Spec.AuthSecret.Name + } + return r.DefaultUserCredSecretName("admin") +} + +func (r *RabbitMQ) GetPersistentSecrets() []string { + var secrets []string + secrets = append(secrets, r.GetAuthSecretName()) + secrets = append(secrets, r.DefaultErlangCookieSecretName()) + return secrets +} + func (r *RabbitMQ) ResourceShortCode() string { return ResourceCodeRabbitmq } @@ -132,6 +155,10 @@ func (r *RabbitMQ) ServiceLabels(alias ServiceAlias, extraLabels ...map[string]s return r.offshootLabels(meta_util.OverwriteKeys(r.OffshootSelectors(), extraLabels...), svcTemplate.Labels) } +func (r *RabbitMQ) Finalizer() string { + return fmt.Sprintf("%s/%s", kubedb.GroupName, apis.Finalizer) +} + type RabbitmqStatsService struct { *RabbitMQ } @@ -247,19 +274,11 @@ func (r *RabbitMQ) PVCName(alias string) string { return meta_util.NameWithSuffix(r.Name, alias) } -func (r *RabbitMQ) SetHealthCheckerDefaults() { - if r.Spec.HealthChecker.PeriodSeconds == nil { - r.Spec.HealthChecker.PeriodSeconds = pointer.Int32P(10) - } - if r.Spec.HealthChecker.TimeoutSeconds == nil { - r.Spec.HealthChecker.TimeoutSeconds = pointer.Int32P(10) - } - if r.Spec.HealthChecker.FailureThreshold == nil { - r.Spec.HealthChecker.FailureThreshold = pointer.Int32P(3) +func (r *RabbitMQ) SetDefaults() { + if r.Spec.Replicas == nil { + r.Spec.Replicas = pointer.Int32P(1) } -} -func (r *RabbitMQ) SetDefaults() { if r.Spec.TerminationPolicy == "" { r.Spec.TerminationPolicy = TerminationPolicyDelete } @@ -268,9 +287,95 @@ func (r *RabbitMQ) SetDefaults() { r.Spec.StorageType = StorageTypeDurable } + var rmVersion catalog.RabbitMQVersion + err := DefaultClient.Get(context.TODO(), types.NamespacedName{ + Name: r.Spec.Version, + }, &rmVersion) + if err != nil { + klog.Errorf("can't get the rabbitmq version object %s for %s \n", err.Error(), r.Spec.Version) + return + } + + r.setDefaultContainerSecurityContext(&rmVersion, &r.Spec.PodTemplate) r.SetHealthCheckerDefaults() } +func (r *RabbitMQ) setDefaultContainerSecurityContext(rmVersion *catalog.RabbitMQVersion, podTemplate *ofst.PodTemplateSpec) { + if podTemplate == nil { + return + } + if podTemplate.Spec.SecurityContext == nil { + podTemplate.Spec.SecurityContext = &core.PodSecurityContext{} + } + if podTemplate.Spec.SecurityContext.FSGroup == nil { + podTemplate.Spec.SecurityContext.FSGroup = rmVersion.Spec.SecurityContext.RunAsUser + } + + container := coreutil.GetContainerByName(podTemplate.Spec.Containers, RabbitMQContainerName) + if container == nil { + container = &core.Container{ + Name: RabbitMQContainerName, + } + podTemplate.Spec.Containers = append(podTemplate.Spec.Containers, *container) + } + if container.SecurityContext == nil { + container.SecurityContext = &core.SecurityContext{} + } + r.assignDefaultContainerSecurityContext(rmVersion, container.SecurityContext) + + initContainer := coreutil.GetContainerByName(podTemplate.Spec.InitContainers, RabbitMQInitContainerName) + if initContainer == nil { + initContainer = &core.Container{ + Name: RabbitMQInitContainerName, + } + podTemplate.Spec.InitContainers = append(podTemplate.Spec.InitContainers, *initContainer) + } + if initContainer.SecurityContext == nil { + initContainer.SecurityContext = &core.SecurityContext{} + } + r.assignDefaultInitContainerSecurityContext(rmVersion, initContainer.SecurityContext) +} + +func (r *RabbitMQ) assignDefaultInitContainerSecurityContext(rmVersion *catalog.RabbitMQVersion, rc *core.SecurityContext) { + if rc.AllowPrivilegeEscalation == nil { + rc.AllowPrivilegeEscalation = pointer.BoolP(false) + } + if rc.Capabilities == nil { + rc.Capabilities = &core.Capabilities{ + Drop: []core.Capability{"ALL"}, + } + } + if rc.RunAsNonRoot == nil { + rc.RunAsNonRoot = pointer.BoolP(true) + } + if rc.RunAsUser == nil { + rc.RunAsUser = rmVersion.Spec.SecurityContext.RunAsUser + } + if rc.SeccompProfile == nil { + rc.SeccompProfile = secomp.DefaultSeccompProfile() + } +} + +func (r *RabbitMQ) assignDefaultContainerSecurityContext(rmVersion *catalog.RabbitMQVersion, rc *core.SecurityContext) { + if rc.AllowPrivilegeEscalation == nil { + rc.AllowPrivilegeEscalation = pointer.BoolP(false) + } + if rc.Capabilities == nil { + rc.Capabilities = &core.Capabilities{ + Drop: []core.Capability{"ALL"}, + } + } + if rc.RunAsNonRoot == nil { + rc.RunAsNonRoot = pointer.BoolP(true) + } + if rc.RunAsUser == nil { + rc.RunAsUser = rmVersion.Spec.SecurityContext.RunAsUser + } + if rc.SeccompProfile == nil { + rc.SeccompProfile = secomp.DefaultSeccompProfile() + } +} + func (r *RabbitMQ) SetTLSDefaults() { if r.Spec.TLS == nil || r.Spec.TLS.IssuerRef == nil { return @@ -279,6 +384,18 @@ func (r *RabbitMQ) SetTLSDefaults() { r.Spec.TLS.Certificates = kmapi.SetMissingSecretNameForCertificate(r.Spec.TLS.Certificates, string(RabbitmqClientCert), r.CertificateName(RabbitmqClientCert)) } +func (r *RabbitMQ) SetHealthCheckerDefaults() { + if r.Spec.HealthChecker.PeriodSeconds == nil { + r.Spec.HealthChecker.PeriodSeconds = pointer.Int32P(10) + } + if r.Spec.HealthChecker.TimeoutSeconds == nil { + r.Spec.HealthChecker.TimeoutSeconds = pointer.Int32P(10) + } + if r.Spec.HealthChecker.FailureThreshold == nil { + r.Spec.HealthChecker.FailureThreshold = pointer.Int32P(3) + } +} + func (r *RabbitMQ) ReplicasAreReady(lister appslister.StatefulSetLister) (bool, string, error) { // Desire number of statefulSets expectedItems := 1 diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/rabbitmq_webhook.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/rabbitmq_webhook.go index 171dc86fb..698b89242 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/rabbitmq_webhook.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/rabbitmq_webhook.go @@ -102,14 +102,20 @@ func (r *RabbitMQ) ValidateCreateOrUpdate() error { "number of replicas can not be 0 or less")) } - err := r.ValidateVersion(r) - if err != nil { + if r.Spec.Version == "" { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("version"), r.Name, - err.Error())) + "spec.version' is missing")) + } else { + err := r.ValidateVersion(r) + if err != nil { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("version"), + r.Name, + err.Error())) + } } - err = r.validateVolumes(r) + err := r.validateVolumes(r) if err != nil { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("podTemplate").Child("spec").Child("volumes"), r.Name, @@ -135,6 +141,12 @@ func (r *RabbitMQ) ValidateCreateOrUpdate() error { } } + if r.Spec.ConfigSecret != nil && r.Spec.ConfigSecret.Name == "" { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("configSecret").Child("name"), + r.Name, + "ConfigSecret Name can not be empty")) + } + if len(allErr) == 0 { return nil } diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/redis_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/redis_helpers.go index ebe5048e4..89f5064f1 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/redis_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/redis_helpers.go @@ -241,8 +241,13 @@ func (r *Redis) SetDefaults(rdVersion *catalog.RedisVersion, topology *core_util r.setDefaultAffinity(&r.Spec.PodTemplate, labels, topology) r.Spec.Monitor.SetDefaults() - if r.Spec.Monitor != nil && r.Spec.Monitor.Prometheus != nil && r.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { - r.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = rdVersion.Spec.SecurityContext.RunAsUser + 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 = rdVersion.Spec.SecurityContext.RunAsUser + } + if r.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup == nil { + r.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup = rdVersion.Spec.SecurityContext.RunAsUser + } } r.SetTLSDefaults() r.SetHealthCheckerDefaults() diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/redis_sentinel_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/redis_sentinel_helpers.go index 824617273..1b01eebec 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/redis_sentinel_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/redis_sentinel_helpers.go @@ -199,8 +199,13 @@ func (rs *RedisSentinel) SetDefaults(rdVersion *catalog.RedisVersion, topology * rs.setDefaultAffinity(&rs.Spec.PodTemplate, rs.OffshootSelectors(), topology) rs.Spec.Monitor.SetDefaults() - if rs.Spec.Monitor != nil && rs.Spec.Monitor.Prometheus != nil && rs.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { - rs.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = rdVersion.Spec.SecurityContext.RunAsUser + if rs.Spec.Monitor != nil && rs.Spec.Monitor.Prometheus != nil { + if rs.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser == nil { + rs.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsUser = rdVersion.Spec.SecurityContext.RunAsUser + } + if rs.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup == nil { + rs.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup = rdVersion.Spec.SecurityContext.RunAsUser + } } rs.SetTLSDefaults() rs.SetHealthCheckerDefaults() diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/zookeeper_helpers.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/zookeeper_helpers.go index f8a12dbc9..c0fdaddc6 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/zookeeper_helpers.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/zookeeper_helpers.go @@ -173,7 +173,7 @@ func (z *ZooKeeper) SetDefaults() { apis.SetDefaultResourceLimits(&z.Spec.PodTemplate.Spec.Resources, DefaultResources) if z.Spec.Replicas == nil { - z.Spec.Replicas = pointer.Int32P(3) + z.Spec.Replicas = pointer.Int32P(1) } if z.Spec.Halted { diff --git a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/zookeeper_webhook.go b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/zookeeper_webhook.go index 2dfb3bef4..ad23533a4 100644 --- a/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/zookeeper_webhook.go +++ b/vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/zookeeper_webhook.go @@ -87,11 +87,10 @@ func (z *ZooKeeper) ValidateDelete() (admission.Warnings, error) { func (z *ZooKeeper) ValidateCreateOrUpdate() (admission.Warnings, error) { var allErr field.ErrorList - // number of replicas can not be less than 3 - if z.Spec.Replicas != nil && *z.Spec.Replicas < 3 { + if z.Spec.Replicas != nil && *z.Spec.Replicas == 2 { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("replicas"), z.Name, - "number of replicas can not be less than 3")) + "zookeeper ensemble should have 3 or more replicas")) } err := z.validateVersion() 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 10b494ef2..c8ea9ca1c 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 @@ -516,11 +516,6 @@ func (in *DruidNode) DeepCopy() *DruidNode { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DruidSpec) DeepCopyInto(out *DruidSpec) { *out = *in - if in.Replicas != nil { - in, out := &in.Replicas, &out.Replicas - *out = new(int32) - **out = **in - } if in.Topology != nil { in, out := &in.Topology, &out.Topology *out = new(DruidClusterTopology) @@ -2003,6 +1998,21 @@ func (in *MemcachedStatus) DeepCopy() *MemcachedStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MetadataStorage) DeepCopyInto(out *MetadataStorage) { *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Namespace != nil { + in, out := &in.Namespace, &out.Namespace + *out = new(string) + **out = **in + } + if in.Type != nil { + in, out := &in.Type, &out.Type + *out = new(string) + **out = **in + } if in.CreateTables != nil { in, out := &in.CreateTables, &out.CreateTables *out = new(bool) @@ -3294,7 +3304,7 @@ func (in *PostgresRef) DeepCopyInto(out *PostgresRef) { if in.Service != nil { in, out := &in.Service, &out.Service *out = new(PostgresServiceRef) - **out = **in + (*in).DeepCopyInto(*out) } if in.Version != nil { in, out := &in.Version, &out.Version @@ -3317,6 +3327,21 @@ func (in *PostgresRef) DeepCopy() *PostgresRef { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PostgresServiceRef) DeepCopyInto(out *PostgresServiceRef) { *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Namespace != nil { + in, out := &in.Namespace, &out.Namespace + *out = new(string) + **out = **in + } + if in.PgPort != nil { + in, out := &in.PgPort, &out.PgPort + *out = new(string) + **out = **in + } return } diff --git a/vendor/kubedb.dev/apimachinery/crds/kubedb.com_druids.yaml b/vendor/kubedb.dev/apimachinery/crds/kubedb.com_druids.yaml index 2e21aac84..3025980e0 100644 --- a/vendor/kubedb.dev/apimachinery/crds/kubedb.com_druids.yaml +++ b/vendor/kubedb.dev/apimachinery/crds/kubedb.com_druids.yaml @@ -64,7 +64,6 @@ spec: type: type: string required: - - configSecret - type type: object disableSecurity: @@ -100,8 +99,8 @@ spec: type: string namespace: type: string - required: - - name + type: + type: string type: object podTemplate: properties: @@ -3456,9 +3455,6 @@ spec: type: array type: object type: object - replicas: - format: int32 - type: integer serviceTemplates: items: properties: @@ -24361,13 +24357,11 @@ spec: type: string pathsBase: type: string - required: - - name type: object required: - deepStorage + - metadataStorage - version - - zooKeeper type: object status: properties: diff --git a/vendor/kubedb.dev/apimachinery/crds/kubedb.com_ferretdbs.yaml b/vendor/kubedb.dev/apimachinery/crds/kubedb.com_ferretdbs.yaml index 32bdd89fe..641358b03 100644 --- a/vendor/kubedb.dev/apimachinery/crds/kubedb.com_ferretdbs.yaml +++ b/vendor/kubedb.dev/apimachinery/crds/kubedb.com_ferretdbs.yaml @@ -75,6 +75,8 @@ spec: version: type: string type: object + required: + - externallyManaged type: object halted: type: boolean diff --git a/vendor/modules.txt b/vendor/modules.txt index de7e126eb..a4a76cf80 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -680,7 +680,7 @@ github.com/go-openapi/swag # github.com/go-resty/resty/v2 v2.11.0 ## explicit; go 1.16 github.com/go-resty/resty/v2 -# github.com/go-sql-driver/mysql v1.7.0 +# github.com/go-sql-driver/mysql v1.7.1 ## explicit; go 1.13 github.com/go-sql-driver/mysql # github.com/goccy/go-json v0.9.11 @@ -1390,7 +1390,7 @@ kmodules.xyz/client-go/discovery kmodules.xyz/client-go/meta kmodules.xyz/client-go/policy/secomp kmodules.xyz/client-go/tools/certholder -# kmodules.xyz/custom-resources v0.29.0 +# kmodules.xyz/custom-resources v0.29.1 ## explicit; go 1.21.5 kmodules.xyz/custom-resources/apis/appcatalog kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1 @@ -1402,7 +1402,7 @@ kmodules.xyz/monitoring-agent-api/api/v1 ## explicit; go 1.21.5 kmodules.xyz/offshoot-api/api/v1 kmodules.xyz/offshoot-api/api/v2 -# kubedb.dev/apimachinery v0.41.0-beta.1.0.20240124061503-ce4799bb0e5c +# kubedb.dev/apimachinery v0.41.0-rc.0 ## explicit; go 1.21.5 kubedb.dev/apimachinery/apis kubedb.dev/apimachinery/apis/catalog