diff --git a/operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml b/operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml index 57c7ebd0..c42c706b 100644 --- a/operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml +++ b/operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml @@ -91,6 +91,89 @@ spec: DeployOption contains the options of deploying a cluster-manager Default mode is used if DeployOption is not set. properties: + default: + description: Default includes optional configurations for clustermanager + in the Default mode. + properties: + registrationWebhookConfiguration: + description: RegistrationWebhookConfiguration represents the + customized webhook-server configuration of registration. + properties: + bindConfiguration: + description: BindConfiguration represents server bind + configuration for the webhook server + properties: + healthProbePort: + default: 8000 + description: |- + HealthProbePort represents the bind port of a webhook-server's healthcheck endpoint. The default value is 8000. + Healthchecks may be disabled by setting a value less than or equal to 0. + format: int32 + maximum: 65535 + type: integer + hostNetwork: + description: |- + HostNetwork enables running webhook pods in host networking mode. + This may be required in some installations, such as EKS with Calico CNI, + to allow the API Server to communicate with the webhook pods. + type: boolean + metricsPort: + default: 8080 + description: |- + MetricsPort represents the bind port for a webhook-server's metric endpoint. The default value is 8080. + Metrics may be disabled by setting a value less than or equal to 0. + format: int32 + maximum: 65535 + type: integer + port: + default: 9443 + description: Port represents the primary bind port + of a server. The default value is 9443. + format: int32 + maximum: 65535 + type: integer + type: object + type: object + workWebhookConfiguration: + description: WorkWebhookConfiguration represents the customized + webhook-server configuration of work. + properties: + bindConfiguration: + description: BindConfiguration represents server bind + configuration for the webhook server + properties: + healthProbePort: + default: 8000 + description: |- + HealthProbePort represents the bind port of a webhook-server's healthcheck endpoint. The default value is 8000. + Healthchecks may be disabled by setting a value less than or equal to 0. + format: int32 + maximum: 65535 + type: integer + hostNetwork: + description: |- + HostNetwork enables running webhook pods in host networking mode. + This may be required in some installations, such as EKS with Calico CNI, + to allow the API Server to communicate with the webhook pods. + type: boolean + metricsPort: + default: 8080 + description: |- + MetricsPort represents the bind port for a webhook-server's metric endpoint. The default value is 8080. + Metrics may be disabled by setting a value less than or equal to 0. + format: int32 + maximum: 65535 + type: integer + port: + default: 9443 + description: Port represents the primary bind port + of a server. The default value is 9443. + format: int32 + maximum: 65535 + type: integer + type: object + type: object + type: object hosted: description: Hosted includes configurations we need for clustermanager in the Hosted mode. @@ -106,9 +189,43 @@ spec: The Address must be reachable by apiserver of the hub cluster. pattern: ^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$ type: string + bindConfiguration: + description: BindConfiguration represents server bind + configuration for the webhook server + properties: + healthProbePort: + default: 8000 + description: |- + HealthProbePort represents the bind port of a webhook-server's healthcheck endpoint. The default value is 8000. + Healthchecks may be disabled by setting a value less than or equal to 0. + format: int32 + maximum: 65535 + type: integer + hostNetwork: + description: |- + HostNetwork enables running webhook pods in host networking mode. + This may be required in some installations, such as EKS with Calico CNI, + to allow the API Server to communicate with the webhook pods. + type: boolean + metricsPort: + default: 8080 + description: |- + MetricsPort represents the bind port for a webhook-server's metric endpoint. The default value is 8080. + Metrics may be disabled by setting a value less than or equal to 0. + format: int32 + maximum: 65535 + type: integer + port: + default: 9443 + description: Port represents the primary bind port + of a server. The default value is 9443. + format: int32 + maximum: 65535 + type: integer + type: object port: default: 443 - description: Port represents the port of a webhook-server. + description: Port represents the external port of a webhook-server. The default value of Port is 443. format: int32 maximum: 65535 @@ -127,9 +244,43 @@ spec: The Address must be reachable by apiserver of the hub cluster. pattern: ^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$ type: string + bindConfiguration: + description: BindConfiguration represents server bind + configuration for the webhook server + properties: + healthProbePort: + default: 8000 + description: |- + HealthProbePort represents the bind port of a webhook-server's healthcheck endpoint. The default value is 8000. + Healthchecks may be disabled by setting a value less than or equal to 0. + format: int32 + maximum: 65535 + type: integer + hostNetwork: + description: |- + HostNetwork enables running webhook pods in host networking mode. + This may be required in some installations, such as EKS with Calico CNI, + to allow the API Server to communicate with the webhook pods. + type: boolean + metricsPort: + default: 8080 + description: |- + MetricsPort represents the bind port for a webhook-server's metric endpoint. The default value is 8080. + Metrics may be disabled by setting a value less than or equal to 0. + format: int32 + maximum: 65535 + type: integer + port: + default: 9443 + description: Port represents the primary bind port + of a server. The default value is 9443. + format: int32 + maximum: 65535 + type: integer + type: object port: default: 443 - description: Port represents the port of a webhook-server. + description: Port represents the external port of a webhook-server. The default value of Port is 443. format: int32 maximum: 65535 diff --git a/operator/v1/types_clustermanager.go b/operator/v1/types_clustermanager.go index a32c7c8c..30bc1f94 100644 --- a/operator/v1/types_clustermanager.go +++ b/operator/v1/types_clustermanager.go @@ -281,19 +281,65 @@ const ( FeatureGateModeTypeDisable FeatureGateModeType = "Disable" ) +// DefaultClusterManagerConfiguration represents customized configurations for clustermanager in the Default mode. +type DefaultClusterManagerConfiguration struct { + // RegistrationWebhookConfiguration represents the customized webhook-server configuration of registration. + // +optional + RegistrationWebhookConfiguration DefaultWebhookConfiguration `json:"registrationWebhookConfiguration,omitempty"` + + // WorkWebhookConfiguration represents the customized webhook-server configuration of work. + // +optional + WorkWebhookConfiguration DefaultWebhookConfiguration `json:"workWebhookConfiguration,omitempty"` +} + // HostedClusterManagerConfiguration represents customized configurations we need to set for clustermanager in the Hosted mode. type HostedClusterManagerConfiguration struct { // RegistrationWebhookConfiguration represents the customized webhook-server configuration of registration. // +optional - RegistrationWebhookConfiguration WebhookConfiguration `json:"registrationWebhookConfiguration,omitempty"` + RegistrationWebhookConfiguration HostedWebhookConfiguration `json:"registrationWebhookConfiguration,omitempty"` // WorkWebhookConfiguration represents the customized webhook-server configuration of work. // +optional - WorkWebhookConfiguration WebhookConfiguration `json:"workWebhookConfiguration,omitempty"` + WorkWebhookConfiguration HostedWebhookConfiguration `json:"workWebhookConfiguration,omitempty"` } -// WebhookConfiguration has two properties: Address and Port. -type WebhookConfiguration struct { +// BindConfiguration represents customization of server bindings +type BindConfiguration struct { + // Port represents the primary bind port of a server. The default value is 9443. + // +optional + // +kubebuilder:default=9443 + // +kubebuilder:validation:Maximum=65535 + Port int32 `json:"port,omitempty"` + + // HealthProbePort represents the bind port of a webhook-server's healthcheck endpoint. The default value is 8000. + // Healthchecks may be disabled by setting a value less than or equal to 0. + // +optional + // +kubebuilder:default=8000 + // +kubebuilder:validation:Maximum=65535 + HealthProbePort int32 `json:"healthProbePort"` + + // MetricsPort represents the bind port for a webhook-server's metric endpoint. The default value is 8080. + // Metrics may be disabled by setting a value less than or equal to 0. + // +optional + // +kubebuilder:default=8080 + // +kubebuilder:validation:Maximum=65535 + MetricsPort int32 `json:"metricsPort"` + + // HostNetwork enables running webhook pods in host networking mode. + // This may be required in some installations, such as EKS with Calico CNI, + // to allow the API Server to communicate with the webhook pods. + // +optional + HostNetwork bool `json:"hostNetwork,omitempty"` +} + +// DefaultWebhookConfiguration represents customization of webhook servers running in default installation mode +type DefaultWebhookConfiguration struct { + // BindConfiguration represents server bind configuration for the webhook server + BindConfiguration *BindConfiguration `json:"bindConfiguration,omitempty"` +} + +// HostedWebhookConfiguration represents customization of webhook servers running in hosted installation mode +type HostedWebhookConfiguration struct { // Address represents the address of a webhook-server. // It could be in IP format or fqdn format. // The Address must be reachable by apiserver of the hub cluster. @@ -302,11 +348,14 @@ type WebhookConfiguration struct { // +kubebuilder:validation:Pattern=^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$ Address string `json:"address"` - // Port represents the port of a webhook-server. The default value of Port is 443. + // Port represents the external port of a webhook-server. The default value of Port is 443. // +optional // +kubebuilder:default=443 // +kubebuilder:validation:Maximum=65535 Port int32 `json:"port,omitempty"` + + // BindConfiguration represents server bind configuration for the webhook server + BindConfiguration *BindConfiguration `json:"bindConfiguration,omitempty"` } // ClusterManagerDeployOption describes the deployment options for cluster-manager @@ -323,6 +372,10 @@ type ClusterManagerDeployOption struct { // +kubebuilder:validation:Enum=Default;Hosted Mode InstallMode `json:"mode,omitempty"` + // Default includes optional configurations for clustermanager in the Default mode. + // +optional + Default *DefaultClusterManagerConfiguration `json:"default,omitempty"` + // Hosted includes configurations we need for clustermanager in the Hosted mode. // +optional Hosted *HostedClusterManagerConfiguration `json:"hosted,omitempty"` diff --git a/operator/v1/zz_generated.deepcopy.go b/operator/v1/zz_generated.deepcopy.go index 957bb218..cf351f3f 100644 --- a/operator/v1/zz_generated.deepcopy.go +++ b/operator/v1/zz_generated.deepcopy.go @@ -75,6 +75,22 @@ func (in *AwsIrsaConfig) DeepCopy() *AwsIrsaConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BindConfiguration) DeepCopyInto(out *BindConfiguration) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BindConfiguration. +func (in *BindConfiguration) DeepCopy() *BindConfiguration { + if in == nil { + return nil + } + out := new(BindConfiguration) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BootstrapKubeConfigs) DeepCopyInto(out *BootstrapKubeConfigs) { *out = *in @@ -169,10 +185,15 @@ func (in *ClusterManager) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterManagerDeployOption) DeepCopyInto(out *ClusterManagerDeployOption) { *out = *in + if in.Default != nil { + in, out := &in.Default, &out.Default + *out = new(DefaultClusterManagerConfiguration) + (*in).DeepCopyInto(*out) + } if in.Hosted != nil { in, out := &in.Hosted, &out.Hosted *out = new(HostedClusterManagerConfiguration) - **out = **in + (*in).DeepCopyInto(*out) } return } @@ -291,6 +312,45 @@ func (in *ClusterManagerStatus) DeepCopy() *ClusterManagerStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DefaultClusterManagerConfiguration) DeepCopyInto(out *DefaultClusterManagerConfiguration) { + *out = *in + in.RegistrationWebhookConfiguration.DeepCopyInto(&out.RegistrationWebhookConfiguration) + in.WorkWebhookConfiguration.DeepCopyInto(&out.WorkWebhookConfiguration) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DefaultClusterManagerConfiguration. +func (in *DefaultClusterManagerConfiguration) DeepCopy() *DefaultClusterManagerConfiguration { + if in == nil { + return nil + } + out := new(DefaultClusterManagerConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DefaultWebhookConfiguration) DeepCopyInto(out *DefaultWebhookConfiguration) { + *out = *in + if in.BindConfiguration != nil { + in, out := &in.BindConfiguration, &out.BindConfiguration + *out = new(BindConfiguration) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DefaultWebhookConfiguration. +func (in *DefaultWebhookConfiguration) DeepCopy() *DefaultWebhookConfiguration { + if in == nil { + return nil + } + out := new(DefaultWebhookConfiguration) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FeatureGate) DeepCopyInto(out *FeatureGate) { *out = *in @@ -373,8 +433,8 @@ func (in *GenerationStatus) DeepCopy() *GenerationStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostedClusterManagerConfiguration) DeepCopyInto(out *HostedClusterManagerConfiguration) { *out = *in - out.RegistrationWebhookConfiguration = in.RegistrationWebhookConfiguration - out.WorkWebhookConfiguration = in.WorkWebhookConfiguration + in.RegistrationWebhookConfiguration.DeepCopyInto(&out.RegistrationWebhookConfiguration) + in.WorkWebhookConfiguration.DeepCopyInto(&out.WorkWebhookConfiguration) return } @@ -388,6 +448,27 @@ func (in *HostedClusterManagerConfiguration) DeepCopy() *HostedClusterManagerCon return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostedWebhookConfiguration) DeepCopyInto(out *HostedWebhookConfiguration) { + *out = *in + if in.BindConfiguration != nil { + in, out := &in.BindConfiguration, &out.BindConfiguration + *out = new(BindConfiguration) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostedWebhookConfiguration. +func (in *HostedWebhookConfiguration) DeepCopy() *HostedWebhookConfiguration { + if in == nil { + return nil + } + out := new(HostedWebhookConfiguration) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostnameConfig) DeepCopyInto(out *HostnameConfig) { *out = *in @@ -827,22 +908,6 @@ func (in *ServerURL) DeepCopy() *ServerURL { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *WebhookConfiguration) DeepCopyInto(out *WebhookConfiguration) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookConfiguration. -func (in *WebhookConfiguration) DeepCopy() *WebhookConfiguration { - if in == nil { - return nil - } - out := new(WebhookConfiguration) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WorkAgentConfiguration) DeepCopyInto(out *WorkAgentConfiguration) { *out = *in diff --git a/test/integration/api/clustermanager_test.go b/test/integration/api/clustermanager_test.go index a023d89b..80318302 100644 --- a/test/integration/api/clustermanager_test.go +++ b/test/integration/api/clustermanager_test.go @@ -78,10 +78,10 @@ var _ = Describe("Create Cluster Manager Hosted mode", func() { Context("Set wrong format address", func() { It("should return err", func() { clusterManager.Spec.DeployOption.Hosted = &operatorv1.HostedClusterManagerConfiguration{ - RegistrationWebhookConfiguration: operatorv1.WebhookConfiguration{ + RegistrationWebhookConfiguration: operatorv1.HostedWebhookConfiguration{ Address: "test:test", }, - WorkWebhookConfiguration: operatorv1.WebhookConfiguration{ + WorkWebhookConfiguration: operatorv1.HostedWebhookConfiguration{ Address: "test:test", }, } @@ -93,10 +93,10 @@ var _ = Describe("Create Cluster Manager Hosted mode", func() { Context("Set IPV4 format addresses", func() { It("should create successfully", func() { clusterManager.Spec.DeployOption.Hosted = &operatorv1.HostedClusterManagerConfiguration{ - RegistrationWebhookConfiguration: operatorv1.WebhookConfiguration{ + RegistrationWebhookConfiguration: operatorv1.HostedWebhookConfiguration{ Address: "192.168.2.3", }, - WorkWebhookConfiguration: operatorv1.WebhookConfiguration{ + WorkWebhookConfiguration: operatorv1.HostedWebhookConfiguration{ Address: "192.168.2.4", }, } @@ -108,10 +108,10 @@ var _ = Describe("Create Cluster Manager Hosted mode", func() { Context("Set FQDN format addresses", func() { It("should create successfully", func() { clusterManager.Spec.DeployOption.Hosted = &operatorv1.HostedClusterManagerConfiguration{ - RegistrationWebhookConfiguration: operatorv1.WebhookConfiguration{ + RegistrationWebhookConfiguration: operatorv1.HostedWebhookConfiguration{ Address: "localhost", }, - WorkWebhookConfiguration: operatorv1.WebhookConfiguration{ + WorkWebhookConfiguration: operatorv1.HostedWebhookConfiguration{ Address: "foo.com", }, } @@ -121,12 +121,12 @@ var _ = Describe("Create Cluster Manager Hosted mode", func() { }) Context("Set nothing in ports", func() { - It("should has 443 as default value", func() { + It("should have 443 as default value in hosted mode", func() { clusterManager.Spec.DeployOption.Hosted = &operatorv1.HostedClusterManagerConfiguration{ - RegistrationWebhookConfiguration: operatorv1.WebhookConfiguration{ + RegistrationWebhookConfiguration: operatorv1.HostedWebhookConfiguration{ Address: "localhost", }, - WorkWebhookConfiguration: operatorv1.WebhookConfiguration{ + WorkWebhookConfiguration: operatorv1.HostedWebhookConfiguration{ Address: "foo.com", }, } @@ -140,11 +140,11 @@ var _ = Describe("Create Cluster Manager Hosted mode", func() { Context("Set port bigger than 65535", func() { It("should return err", func() { clusterManager.Spec.DeployOption.Hosted = &operatorv1.HostedClusterManagerConfiguration{ - RegistrationWebhookConfiguration: operatorv1.WebhookConfiguration{ + RegistrationWebhookConfiguration: operatorv1.HostedWebhookConfiguration{ Address: "localhost", Port: 65536, }, - WorkWebhookConfiguration: operatorv1.WebhookConfiguration{ + WorkWebhookConfiguration: operatorv1.HostedWebhookConfiguration{ Address: "foo.com", }, } @@ -156,11 +156,11 @@ var _ = Describe("Create Cluster Manager Hosted mode", func() { Context("Set customized WebhookConfiguration", func() { It("should have euqually value after create", func() { clusterManager.Spec.DeployOption.Hosted = &operatorv1.HostedClusterManagerConfiguration{ - RegistrationWebhookConfiguration: operatorv1.WebhookConfiguration{ + RegistrationWebhookConfiguration: operatorv1.HostedWebhookConfiguration{ Address: "foo1.com", Port: 1443, }, - WorkWebhookConfiguration: operatorv1.WebhookConfiguration{ + WorkWebhookConfiguration: operatorv1.HostedWebhookConfiguration{ Address: "foo2.com", Port: 2443, },