diff --git a/api/v1alpha1/tenantcontrolplane_registrysettings.go b/api/v1alpha1/tenantcontrolplane_registrysettings.go new file mode 100644 index 0000000..2616d1b --- /dev/null +++ b/api/v1alpha1/tenantcontrolplane_registrysettings.go @@ -0,0 +1,18 @@ +// Copyright 2022 Clastix Labs +// SPDX-License-Identifier: Apache-2.0 + +package v1alpha1 + +type RegistrySettings struct { + // +kubebuilder:default="registry.k8s.io" + Registry string `json:"registry,omitempty"` + // The tag to append to all the Control Plane container images. + // Optional. + TagSuffix string `json:"tagSuffix,omitempty"` + // +kubebuilder:default="kube-apiserver" + APIServerImage string `json:"apiServerImage,omitempty"` + // +kubebuilder:default="kube-controller-manager" + ControllerManagerImage string `json:"controllerManagerImage,omitempty"` + // +kubebuilder:default="kube-scheduler" + SchedulerImage string `json:"schedulerImage,omitempty"` +} diff --git a/api/v1alpha1/tenantcontrolplane_registrysettings_funcs.go b/api/v1alpha1/tenantcontrolplane_registrysettings_funcs.go new file mode 100644 index 0000000..d1bfd73 --- /dev/null +++ b/api/v1alpha1/tenantcontrolplane_registrysettings_funcs.go @@ -0,0 +1,34 @@ +// Copyright 2022 Clastix Labs +// SPDX-License-Identifier: Apache-2.0 + +package v1alpha1 + +import ( + "fmt" +) + +func (r *RegistrySettings) buildContainerImage(name, tag string) (image string) { + if len(r.Registry) > 0 { + image = fmt.Sprintf("%s/", r.Registry) + } + + image += fmt.Sprintf("%s:%s", name, tag) + + if len(r.TagSuffix) > 0 { + image += r.TagSuffix + } + + return image +} + +func (r *RegistrySettings) KubeAPIServerImage(version string) string { + return r.buildContainerImage(r.APIServerImage, version) +} + +func (r *RegistrySettings) KubeSchedulerImage(version string) string { + return r.buildContainerImage(r.SchedulerImage, version) +} + +func (r *RegistrySettings) KubeControllerManagerImage(version string) string { + return r.buildContainerImage(r.ControllerManagerImage, version) +} diff --git a/api/v1alpha1/tenantcontrolplane_types.go b/api/v1alpha1/tenantcontrolplane_types.go index a8ef8f4..8598367 100644 --- a/api/v1alpha1/tenantcontrolplane_types.go +++ b/api/v1alpha1/tenantcontrolplane_types.go @@ -103,6 +103,10 @@ type ControlPlaneComponentsResources struct { } type DeploymentSpec struct { + // RegistrySettings allows to override the default images for the given Tenant Control Plane instance. + // It could be used to point to a different container registry rather than the public one. + // +kubebuilder:default={registry:"registry.k8s.io",apiServerImage:"kube-apiserver",controllerManagerImage:"kube-controller-manager",schedulerImage:"kube-scheduler"} + RegistrySettings RegistrySettings `json:"registrySettings,omitempty"` // +kubebuilder:default=2 Replicas int32 `json:"replicas,omitempty"` // NodeSelector is a selector which must be true for the pod to fit on a node. diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 69d7077..42e0f00 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -577,6 +577,7 @@ func (in *DatastoreUsedSecret) DeepCopy() *DatastoreUsedSecret { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DeploymentSpec) DeepCopyInto(out *DeploymentSpec) { *out = *in + out.RegistrySettings = in.RegistrySettings if in.NodeSelector != nil { in, out := &in.NodeSelector, &out.NodeSelector *out = make(map[string]string, len(*in)) @@ -1126,6 +1127,21 @@ func (in *PublicKeyPrivateKeyPairStatus) DeepCopy() *PublicKeyPrivateKeyPairStat return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RegistrySettings) DeepCopyInto(out *RegistrySettings) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegistrySettings. +func (in *RegistrySettings) DeepCopy() *RegistrySettings { + if in == nil { + return nil + } + out := new(RegistrySettings) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecretReference) DeepCopyInto(out *SecretReference) { *out = *in