Skip to content

Commit

Permalink
Enable/Disable prometheus during tenant creation (#1187)
Browse files Browse the repository at this point in the history
Enable prometheus during tenant creation
  • Loading branch information
reivaj05 committed Jun 29, 2022
1 parent 7978bd0 commit 4938596
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
30 changes: 30 additions & 0 deletions kubectl-minio/cmd/resources/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ type TenantOptions struct {
AuditLogsPGImage string
AuditLogsPGInitImage string
AuditLogsStorageClass string
EnablePrometheus bool
PrometheusDiskSpace int
PrometheusStorageClass string
PrometheusImage string
PrometheusSidecarImage string
PrometheusInitImage string
}

// Validate Tenant Options
Expand Down Expand Up @@ -147,6 +153,9 @@ func NewTenant(opts *TenantOptions, userSecret *v1.Secret) (*miniov2.Tenant, err
if opts.EnableAuditLogs {
t.Spec.Log = getAuditLogConfig(opts)
}
if opts.EnablePrometheus {
t.Spec.Prometheus = getPrometheusConfig(opts)
}

t.EnsureDefaults()

Expand Down Expand Up @@ -200,3 +209,24 @@ func createLogConfig(diskSpace int64, auditMaxCap int, name string, storage *str
},
}
}

func getPrometheusConfig(opts *TenantOptions) *miniov2.PrometheusConfig {
var prometheusStorageClass *string
if opts.PrometheusStorageClass != "" {
prometheusStorageClass = &opts.PrometheusStorageClass
}
prometheusConfig := &miniov2.PrometheusConfig{
DiskCapacityDB: &opts.PrometheusDiskSpace,
StorageClassName: prometheusStorageClass,
}
if opts.PrometheusImage != "" {
prometheusConfig.Image = opts.PrometheusImage
}
if opts.PrometheusSidecarImage != "" {
prometheusConfig.SideCarImage = opts.PrometheusSidecarImage
}
if opts.PrometheusInitImage != "" {
prometheusConfig.InitImage = opts.PrometheusInitImage
}
return prometheusConfig
}
5 changes: 5 additions & 0 deletions kubectl-minio/cmd/tenant-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ func newTenantCreateCmd(out io.Writer, errOut io.Writer) *cobra.Command {
f.StringVar(&c.tenantOpts.AuditLogsPGImage, "audit-logs-pg-image", "", "(Only used when enable-audit-logs is on) The PostgreSQL Docker image to use for audit logs")
f.StringVar(&c.tenantOpts.AuditLogsPGInitImage, "audit-logs-pg-init-image", "", "(Only used when enable-audit-logs is on) Defines the Docker image to use as the init container for running the postgres server in audit logs")
f.StringVar(&c.tenantOpts.AuditLogsStorageClass, "audit-logs-storage-class", "", "(Only used when enable-audit-logs is on) Storage class for audit logs")
f.BoolVar(&c.tenantOpts.EnablePrometheus, "enable-prometheus", true, "Enable/Disable prometheus")
f.IntVar(&c.tenantOpts.PrometheusDiskSpace, "prometheus-disk-space", 5, "(Only used when enable-prometheus is on) Disk space for prometheus")
f.StringVar(&c.tenantOpts.PrometheusImage, "prometheus-image", "", "(Only used when enable-prometheus is on) The Docker image to use for prometheus")
f.StringVar(&c.tenantOpts.PrometheusSidecarImage, "prometheus-sidecar-image", "", "(Only used when enable-prometheus is on) The Docker image to use for prometheus sidecar")
f.StringVar(&c.tenantOpts.PrometheusImage, "prometheus-init-image", "", "(Only used when enable-prometheus is on) Defines the Docker image to use as the init container for running prometheus")
f.BoolVarP(&c.output, "output", "o", false, "generate tenant yaml for 'kubectl apply -f tenant.yaml'")

cmd.MarkFlagRequired("servers")
Expand Down

0 comments on commit 4938596

Please sign in to comment.