From af2889e56dee93bb6e9ef944b15ef28cff899d3b 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 24331b5b942..b06226fa719 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 ae3202e4025..e2f8b8eec5a 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 a563708dbc1..d9bd5fc73e1 100644 --- a/pkg/resources/statefulsets/minio-statefulset.go +++ b/pkg/resources/statefulsets/minio-statefulset.go @@ -348,6 +348,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 24331b5b942..b06226fa719 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: