diff --git a/examples/tenant-prometheus.yaml b/examples/tenant-prometheus.yaml index c4d75079fbe..3cf2a4a6f28 100644 --- a/examples/tenant-prometheus.yaml +++ b/examples/tenant-prometheus.yaml @@ -97,4 +97,7 @@ spec: podManagementPolicy: Parallel prometheus: + image: "prom/prometheus" + sidecarimage: "alpine" + initimage: "busybox" diskCapacityGB: 5 diff --git a/helm/minio-operator/templates/minio.min.io_tenants.yaml b/helm/minio-operator/templates/minio.min.io_tenants.yaml index 8c7007d3c73..98129122b52 100644 --- a/helm/minio-operator/templates/minio.min.io_tenants.yaml +++ b/helm/minio-operator/templates/minio.min.io_tenants.yaml @@ -1421,6 +1421,10 @@ spec: type: object diskCapacityGB: type: integer + image: + type: string + initimage: + type: string labels: additionalProperties: type: string @@ -1510,6 +1514,8 @@ spec: type: string type: object type: object + sidecarimage: + type: string type: object requestAutoCert: type: boolean @@ -5370,6 +5376,10 @@ spec: type: object diskCapacityGB: type: integer + image: + type: string + initimage: + type: string labels: additionalProperties: type: string @@ -5459,6 +5469,8 @@ spec: type: string type: object type: object + sidecarimage: + type: string type: object requestAutoCert: type: boolean diff --git a/pkg/apis/minio.min.io/v2/constants.go b/pkg/apis/minio.min.io/v2/constants.go index 7f657395939..3ced42d5e92 100644 --- a/pkg/apis/minio.min.io/v2/constants.go +++ b/pkg/apis/minio.min.io/v2/constants.go @@ -157,6 +157,12 @@ const ConsoleCertPath = "/tmp/certs" // PrometheusImage specifies the container image for prometheus server const PrometheusImage = "quay.io/prometheus/prometheus:latest" +// PrometheusSideCarImage specifies the container image for prometheus sidecar +const PrometheusSideCarImage = "alpine" + +// PrometheusInitImage specifies the init container image for prometheus server +const PrometheusInitImage = "busybox" + // PrometheusInstanceLabel is applied to the prometheus server pod const PrometheusInstanceLabel = "v1.min.io/prometheus" diff --git a/pkg/apis/minio.min.io/v2/helper.go b/pkg/apis/minio.min.io/v2/helper.go index 3209acb3307..d8ec7ecdc97 100644 --- a/pkg/apis/minio.min.io/v2/helper.go +++ b/pkg/apis/minio.min.io/v2/helper.go @@ -365,6 +365,18 @@ func (t *Tenant) EnsureDefaults() *Tenant { } } + if t.HasPrometheusEnabled() { + if t.Spec.Prometheus.Image == "" { + t.Spec.Prometheus.Image = PrometheusImage + } + if t.Spec.Prometheus.SideCarImage == "" { + t.Spec.Prometheus.SideCarImage = PrometheusSideCarImage + } + if t.Spec.Prometheus.InitImage == "" { + t.Spec.Prometheus.InitImage = PrometheusInitImage + } + } + return t } diff --git a/pkg/apis/minio.min.io/v2/types.go b/pkg/apis/minio.min.io/v2/types.go index 4aa7badb86d..c652023b2b0 100644 --- a/pkg/apis/minio.min.io/v2/types.go +++ b/pkg/apis/minio.min.io/v2/types.go @@ -360,6 +360,17 @@ type AuditConfig struct { // PrometheusConfig defines configuration for Prometheus metrics server type PrometheusConfig struct { + // Image defines Prometheus container image. + // +optional + Image string `json:"image,omitempty"` + // SideCarImage defines container image to be used for sidecar + // Expects "alpine" image + // +optional + SideCarImage string `json:"sidecarimage,omitempty"` + // InitImage defines init container image to be used for Prometheus + // Expects "busybox" image + // +optional + InitImage string `json:"initimage,omitempty"` // DiskCapacityGB defines the disk capacity in GB available to the // Prometheus server // +optional diff --git a/pkg/resources/statefulsets/prometheus.go b/pkg/resources/statefulsets/prometheus.go index c4b7ef659ed..3114f7d6902 100644 --- a/pkg/resources/statefulsets/prometheus.go +++ b/pkg/resources/statefulsets/prometheus.go @@ -88,7 +88,7 @@ func prometheusServerContainer(t *miniov2.Tenant) corev1.Container { var runAsUser int64 = 1000 return corev1.Container{ Name: miniov2.PrometheusContainerName, - Image: miniov2.PrometheusImage, + Image: t.Spec.Prometheus.Image, Ports: []corev1.ContainerPort{ { ContainerPort: miniov2.PrometheusPort, @@ -119,7 +119,7 @@ func prometheusServerContainer(t *miniov2.Tenant) corev1.Container { func prometheusSidecarContainer(t *miniov2.Tenant) corev1.Container { return corev1.Container{ Name: miniov2.PrometheusContainerName + "-sidecar", - Image: "alpine", + Image: t.Spec.Prometheus.SideCarImage, ImagePullPolicy: t.Spec.ImagePullPolicy, VolumeMounts: prometheusVolumeMounts(t), Env: prometheusEnvVars(t), @@ -189,7 +189,7 @@ func NewForPrometheus(t *miniov2.Tenant, serviceName string) *appsv1.StatefulSet initContainers := []corev1.Container{ { Name: "prometheus-init-chown-data", - Image: "busybox", + Image: t.Spec.Prometheus.InitImage, Command: []string{ "chown", "-R", diff --git a/resources/base/crds/minio.min.io_tenants.yaml b/resources/base/crds/minio.min.io_tenants.yaml index 8c7007d3c73..98129122b52 100644 --- a/resources/base/crds/minio.min.io_tenants.yaml +++ b/resources/base/crds/minio.min.io_tenants.yaml @@ -1421,6 +1421,10 @@ spec: type: object diskCapacityGB: type: integer + image: + type: string + initimage: + type: string labels: additionalProperties: type: string @@ -1510,6 +1514,8 @@ spec: type: string type: object type: object + sidecarimage: + type: string type: object requestAutoCert: type: boolean @@ -5370,6 +5376,10 @@ spec: type: object diskCapacityGB: type: integer + image: + type: string + initimage: + type: string labels: additionalProperties: type: string @@ -5459,6 +5469,8 @@ spec: type: string type: object type: object + sidecarimage: + type: string type: object requestAutoCert: type: boolean