From a9e5f69c5133c5f53e04f36aecad248ddef19190 Mon Sep 17 00:00:00 2001 From: Matthew Toohey Date: Sat, 28 Oct 2023 19:19:02 +1100 Subject: [PATCH] Add Lifecycle hooks configuration to Tenant --- .../templates/minio.min.io_tenants.yaml | 103 ++++++++++++++++++ helm/tenant/templates/tenant.yaml | 3 + helm/tenant/values.yaml | 3 + pkg/apis/minio.min.io/v2/types.go | 4 + .../statefulsets/minio-statefulset.go | 1 + resources/base/crds/minio.min.io_tenants.yaml | 103 ++++++++++++++++++ 6 files changed, 217 insertions(+) diff --git a/helm/operator/templates/minio.min.io_tenants.yaml b/helm/operator/templates/minio.min.io_tenants.yaml index 4dec342a7c8..b322ae2135f 100644 --- a/helm/operator/templates/minio.min.io_tenants.yaml +++ b/helm/operator/templates/minio.min.io_tenants.yaml @@ -2234,6 +2234,109 @@ spec: required: - kesSecret type: object + lifecycle: + properties: + postStart: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object liveness: properties: exec: diff --git a/helm/tenant/templates/tenant.yaml b/helm/tenant/templates/tenant.yaml index 1dabdf52136..9b6dcf4c742 100644 --- a/helm/tenant/templates/tenant.yaml +++ b/helm/tenant/templates/tenant.yaml @@ -111,6 +111,9 @@ spec: {{- with (dig "startup" (dict) .) }} startup: {{- toYaml . | nindent 4 }} {{- end }} + {{- with (dig "lifecycle" (dict) .) }} + lifecycle: {{- toYaml . | nindent 4 }} + {{- end }} {{- with (dig "exposeServices" (dict) .) }} exposeServices: {{- toYaml . | nindent 4 }} {{- end }} diff --git a/helm/tenant/values.yaml b/helm/tenant/values.yaml index b0c7727b42e..066ed4ec123 100644 --- a/helm/tenant/values.yaml +++ b/helm/tenant/values.yaml @@ -147,6 +147,9 @@ tenant: # Startup Probe for container startup. Container will be restarted if the probe fails. # Refer https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ startup: { } + # Lifecycle hooks for container. + # Refer https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/ + lifecycle: { } ## exposeServices defines the exposure of the MinIO object storage and Console services. ## service is exposed as a loadbalancer in k8s service. exposeServices: { } diff --git a/pkg/apis/minio.min.io/v2/types.go b/pkg/apis/minio.min.io/v2/types.go index 8c6ed8c6ec2..d2474c70629 100644 --- a/pkg/apis/minio.min.io/v2/types.go +++ b/pkg/apis/minio.min.io/v2/types.go @@ -254,6 +254,10 @@ type TenantSpec struct { // +optional Startup *corev1.Probe `json:"startup,omitempty"` + // Lifecycle hooks for container. + // +optional + Lifecycle *corev1.Lifecycle `json:"lifecycle,omitempty"` + // S3 related features can be disabled or enabled such as `bucketDNS` etc. Features *Features `json:"features,omitempty"` // *Optional* + diff --git a/pkg/resources/statefulsets/minio-statefulset.go b/pkg/resources/statefulsets/minio-statefulset.go index 0856e0fdbac..b8e58a218d0 100644 --- a/pkg/resources/statefulsets/minio-statefulset.go +++ b/pkg/resources/statefulsets/minio-statefulset.go @@ -346,6 +346,7 @@ func poolMinioServerContainer(t *miniov2.Tenant, skipEnvVars map[string][]byte, LivenessProbe: t.Spec.Liveness, ReadinessProbe: t.Spec.Readiness, StartupProbe: t.Spec.Startup, + Lifecycle: t.Spec.Lifecycle, SecurityContext: poolContainerSecurityContext(pool), } } diff --git a/resources/base/crds/minio.min.io_tenants.yaml b/resources/base/crds/minio.min.io_tenants.yaml index 4dec342a7c8..b322ae2135f 100644 --- a/resources/base/crds/minio.min.io_tenants.yaml +++ b/resources/base/crds/minio.min.io_tenants.yaml @@ -2234,6 +2234,109 @@ spec: required: - kesSecret type: object + lifecycle: + properties: + postStart: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object liveness: properties: exec: