mirror of
https://github.com/ysoftdevs/gardener-extension-shoot-fleet-agent.git
synced 2026-04-20 15:31:49 +02:00
Added support for configuration per project
Shoots with type==Infrastructure will not be considered to be added to Fleet
This commit is contained in:
@@ -3,7 +3,6 @@ package config
|
||||
import (
|
||||
healthcheckconfig "github.com/gardener/gardener/extensions/pkg/controller/healthcheck/config"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
componentbaseconfig "k8s.io/component-base/config"
|
||||
)
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
@@ -12,15 +11,23 @@ import (
|
||||
type FleetAgentConfig struct {
|
||||
metav1.TypeMeta
|
||||
|
||||
// ClientConnection specifies the kubeconfig file and client connection
|
||||
// settings for the proxy server to use when communicating with the apiserver.
|
||||
ClientConnection *componentbaseconfig.ClientConnectionConfiguration
|
||||
// DefaultConfiguration holds default config applied if no project config found
|
||||
DefaultConfiguration ProjectConfig
|
||||
|
||||
// ProjectConfiguration holds configuration overrides for each project
|
||||
ProjectConfiguration map[string]ProjectConfig
|
||||
|
||||
HealthCheckConfig *healthcheckconfig.HealthCheckConfig
|
||||
}
|
||||
|
||||
// ProjectConfig holds configuration for single project
|
||||
type ProjectConfig struct {
|
||||
// Kubeconfig contains base64 encoded kubeconfig
|
||||
Kubeconfig string
|
||||
|
||||
// labels to use in Fleet Cluster registration
|
||||
Labels map[string]string
|
||||
|
||||
//namespace to store clusters registrations in Fleet managers cluster
|
||||
Namespace string
|
||||
|
||||
HealthCheckConfig *healthcheckconfig.HealthCheckConfig
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package v1alpha1
|
||||
import (
|
||||
healthcheckconfig "github.com/gardener/gardener/extensions/pkg/controller/healthcheck/config"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1"
|
||||
)
|
||||
|
||||
// +genclient
|
||||
@@ -13,16 +12,23 @@ import (
|
||||
type FleetAgentConfig struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
|
||||
// ClientConnection specifies the kubeconfig file and client connection
|
||||
// settings for the proxy server to use when communicating with the apiserver.
|
||||
// +optional
|
||||
ClientConnection *componentbaseconfigv1alpha1.ClientConnectionConfiguration `json:"clientConnection,omitempty"`
|
||||
// DefaultConfiguration holds default config applied if no project config found
|
||||
DefaultConfiguration ProjectConfig `json:"defaultConfig,omitempty"`
|
||||
|
||||
// ProjectConfiguration holds configuration overrides for each project
|
||||
ProjectConfiguration map[string]ProjectConfig `json:"projectConfig,omitempty"`
|
||||
|
||||
HealthCheckConfig *healthcheckconfig.HealthCheckConfig `json:"healthCheckConfig,omitempty"`
|
||||
}
|
||||
|
||||
// ProjectConfig holds configuration for single project
|
||||
type ProjectConfig struct {
|
||||
// Kubeconfig contains base64 encoded kubeconfig
|
||||
Kubeconfig string `json:"kubeconfig,omitempty"`
|
||||
|
||||
// labels to use in Fleet Cluster registration
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
|
||||
//namespace to store clusters registrations in Fleet managers cluster
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
|
||||
HealthCheckConfig *healthcheckconfig.HealthCheckConfig `json:"healthCheckConfig,omitempty"`
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@ import (
|
||||
config "github.com/javamachr/gardener-extension-shoot-fleet-agent/pkg/apis/config"
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
componentbaseconfig "k8s.io/component-base/config"
|
||||
configv1alpha1 "k8s.io/component-base/config/v1alpha1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -48,13 +46,24 @@ func RegisterConversions(s *runtime.Scheme) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*ProjectConfig)(nil), (*config.ProjectConfig)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_ProjectConfig_To_config_ProjectConfig(a.(*ProjectConfig), b.(*config.ProjectConfig), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*config.ProjectConfig)(nil), (*ProjectConfig)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_config_ProjectConfig_To_v1alpha1_ProjectConfig(a.(*config.ProjectConfig), b.(*ProjectConfig), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_FleetAgentConfig_To_config_FleetAgentConfig(in *FleetAgentConfig, out *config.FleetAgentConfig, s conversion.Scope) error {
|
||||
out.ClientConnection = (*componentbaseconfig.ClientConnectionConfiguration)(unsafe.Pointer(in.ClientConnection))
|
||||
out.Labels = *(*map[string]string)(unsafe.Pointer(&in.Labels))
|
||||
out.Namespace = in.Namespace
|
||||
if err := Convert_v1alpha1_ProjectConfig_To_config_ProjectConfig(&in.DefaultConfiguration, &out.DefaultConfiguration, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.ProjectConfiguration = *(*map[string]config.ProjectConfig)(unsafe.Pointer(&in.ProjectConfiguration))
|
||||
out.HealthCheckConfig = (*healthcheckconfig.HealthCheckConfig)(unsafe.Pointer(in.HealthCheckConfig))
|
||||
return nil
|
||||
}
|
||||
@@ -65,9 +74,10 @@ func Convert_v1alpha1_FleetAgentConfig_To_config_FleetAgentConfig(in *FleetAgent
|
||||
}
|
||||
|
||||
func autoConvert_config_FleetAgentConfig_To_v1alpha1_FleetAgentConfig(in *config.FleetAgentConfig, out *FleetAgentConfig, s conversion.Scope) error {
|
||||
out.ClientConnection = (*configv1alpha1.ClientConnectionConfiguration)(unsafe.Pointer(in.ClientConnection))
|
||||
out.Labels = *(*map[string]string)(unsafe.Pointer(&in.Labels))
|
||||
out.Namespace = in.Namespace
|
||||
if err := Convert_config_ProjectConfig_To_v1alpha1_ProjectConfig(&in.DefaultConfiguration, &out.DefaultConfiguration, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.ProjectConfiguration = *(*map[string]ProjectConfig)(unsafe.Pointer(&in.ProjectConfiguration))
|
||||
out.HealthCheckConfig = (*healthcheckconfig.HealthCheckConfig)(unsafe.Pointer(in.HealthCheckConfig))
|
||||
return nil
|
||||
}
|
||||
@@ -76,3 +86,27 @@ func autoConvert_config_FleetAgentConfig_To_v1alpha1_FleetAgentConfig(in *config
|
||||
func Convert_config_FleetAgentConfig_To_v1alpha1_FleetAgentConfig(in *config.FleetAgentConfig, out *FleetAgentConfig, s conversion.Scope) error {
|
||||
return autoConvert_config_FleetAgentConfig_To_v1alpha1_FleetAgentConfig(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_ProjectConfig_To_config_ProjectConfig(in *ProjectConfig, out *config.ProjectConfig, s conversion.Scope) error {
|
||||
out.Kubeconfig = in.Kubeconfig
|
||||
out.Labels = *(*map[string]string)(unsafe.Pointer(&in.Labels))
|
||||
out.Namespace = in.Namespace
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_ProjectConfig_To_config_ProjectConfig is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_ProjectConfig_To_config_ProjectConfig(in *ProjectConfig, out *config.ProjectConfig, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_ProjectConfig_To_config_ProjectConfig(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_config_ProjectConfig_To_v1alpha1_ProjectConfig(in *config.ProjectConfig, out *ProjectConfig, s conversion.Scope) error {
|
||||
out.Kubeconfig = in.Kubeconfig
|
||||
out.Labels = *(*map[string]string)(unsafe.Pointer(&in.Labels))
|
||||
out.Namespace = in.Namespace
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_config_ProjectConfig_To_v1alpha1_ProjectConfig is an autogenerated conversion function.
|
||||
func Convert_config_ProjectConfig_To_v1alpha1_ProjectConfig(in *config.ProjectConfig, out *ProjectConfig, s conversion.Scope) error {
|
||||
return autoConvert_config_ProjectConfig_To_v1alpha1_ProjectConfig(in, out, s)
|
||||
}
|
||||
|
||||
@@ -23,23 +23,18 @@ package v1alpha1
|
||||
import (
|
||||
config "github.com/gardener/gardener/extensions/pkg/controller/healthcheck/config"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
configv1alpha1 "k8s.io/component-base/config/v1alpha1"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FleetAgentConfig) DeepCopyInto(out *FleetAgentConfig) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
if in.ClientConnection != nil {
|
||||
in, out := &in.ClientConnection, &out.ClientConnection
|
||||
*out = new(configv1alpha1.ClientConnectionConfiguration)
|
||||
**out = **in
|
||||
}
|
||||
if in.Labels != nil {
|
||||
in, out := &in.Labels, &out.Labels
|
||||
*out = make(map[string]string, len(*in))
|
||||
in.DefaultConfiguration.DeepCopyInto(&out.DefaultConfiguration)
|
||||
if in.ProjectConfiguration != nil {
|
||||
in, out := &in.ProjectConfiguration, &out.ProjectConfiguration
|
||||
*out = make(map[string]ProjectConfig, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
(*out)[key] = *val.DeepCopy()
|
||||
}
|
||||
}
|
||||
if in.HealthCheckConfig != nil {
|
||||
@@ -67,3 +62,26 @@ func (in *FleetAgentConfig) DeepCopyObject() runtime.Object {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ProjectConfig) DeepCopyInto(out *ProjectConfig) {
|
||||
*out = *in
|
||||
if in.Labels != nil {
|
||||
in, out := &in.Labels, &out.Labels
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProjectConfig.
|
||||
func (in *ProjectConfig) DeepCopy() *ProjectConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ProjectConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -23,23 +23,18 @@ package config
|
||||
import (
|
||||
healthcheckconfig "github.com/gardener/gardener/extensions/pkg/controller/healthcheck/config"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
componentbaseconfig "k8s.io/component-base/config"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FleetAgentConfig) DeepCopyInto(out *FleetAgentConfig) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
if in.ClientConnection != nil {
|
||||
in, out := &in.ClientConnection, &out.ClientConnection
|
||||
*out = new(componentbaseconfig.ClientConnectionConfiguration)
|
||||
**out = **in
|
||||
}
|
||||
if in.Labels != nil {
|
||||
in, out := &in.Labels, &out.Labels
|
||||
*out = make(map[string]string, len(*in))
|
||||
in.DefaultConfiguration.DeepCopyInto(&out.DefaultConfiguration)
|
||||
if in.ProjectConfiguration != nil {
|
||||
in, out := &in.ProjectConfiguration, &out.ProjectConfiguration
|
||||
*out = make(map[string]ProjectConfig, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
(*out)[key] = *val.DeepCopy()
|
||||
}
|
||||
}
|
||||
if in.HealthCheckConfig != nil {
|
||||
@@ -67,3 +62,26 @@ func (in *FleetAgentConfig) DeepCopyObject() runtime.Object {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ProjectConfig) DeepCopyInto(out *ProjectConfig) {
|
||||
*out = *in
|
||||
if in.Labels != nil {
|
||||
in, out := &in.Labels, &out.Labels
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProjectConfig.
|
||||
func (in *ProjectConfig) DeepCopy() *ProjectConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ProjectConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user