Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
k8s.io/klog/v2 v2.130.1
kmodules.xyz/client-go v0.34.2
kmodules.xyz/custom-resources v0.34.0
kubedb.dev/apimachinery v0.60.0
kubedb.dev/apimachinery v0.60.2-0.20260213100621-46868bd03949
sigs.k8s.io/controller-runtime v0.22.4
xorm.io/xorm v1.3.11
)
Expand Down Expand Up @@ -79,7 +79,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cert-manager/cert-manager v1.19.2 // indirect
github.com/cert-manager/cert-manager v1.19.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cilium/ebpf v0.11.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
Expand Down Expand Up @@ -261,15 +261,15 @@ require (
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
kmodules.xyz/apiversion v0.2.0 // indirect
kmodules.xyz/monitoring-agent-api v0.34.0 // indirect
kmodules.xyz/monitoring-agent-api v0.34.1 // indirect
kmodules.xyz/objectstore-api v0.34.0 // indirect
kmodules.xyz/offshoot-api v0.34.0 // indirect
kmodules.xyz/prober v0.34.0 // indirect
kmodules.xyz/resource-metadata v0.41.0 // indirect
kubeops.dev/operator-shard-manager v0.0.5 // indirect
kubeops.dev/petset v0.0.15 // indirect
kubeops.dev/sidekick v0.0.12 // indirect
kubestash.dev/apimachinery v0.23.0 // indirect
kubestash.dev/apimachinery v0.23.1-0.20260209084525-80db980e861f // indirect
open-cluster-management.io/api v1.1.1-0.20251222023835-510285203ee6 // indirect
sigs.k8s.io/gateway-api v1.4.0 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cert-manager/cert-manager v1.19.2 h1:jSprN1h5pgNDSl7HClAmIzXuTxic/5FXJ32kbQHqjlM=
github.com/cert-manager/cert-manager v1.19.2/go.mod h1:e9NzLtOKxTw7y99qLyWGmPo6mrC1Nh0EKKcMkRfK+GE=
github.com/cert-manager/cert-manager v1.19.3 h1:3d0Nk/HO3BOmAdBJNaBh+6YgaO3Ciey3xCpOjiX5Obs=
github.com/cert-manager/cert-manager v1.19.3/go.mod h1:e9NzLtOKxTw7y99qLyWGmPo6mrC1Nh0EKKcMkRfK+GE=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cilium/ebpf v0.11.0 h1:V8gS/bTCCjX9uUnkUFUpPsksM8n1lXBAvHcpiFk1X2Y=
Expand Down Expand Up @@ -1114,8 +1114,8 @@ kmodules.xyz/client-go v0.34.2 h1:2Cec+nyfj9kfbR+5KPK3AksxN6h4jSjhn/tw+Dhqggo=
kmodules.xyz/client-go v0.34.2/go.mod h1:kQRuGMxhb+B9rVdcfBzjK+PV7oBDo+SaDiQ66u1QG+4=
kmodules.xyz/custom-resources v0.34.0 h1:ljkIYzIq0A3Awj87kkpuYqS9aifuyR3Hr9q2OVKoojM=
kmodules.xyz/custom-resources v0.34.0/go.mod h1:pcA/n/CnrycjKCRNtU9Z+l5svhzFncLY2Kn9pqeXDVs=
kmodules.xyz/monitoring-agent-api v0.34.0 h1:SNgKvC1j8oYWQcdClyV2T5GsOQoG40c3pK9aYKm0j8A=
kmodules.xyz/monitoring-agent-api v0.34.0/go.mod h1:XFDfMHDZQeNEPdTDeDr4M0dT4UCWs+4IYzgHw7JDlms=
kmodules.xyz/monitoring-agent-api v0.34.1 h1:0ANZgff50xF9D9cFng1NBVmSeLwiYPsZKiFLcxAY9bQ=
kmodules.xyz/monitoring-agent-api v0.34.1/go.mod h1:XFDfMHDZQeNEPdTDeDr4M0dT4UCWs+4IYzgHw7JDlms=
kmodules.xyz/objectstore-api v0.34.0 h1:h16QGeKAJB27mj0rhvm3I0q0ulE99TgIulob/UkXzRc=
kmodules.xyz/objectstore-api v0.34.0/go.mod h1:x6snmU8evi1K0qcWKrTXbkSN18hamcuGraYGCgtG9JY=
kmodules.xyz/offshoot-api v0.34.0 h1:HnOOp8FrCjTWjtNApRDo6Ahe79tOlLrJmyye4xxO4Kk=
Expand All @@ -1124,16 +1124,16 @@ kmodules.xyz/prober v0.34.0 h1:ElZkZYCjLaytAA0M8EH42To7i9gh1IIX+d0qfaIohys=
kmodules.xyz/prober v0.34.0/go.mod h1:rsu/fxxfNxY70GDbH6Ju8G66459hi7AhWSSBoiIp8ic=
kmodules.xyz/resource-metadata v0.41.0 h1:9wUOg2EvAOW3n8I+tbZnE1PJDdolX+94/Mn7FBZZy9w=
kmodules.xyz/resource-metadata v0.41.0/go.mod h1:xntcQko2QLbLEHwGE4TQ7I/80fcBQzcexbep97Akstk=
kubedb.dev/apimachinery v0.60.0 h1:D2tSwXPs0qLAP3Ac6Xy+sOVIl3/oc7ZmYUwEGUfqWdw=
kubedb.dev/apimachinery v0.60.0/go.mod h1:tmfp77k7j2d5Bll3lPL9Ul5wEYSRLpekjOEnro2/rFA=
kubedb.dev/apimachinery v0.60.2-0.20260213100621-46868bd03949 h1:4fXF3Zw8IJV2iFIkyqIdktJL2CGSQzUma+/6GTyFT9E=
kubedb.dev/apimachinery v0.60.2-0.20260213100621-46868bd03949/go.mod h1:aCE7ly0M7DsStDdWwBql5dCG7cVUrqEwDu3tGokLwCo=
kubeops.dev/operator-shard-manager v0.0.5 h1:i7VnyUfIa9u3RQhSTVWNsooXcgmrWWxJyI9gJ10onE8=
kubeops.dev/operator-shard-manager v0.0.5/go.mod h1:NE6GzlhwLRiwiUUpqi4Uf+J7e/gniITM0uJnE5r1mzY=
kubeops.dev/petset v0.0.15 h1:iwTRFAp0RNw0A87sw2c97UZ6WIA9H/nhJBpDhXLa7fk=
kubeops.dev/petset v0.0.15/go.mod h1:sw96WiXfzhpmKpXj4a5AdmEHs0Bx4QMhf+iW15zY4Gg=
kubeops.dev/sidekick v0.0.12 h1:pmUjQLZDKxgREiM6z0PogLR1aDbgvkE9jRjbxG6dEt0=
kubeops.dev/sidekick v0.0.12/go.mod h1:RU7QH3E8DOLw15rBYlOOJSyczuwAnVVtYyZjJb00UB8=
kubestash.dev/apimachinery v0.23.0 h1:EB6w+lB0ACgnqIjtbyvRN5hVEmB8dVHSaN7SJCACHCY=
kubestash.dev/apimachinery v0.23.0/go.mod h1:zJEjHjd/nYcXFSW+RfGbLxZMJK41IOWjQGosoAWZDRg=
kubestash.dev/apimachinery v0.23.1-0.20260209084525-80db980e861f h1:nti4U+hCA4VH4+Fc9D9/AEpw2/nHkUgyAhZrLkpfMfQ=
kubestash.dev/apimachinery v0.23.1-0.20260209084525-80db980e861f/go.mod h1:zJEjHjd/nYcXFSW+RfGbLxZMJK41IOWjQGosoAWZDRg=
lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw=
Expand Down
45 changes: 40 additions & 5 deletions mariadb/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"crypto/x509"
"database/sql"
"fmt"
"os"

"kubedb.dev/apimachinery/apis/kubedb"
dbapi "kubedb.dev/apimachinery/apis/kubedb/v1"
Expand Down Expand Up @@ -140,17 +141,38 @@ func (o *KubeDBClientBuilder) getMariaDBBasicAuth() (string, string, error) {
}

func (o *KubeDBClientBuilder) SSLEnabledMariaDB() bool {
if o.db == nil {
return os.Getenv("REQUIRE_SSL") == "TRUE" || os.Getenv("REQUIRE_SSL") == "ON"
}
return o.db.Spec.TLS != nil && o.db.Spec.RequireSSL
}

func (o *KubeDBClientBuilder) getURL() string {
return fmt.Sprintf("%s.%s.%s.svc", o.podName, o.db.GoverningServiceName(), o.db.Namespace)
if o.db == nil {
if o.url != "" {
return o.url
} else {
return os.Getenv("GOVERNING_SERVICE_NAME")
}
} else {
if o.db.Spec.Distributed {
return fmt.Sprintf("%s.%s.%s.svc.%s", o.podName, o.db.GoverningServiceName(), o.db.Namespace, kubedb.KubeSliceDomainSuffix)
} else {
return fmt.Sprintf("%s.%s.%s.svc", o.podName, o.db.GoverningServiceName(), o.db.Namespace)
}
}
}

func (o *KubeDBClientBuilder) getConnectionString() (string, error) {
user, pass, err := o.getMariaDBBasicAuth()
if err != nil {
return "", err
var user, pass string
var err error
if o.db == nil {
user, pass = getMariaDBBasicAuth()
} else {
user, pass, err = o.getMariaDBBasicAuth()
if err != nil {
return "", err
}
}

if o.podName != "" {
Expand All @@ -160,8 +182,16 @@ func (o *KubeDBClientBuilder) getConnectionString() (string, error) {
tlsConfig := ""
if o.SSLEnabledMariaDB() {
// get client-secret

var secretName string
if o.db == nil {
secretName = os.Getenv("TLS_SECRET_NAME")
} else {
secretName = o.db.GetCertSecretName(dbapi.MariaDBClientCert)
}

var clientSecret core.Secret
err := o.kc.Get(o.ctx, client.ObjectKey{Namespace: o.db.Namespace, Name: o.db.GetCertSecretName(dbapi.MariaDBClientCert)}, &clientSecret)
err := o.kc.Get(o.ctx, client.ObjectKey{Namespace: o.db.Namespace, Name: secretName}, &clientSecret)
if err != nil {
return "", err
}
Expand All @@ -170,6 +200,7 @@ func (o *KubeDBClientBuilder) getConnectionString() (string, error) {
if !exists {
return "", fmt.Errorf("%v in not present in client secret", rootCAKey)
}

cacrt := value
certPool := x509.NewCertPool()
certPool.AppendCertsFromPEM(cacrt)
Expand Down Expand Up @@ -204,3 +235,7 @@ func (o *KubeDBClientBuilder) getConnectionString() (string, error) {
connector := fmt.Sprintf("%v:%v@tcp(%s:%d)/%s?%s", user, pass, o.url, 3306, "mysql", tlsConfig)
return connector, nil
}

func getMariaDBBasicAuth() (string, string) {
return os.Getenv("MYSQL_ROOT_USERNAME"), os.Getenv("MYSQL_ROOT_PASSWORD")
}

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

47 changes: 47 additions & 0 deletions vendor/kmodules.xyz/monitoring-agent-api/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,53 @@ type ServiceMonitorSpec struct {
// Interval at which metrics should be scraped
// +optional
Interval string `json:"interval,omitempty"`

// targetLabels defines the labels which are transferred from the
// associated Kubernetes `Service` object onto the ingested metrics.
//
// +optional
TargetLabels []string `json:"targetLabels,omitempty"`
// podTargetLabels defines the labels which are transferred from the
// associated Kubernetes `Pod` object onto the ingested metrics.
//
// +optional
PodTargetLabels []string `json:"podTargetLabels,omitempty"`

// endpoints defines the list of endpoints part of this ServiceMonitor.
// Defines how to scrape metrics from Kubernetes [Endpoints](https://kubernetes.io/docs/concepts/services-networking/service/#endpoints) objects.
// In most cases, an Endpoints object is backed by a Kubernetes [Service](https://kubernetes.io/docs/concepts/services-networking/service/) object with the same name and labels.
// +optional
Endpoints []Endpoint `json:"endpoints,omitempty"`
}

// Endpoint defines an endpoint serving Prometheus metrics to be scraped by
// Prometheus.
//
// +k8s:openapi-gen=true
type Endpoint struct {
// port defines the name of the Service port which this endpoint refers to.
//
// It takes precedence over `targetPort`.
// +optional
Port string `json:"port,omitempty"`

// metricRelabelings defines the relabeling rules to apply to the
// samples before ingestion.
//
// +optional
MetricRelabelConfigs []promapi.RelabelConfig `json:"metricRelabelings,omitempty"`

// relabelings defines the relabeling rules to apply the target's
// metadata labels.
//
// The Operator automatically adds relabelings for a few standard Kubernetes fields.
//
// The original scrape job's name is available via the `__tmp_prometheus_job_name` label.
//
// More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
//
// +optional
RelabelConfigs []promapi.RelabelConfig `json:"relabelings,omitempty"`
}

type PrometheusExporterSpec struct {
Expand Down
Loading
Loading