From 87677e260eaaa5dbce6f2fbf7d7af1c014cd447e Mon Sep 17 00:00:00 2001 From: Matthew Toohey Date: Sat, 28 Oct 2023 19:19:02 +1100 Subject: [PATCH 1/2] 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 0b7152e560f..1d3fb321e08 100644 --- a/helm/tenant/values.yaml +++ b/helm/tenant/values.yaml @@ -266,6 +266,9 @@ tenant: # Refer startup: { } ### + # The `Lifecycle hooks `__ for container. + lifecycle: { } + ### # Directs the Operator to deploy the MinIO S3 API and Console services as LoadBalancer objects. # # If the Kubernetes cluster has a configured LoadBalancer, it can attempt to route traffic to those services automatically. 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 1a17c018ca0..58722e67f5d 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: From 39167b5d48d752cddad248b052b3842bdb1a7923 Mon Sep 17 00:00:00 2001 From: pjuarezd Date: Mon, 6 Nov 2023 20:42:24 -0800 Subject: [PATCH 2/2] Regen CRD docs to include Lifecycle Signed-off-by: pjuarezd --- docs/tenant_crd.adoc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/tenant_crd.adoc b/docs/tenant_crd.adoc index f44aa17a2f6..e5aef0f1899 100644 --- a/docs/tenant_crd.adoc +++ b/docs/tenant_crd.adoc @@ -255,11 +255,11 @@ KESConfig (`kes`) defines the configuration of the https://github.com/minio/kes[ |*`gcpCredentialSecretName`* __string__ |*Optional* + - Specify the GCP default credentials to be used for KES to authenticate to GCP key store + Specify the GCP default credentials to be used for KES to authenticate to GCP key store |*`gcpWorkloadIdentityPool`* __string__ |*Optional* + - Specify the name of the workload identity pool (This is required for generating service account token) + Specify the name of the workload identity pool (This is required for generating service account token) |*`annotations`* __object (keys:string, values:string)__ |*Optional* + @@ -749,6 +749,9 @@ TenantSpec (`spec`) defines the configuration of a MinIO Tenant object. + |*`startup`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#probe-v1-core[$$Probe$$]__ |Startup Probe allows to configure a max grace period for a pod to start before getting traffic routed to it. +|*`lifecycle`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#lifecycle-v1-core[$$Lifecycle$$]__ +|Lifecycle hooks for container. + |*`features`* __xref:{anchor_prefix}-github-com-minio-operator-pkg-apis-minio-min-io-v2-features[$$Features$$]__ |S3 related features can be disabled or enabled such as `bucketDNS` etc.