Skip to content

Commit

Permalink
Allow custom (non-propagating) stateful set metadata (#2337)
Browse files Browse the repository at this point in the history
* allow custom (non-propagating) sts metadata
  • Loading branch information
ramondeklein authored Oct 17, 2024
1 parent 00f9e7e commit 54a9f26
Show file tree
Hide file tree
Showing 17 changed files with 331 additions and 93 deletions.
47 changes: 47 additions & 0 deletions docs/tenant_crd.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,35 @@ Security Context
|===


[id="{anchor_prefix}-github-com-minio-operator-pkg-apis-minio-min-io-v2-poolsmetadata"]
==== PoolsMetadata

PoolsMetadata (`poolsMetadata`) defines custom labels and annotations for the MinIO pool stateful sets / pods. +

.Appears In:
****
- xref:{anchor_prefix}-github-com-minio-operator-pkg-apis-minio-min-io-v2-tenantspec[$$TenantSpec$$]
****

[cols="25a,75a", options="header"]
|===
| Field | Description

|*`labels`* __object (keys:string, values:string)__
|*Optional* +


If provided, append these labels to the MinIO statefulset / pods

|*`annotations`* __object (keys:string, values:string)__
|*Optional* +


If provided, append these annotations to the MinIO statefulset / pods

|===


[id="{anchor_prefix}-github-com-minio-operator-pkg-apis-minio-min-io-v2-servicemetadata"]
==== ServiceMetadata

Expand Down Expand Up @@ -727,6 +756,18 @@ If provided, append these labels to the Console service

If provided, append these annotations to the Console service

|*`kesServiceLabels`* __object (keys:string, values:string)__
|*Optional* +


If provided, append these labels to the KES service

|*`kesServiceAnnotations`* __object (keys:string, values:string)__
|*Optional* +


If provided, append these annotations to the KES service

|===


Expand Down Expand Up @@ -1154,6 +1195,12 @@ Directs the Operator to expose the MinIO and/or Console services. +

Specify custom labels and annotations to append to the MinIO service and/or Console service.

|*`poolsMetadata`* __xref:{anchor_prefix}-github-com-minio-operator-pkg-apis-minio-min-io-v2-poolsmetadata[$$PoolsMetadata$$]__
|*Optional* +


Specify custom labels and annotations to append to all pool statefulsets and pods.

|*`users`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#localobjectreference-v1-core[$$LocalObjectReference$$] array__
|*Optional* +

Expand Down
4 changes: 4 additions & 0 deletions examples/kustomization/tenant-certmanager/tenant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ metadata:
name: myminio
namespace: minio-tenant
spec:
## Assign labels to the pool
poolsMetadata:
labels:
app: minio
## Disable default tls certificates.
requestAutoCert: false
## Use certificates generated by cert-manager.
Expand Down
19 changes: 19 additions & 0 deletions helm/operator/templates/minio.min.io_tenants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3638,6 +3638,17 @@ spec:
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
poolsMetadata:
properties:
annotations:
additionalProperties:
type: string
type: object
labels:
additionalProperties:
type: string
type: object
type: object
priorityClassName:
type: string
prometheusOperator:
Expand Down Expand Up @@ -3736,6 +3747,14 @@ spec:
additionalProperties:
type: string
type: object
kesServiceAnnotations:
additionalProperties:
type: string
type: object
kesServiceLabels:
additionalProperties:
type: string
type: object
minioServiceAnnotations:
additionalProperties:
type: string
Expand Down
6 changes: 6 additions & 0 deletions helm/tenant/templates/tenant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ spec:
## Secret with default environment variable configurations
configuration:
name: {{ .configuration.name }}
{{- if hasKey . "poolsMetadata" }}
poolsMetadata: {{- if eq (len .poolsMetadata) 0 }} {} {{- end }}
{{- with (dig "poolsMetadata" (dict) .) }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
pools:
{{- range (dig "pools" (list) .) }}
- servers: {{ dig "servers" 4 . }}
Expand Down
10 changes: 10 additions & 0 deletions helm/tenant/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ tenant:
secretKey: minio123
#existingSecret: true

###
# Metadata that will be added to the statefulset and pods of all pools
poolsMetadata:
###
# Specify `annotations <https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/>`__ to associate to Tenant pods.
annotations: { }
###
# Specify `labels <https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/>`__ to associate to Tenant pods.
labels: { }

###
# If this variable is set to true, then enable the usage of an existing Kubernetes secret to set environment variables for the Tenant.
# The existing Kubernetes secret name must be placed under .tenant.configuration.name e.g. existing-minio-env-configuration
Expand Down
14 changes: 0 additions & 14 deletions pkg/apis/minio.min.io/v2/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,20 +878,6 @@ func GetClusterDomain() string {
return k8sClusterDomain
}

// MergeMaps merges two maps and returns the union
func MergeMaps(a, b map[string]string) map[string]string {
if a == nil {
a = map[string]string{}
}
if b == nil {
b = map[string]string{}
}
for k, v := range b {
a[k] = v
}
return a
}

// ToMap converts a slice of env vars to a map of Name and value
func ToMap(envs []corev1.EnvVar) map[string]string {
newMap := make(map[string]string)
Expand Down
29 changes: 29 additions & 0 deletions pkg/apis/minio.min.io/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ type TenantSpec struct {
ServiceMetadata *ServiceMetadata `json:"serviceMetadata,omitempty"`
// *Optional* +
//
// Specify custom labels and annotations to append to all pool statefulsets and pods.
// +optional
PoolsMetadata *PoolsMetadata `json:"poolsMetadata,omitempty"`
// *Optional* +
//
// An array of https://kubernetes.io/docs/concepts/configuration/secret/[Kubernetes opaque secrets] to use for generating MinIO users during tenant provisioning. +
//
// Each element in the array is an object consisting of a key-value pair `name: <string>`, where the `<string>` references an opaque Kubernetes secret. +
Expand Down Expand Up @@ -395,6 +400,30 @@ type ServiceMetadata struct {
// If provided, append these annotations to the Console service
// +optional
ConsoleServiceAnnotations map[string]string `json:"consoleServiceAnnotations,omitempty"`
// *Optional* +
//
// If provided, append these labels to the KES service
// +optional
KESServiceLabels map[string]string `json:"kesServiceLabels,omitempty"`
// *Optional* +
//
// If provided, append these annotations to the KES service
// +optional
KESServiceAnnotations map[string]string `json:"kesServiceAnnotations,omitempty"`
}

// PoolsMetadata (`poolsMetadata`) defines custom labels and annotations for the MinIO pool stateful sets / pods. +
type PoolsMetadata struct {
// *Optional* +
//
// If provided, append these labels to the MinIO statefulset / pods
// +optional
Labels map[string]string `json:"labels,omitempty"`
// *Optional* +
//
// If provided, append these annotations to the MinIO statefulset / pods
// +optional
Annotations map[string]string `json:"annotations,omitempty"`
}

// LocalCertificateReference (`externalCertSecret`, `externalCaCertSecret`,`clientCertSecret`) contains a Kubernetes secret containing TLS certificates or Certificate Authority files for use with enabling TLS in the MinIO Tenant. +
Expand Down
49 changes: 49 additions & 0 deletions pkg/apis/minio.min.io/v2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions pkg/client/applyconfiguration/minio.min.io/v2/poolsmetadata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions pkg/client/applyconfiguration/minio.min.io/v2/servicemetadata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 54a9f26

Please sign in to comment.