Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
refactor
  • Loading branch information
jiuker authored and pjuarezd committed Dec 9, 2024
1 parent 3bd8d7f commit 9f11411
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/tenant_crd.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ Directs the MinIO Operator to use prometheus operator. +

Tenant scrape configuration will be added to prometheus managed by the prometheus-operator.

|*`prometheusOperatorScrape`* __string array__
|*`prometheusOperatorScrapeMetricsPath`* __string array__
|*Optional* +


Expand Down
2 changes: 1 addition & 1 deletion helm/operator/templates/minio.min.io_tenants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3682,7 +3682,7 @@ spec:
type: string
prometheusOperator:
type: boolean
prometheusOperatorScrape:
prometheusOperatorScrapeMetricsPath:
items:
type: string
type: array
Expand Down
2 changes: 1 addition & 1 deletion helm/operator/templates/sts.min.io_policybindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.4
operator.min.io/version: v6.0.4
operator.min.io/version: v5.0.15
name: policybindings.sts.min.io
spec:
group: sts.min.io
Expand Down
3 changes: 0 additions & 3 deletions pkg/apis/minio.min.io/v2/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,6 @@ const StatefulSetPrefix = "ss"
// StatefulSetLegacyPrefix by old operators
const StatefulSetLegacyPrefix = "zone"

// MinIOPrometheusPathPrefix is the path prefix where MinIO tenant exposes cluster Prometheus metrics
const MinIOPrometheusPathPrefix = "/minio/v2/metrics/"

// MinIOPrometheusScrapeInterval defines how frequently to scrape targets.
const MinIOPrometheusScrapeInterval = 30 * time.Second

Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/minio.min.io/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ type TenantSpec struct {
// The name of the Prometheus instance to scrape metrics from.
//
// +optional
PrometheusOperatorScrape []string `json:"prometheusOperatorScrape,omitempty"`
PrometheusOperatorScrapeMetricsPath []string `json:"prometheusOperatorScrapeMetricsPath,omitempty"`
// *Optional* +
//
// The https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/[Kubernetes Service Account] to use for running MinIO pods created as part of the Tenant. +
Expand Down
8 changes: 4 additions & 4 deletions pkg/resources/configmaps/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ func GetPrometheusConfig(t *miniov2.Tenant, accessKey, secretKey string) *Promet
ScrapeConfigs: []ScrapeConfig{},
}

if len(t.Spec.PrometheusOperatorScrape) == 0 {
t.Spec.PrometheusOperatorScrape = []string{"cluster"}
if len(t.Spec.PrometheusOperatorScrapeMetricsPath) == 0 {
t.Spec.PrometheusOperatorScrapeMetricsPath = []string{"/minio/v2/metrics/cluster"}
}

for _, scrape := range t.Spec.PrometheusOperatorScrape {
for _, scrape := range t.Spec.PrometheusOperatorScrapeMetricsPath {
promConfig.ScrapeConfigs = append(promConfig.ScrapeConfigs, ScrapeConfig{
JobName: t.PrometheusConfigJobName(),
BearerToken: bearerToken,
MetricsPath: fmt.Sprintf("%s%s", miniov2.MinIOPrometheusPathPrefix, scrape),
MetricsPath: scrape,
Scheme: minioScheme,
TLSConfig: tlsConfig{
CAFile: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt",
Expand Down
2 changes: 1 addition & 1 deletion resources/base/crds/minio.min.io_tenants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3682,7 +3682,7 @@ spec:
type: string
prometheusOperator:
type: boolean
prometheusOperatorScrape:
prometheusOperatorScrapeMetricsPath:
items:
type: string
type: array
Expand Down
2 changes: 1 addition & 1 deletion resources/base/crds/sts.min.io_policybindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.4
operator.min.io/version: v6.0.4
operator.min.io/version: v5.0.15
name: policybindings.sts.min.io
spec:
group: sts.min.io
Expand Down

0 comments on commit 9f11411

Please sign in to comment.