diff --git a/helm/tenant/templates/tenant.yaml b/helm/tenant/templates/tenant.yaml index e1e9ee802e7..2287bc89cde 100644 --- a/helm/tenant/templates/tenant.yaml +++ b/helm/tenant/templates/tenant.yaml @@ -157,6 +157,9 @@ spec: {{- with (dig "env" (list) .) }} env: {{- toYaml . | nindent 4 }} {{- end }} + {{- with (dig "hostAliases" (list) .) }} + hostAliases: {{- toYaml . | nindent 4 }} + {{- end }} {{- if dig "priorityClassName" "" . }} priorityClassName: {{ dig "priorityClassName" "" . }} {{- end }} diff --git a/helm/tenant/values.yaml b/helm/tenant/values.yaml index 32659a46d63..0156d55fdfd 100644 --- a/helm/tenant/values.yaml +++ b/helm/tenant/values.yaml @@ -362,6 +362,17 @@ tenant: # Add environment variables to be set in MinIO container (https://github.com/minio/minio/tree/master/docs/config) env: [ ] ### + # Add custom host aliases to MinIO pods. + # + # Example: + # + # .. code-block:: yaml + # + # - ip: "10.10.10.10" + # hostnames: + # - "internal.example.local" + hostAliases: [ ] + ### # PriorityClassName indicates the Pod priority and hence importance of a Pod relative to other Pods. # This is applied to MinIO pods only. # Refer Kubernetes documentation for details https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass/ diff --git a/pkg/apis/minio.min.io/v2/types.go b/pkg/apis/minio.min.io/v2/types.go index 4ce91583a1b..d0ce0a9d01c 100644 --- a/pkg/apis/minio.min.io/v2/types.go +++ b/pkg/apis/minio.min.io/v2/types.go @@ -298,6 +298,11 @@ type TenantSpec struct { PriorityClassName string `json:"priorityClassName,omitempty"` // *Optional* + // + // Maps IP addresses to hostnames at the pod level. Entries are added to the `/etc/hosts` file on each MinIO pod. + // +optional + HostAliases []corev1.HostAlias `json:"hostAliases,omitempty"` + // *Optional* + + // // The pull policy for the MinIO Docker image. Specify one of the following: + // // * `Always` + diff --git a/pkg/apis/minio.min.io/v2/zz_generated.deepcopy.go b/pkg/apis/minio.min.io/v2/zz_generated.deepcopy.go index a0c8bc733b3..011edf2d800 100644 --- a/pkg/apis/minio.min.io/v2/zz_generated.deepcopy.go +++ b/pkg/apis/minio.min.io/v2/zz_generated.deepcopy.go @@ -837,6 +837,13 @@ func (in *TenantSpec) DeepCopyInto(out *TenantSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.HostAliases != nil { + in, out := &in.HostAliases, &out.HostAliases + *out = make([]v1.HostAlias, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } diff --git a/pkg/client/applyconfiguration/minio.min.io/v2/tenantspec.go b/pkg/client/applyconfiguration/minio.min.io/v2/tenantspec.go index 5ec69981336..91137162c2d 100644 --- a/pkg/client/applyconfiguration/minio.min.io/v2/tenantspec.go +++ b/pkg/client/applyconfiguration/minio.min.io/v2/tenantspec.go @@ -51,6 +51,7 @@ type TenantSpecApplyConfiguration struct { PrometheusOperatorScrapeMetricsPaths []string `json:"prometheusOperatorScrapeMetricsPaths,omitempty"` ServiceAccountName *string `json:"serviceAccountName,omitempty"` PriorityClassName *string `json:"priorityClassName,omitempty"` + HostAliases []v1.HostAlias `json:"hostAliases,omitempty"` ImagePullPolicy *v1.PullPolicy `json:"imagePullPolicy,omitempty"` SideCars *SideCarsApplyConfiguration `json:"sideCars,omitempty"` ExposeServices *ExposeServicesApplyConfiguration `json:"exposeServices,omitempty"` @@ -287,6 +288,16 @@ func (b *TenantSpecApplyConfiguration) WithPriorityClassName(value string) *Tena return b } +// WithHostAliases adds the given value to the HostAliases field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the HostAliases field. +func (b *TenantSpecApplyConfiguration) WithHostAliases(values ...v1.HostAlias) *TenantSpecApplyConfiguration { + for i := range values { + b.HostAliases = append(b.HostAliases, values[i]) + } + return b +} + // WithImagePullPolicy sets the ImagePullPolicy field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the ImagePullPolicy field is set to the value of the last call. diff --git a/pkg/resources/statefulsets/minio-statefulset.go b/pkg/resources/statefulsets/minio-statefulset.go index 16a92c8179e..a9f5edece75 100644 --- a/pkg/resources/statefulsets/minio-statefulset.go +++ b/pkg/resources/statefulsets/minio-statefulset.go @@ -659,6 +659,7 @@ func NewPool(args *NewPoolArgs) *appsv1.StatefulSet { SecurityContext: poolSecurityContext(pool, poolStatus), ServiceAccountName: t.Spec.ServiceAccountName, PriorityClassName: t.Spec.PriorityClassName, + HostAliases: t.Spec.HostAliases, TerminationGracePeriodSeconds: pool.TerminationGracePeriodSeconds, }, }, diff --git a/resources/base/crds/minio.min.io_tenants.yaml b/resources/base/crds/minio.min.io_tenants.yaml index f4cf809d1ff..27b82ef4753 100644 --- a/resources/base/crds/minio.min.io_tenants.yaml +++ b/resources/base/crds/minio.min.io_tenants.yaml @@ -3778,6 +3778,18 @@ spec: type: boolean serviceAccountName: type: string + hostAliases: + items: + properties: + hostnames: + items: + type: string + type: array + x-kubernetes-list-type: atomic + ip: + type: string + type: object + type: array serviceMetadata: properties: consoleServiceAnnotations: