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 e5fef5e0..73ba5b51 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,71 @@ spec: DeployOption contains the options of deploying a cluster-manager Default mode is used if DeployOption is not set. properties: + default: + description: Default includes configurations for clustermanager + in the Default mode + properties: + registrationWebhookConfiguration: + description: RegistrationWebhookConfiguration represents the + customized webhook-server configuration of registration. + properties: + healthProbeBindAddress: + default: :8000 + description: |- + HealthProbeBindAddress represents the healthcheck address of a webhook-server. The default value is ":8000". + Healthchecks may be disabled by setting a value of "0" or "". + type: string + hostNetwork: + description: |- + HostNetwork enables running webhook pods with hostNetwork: true + 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 + metricsBindAddress: + default: :8080 + description: |- + MetricsBindAddress represents the metrics address of a webhook-server. The default value is ":8080" + Metrics may be disabled by setting a value of "0" or "". + type: string + port: + default: 9443 + description: Port represents the port of a webhook-server. + The default value of Port is 9443. + format: int32 + maximum: 65535 + type: integer + type: object + workWebhookConfiguration: + description: WorkWebhookConfiguration represents the customized + webhook-server configuration of work. + properties: + healthProbeBindAddress: + default: :8000 + description: |- + HealthProbeBindAddress represents the healthcheck address of a webhook-server. The default value is ":8000". + Healthchecks may be disabled by setting a value of "0" or "". + type: string + hostNetwork: + description: |- + HostNetwork enables running webhook pods with hostNetwork: true + 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 + metricsBindAddress: + default: :8080 + description: |- + MetricsBindAddress represents the metrics address of a webhook-server. The default value is ":8080" + Metrics may be disabled by setting a value of "0" or "". + type: string + port: + default: 9443 + description: Port represents the port of a webhook-server. + The default value of Port is 9443. + format: int32 + maximum: 65535 + type: integer + type: object + type: object hosted: description: Hosted includes configurations we need for clustermanager in the Hosted mode. @@ -106,6 +171,24 @@ 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 + healthProbeBindAddress: + default: :8000 + description: |- + HealthProbeBindAddress represents the healthcheck address of a webhook-server. The default value is ":8000". + Healthchecks may be disabled by setting a value of "0" or "". + type: string + hostNetwork: + description: |- + HostNetwork enables running webhook pods with hostNetwork: true + 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 + metricsBindAddress: + default: :8080 + description: |- + MetricsBindAddress represents the metrics address of a webhook-server. The default value is ":8080" + Metrics may be disabled by setting a value of "0" or "". + type: string port: default: 443 description: Port represents the port of a webhook-server. @@ -127,6 +210,24 @@ 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 + healthProbeBindAddress: + default: :8000 + description: |- + HealthProbeBindAddress represents the healthcheck address of a webhook-server. The default value is ":8000". + Healthchecks may be disabled by setting a value of "0" or "". + type: string + hostNetwork: + description: |- + HostNetwork enables running webhook pods with hostNetwork: true + 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 + metricsBindAddress: + default: :8080 + description: |- + MetricsBindAddress represents the metrics address of a webhook-server. The default value is ":8080" + Metrics may be disabled by setting a value of "0" or "". + type: string port: default: 443 description: Port represents the port of a webhook-server. diff --git a/operator/v1/types_clustermanager.go b/operator/v1/types_clustermanager.go index abfdc9b0..304b20c6 100644 --- a/operator/v1/types_clustermanager.go +++ b/operator/v1/types_clustermanager.go @@ -232,19 +232,62 @@ 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. +// WebhookConfiguration represents customization of webhook servers type WebhookConfiguration struct { + // HealthProbeBindAddress represents the healthcheck address of a webhook-server. The default value is ":8000". + // Healthchecks may be disabled by setting a value of "0" or "". + // +optional + // +kubebuilder:default=":8000" + HealthProbeBindAddress string `json:"healthProbeBindAddress"` + + // MetricsBindAddress represents the metrics address of a webhook-server. The default value is ":8080" + // Metrics may be disabled by setting a value of "0" or "". + // +optional + // +kubebuilder:default=":8080" + MetricsBindAddress string `json:"metricsBindAddress"` + + // HostNetwork enables running webhook pods with hostNetwork: true + // 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 { + // Port represents the port of a webhook-server. The default value of Port is 9443. + // +optional + // +kubebuilder:default=9443 + // +kubebuilder:validation:Maximum=65535 + Port int32 `json:"port,omitempty"` + + WebhookConfiguration `json:",inline"` +} + +// 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. @@ -258,6 +301,8 @@ type WebhookConfiguration struct { // +kubebuilder:default=443 // +kubebuilder:validation:Maximum=65535 Port int32 `json:"port,omitempty"` + + WebhookConfiguration `json:",inline"` } // ClusterManagerDeployOption describes the deployment options for cluster-manager @@ -274,6 +319,10 @@ type ClusterManagerDeployOption struct { // +kubebuilder:validation:Enum=Default;Hosted Mode InstallMode `json:"mode,omitempty"` + // Default includes 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 af3ca258..619c09d2 100644 --- a/operator/v1/zz_generated.deepcopy.go +++ b/operator/v1/zz_generated.deepcopy.go @@ -168,6 +168,11 @@ 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) + **out = **in + } if in.Hosted != nil { in, out := &in.Hosted, &out.Hosted *out = new(HostedClusterManagerConfiguration) @@ -290,6 +295,41 @@ 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 + out.RegistrationWebhookConfiguration = in.RegistrationWebhookConfiguration + out.WorkWebhookConfiguration = in.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 + out.WebhookConfiguration = in.WebhookConfiguration + 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 @@ -340,6 +380,23 @@ 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 + out.WebhookConfiguration = in.WebhookConfiguration + 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 *HubApiServerHostAlias) DeepCopyInto(out *HubApiServerHostAlias) { *out = *in diff --git a/operator/v1/zz_generated.swagger_doc_generated.go b/operator/v1/zz_generated.swagger_doc_generated.go index 49e19c57..a4dd641e 100644 --- a/operator/v1/zz_generated.swagger_doc_generated.go +++ b/operator/v1/zz_generated.swagger_doc_generated.go @@ -48,9 +48,10 @@ func (ClusterManager) SwaggerDoc() map[string]string { } var map_ClusterManagerDeployOption = map[string]string{ - "": "ClusterManagerDeployOption describes the deployment options for cluster-manager", - "mode": "Mode can be Default or Hosted. In Default mode, the Hub is installed as a whole and all parts of Hub are deployed in the same cluster. In Hosted mode, only crd and configurations are installed on one cluster(defined as hub-cluster). Controllers run in another cluster (defined as management-cluster) and connect to the hub with the kubeconfig in secret of \"external-hub-kubeconfig\"(a kubeconfig of hub-cluster with cluster-admin permission). Note: Do not modify the Mode field once it's applied.", - "hosted": "Hosted includes configurations we need for clustermanager in the Hosted mode.", + "": "ClusterManagerDeployOption describes the deployment options for cluster-manager", + "mode": "Mode can be Default or Hosted. In Default mode, the Hub is installed as a whole and all parts of Hub are deployed in the same cluster. In Hosted mode, only crd and configurations are installed on one cluster(defined as hub-cluster). Controllers run in another cluster (defined as management-cluster) and connect to the hub with the kubeconfig in secret of \"external-hub-kubeconfig\"(a kubeconfig of hub-cluster with cluster-admin permission). Note: Do not modify the Mode field once it's applied.", + "default": "Default includes configurations for clustermanager in the Default mode", + "hosted": "Hosted includes configurations we need for clustermanager in the Hosted mode.", } func (ClusterManagerDeployOption) SwaggerDoc() map[string]string { @@ -97,6 +98,25 @@ func (ClusterManagerStatus) SwaggerDoc() map[string]string { return map_ClusterManagerStatus } +var map_DefaultClusterManagerConfiguration = map[string]string{ + "": "DefaultClusterManagerConfiguration represents customized configurations for clustermanager in the Default mode", + "registrationWebhookConfiguration": "RegistrationWebhookConfiguration represents the customized webhook-server configuration of registration.", + "workWebhookConfiguration": "WorkWebhookConfiguration represents the customized webhook-server configuration of work.", +} + +func (DefaultClusterManagerConfiguration) SwaggerDoc() map[string]string { + return map_DefaultClusterManagerConfiguration +} + +var map_DefaultWebhookConfiguration = map[string]string{ + "": "DefaultWebhookConfiguration represents customization of webhook servers running in default installation mode", + "port": "Port represents the port of a webhook-server. The default value of Port is 9443.", +} + +func (DefaultWebhookConfiguration) SwaggerDoc() map[string]string { + return map_DefaultWebhookConfiguration +} + var map_FeatureGate = map[string]string{ "feature": "Feature is the key of feature gate. e.g. featuregate/Foo.", "mode": "Mode is either Enable, Disable, \"\" where \"\" is Disable by default. In Enable mode, a valid feature gate `featuregate/Foo` will be set to \"--featuregate/Foo=true\". In Disable mode, a valid feature gate `featuregate/Foo` will be set to \"--featuregate/Foo=false\".", @@ -130,6 +150,16 @@ func (HostedClusterManagerConfiguration) SwaggerDoc() map[string]string { return map_HostedClusterManagerConfiguration } +var map_HostedWebhookConfiguration = map[string]string{ + "": "HostedWebhookConfiguration represents customization of webhook servers running in hosted installation mode", + "address": "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.", + "port": "Port represents the port of a webhook-server. The default value of Port is 443.", +} + +func (HostedWebhookConfiguration) SwaggerDoc() map[string]string { + return map_HostedWebhookConfiguration +} + var map_NodePlacement = map[string]string{ "": "NodePlacement describes node scheduling configuration for the pods.", "nodeSelector": "NodeSelector defines which Nodes the Pods are scheduled on. The default is an empty list.", @@ -174,9 +204,10 @@ func (RelatedResourceMeta) SwaggerDoc() map[string]string { } var map_WebhookConfiguration = map[string]string{ - "": "WebhookConfiguration has two properties: Address and Port.", - "address": "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.", - "port": "Port represents the port of a webhook-server. The default value of Port is 443.", + "": "WebhookConfiguration represents customization of webhook servers", + "healthProbeBindAddress": "HealthProbeBindAddress represents the healthcheck address of a webhook-server. The default value is \":8000\". Healthchecks may be disabled by setting a value of \"0\" or \"\".", + "metricsBindAddress": "MetricsBindAddress represents the metrics address of a webhook-server. The default value is \":8080\" Metrics may be disabled by setting a value of \"0\" or \"\".", + "hostNetwork": "HostNetwork enables running webhook pods with hostNetwork: true This may be required in some installations, such as EKS with Calico CNI, to allow the API Server to communicate with the webhook pods.", } func (WebhookConfiguration) SwaggerDoc() map[string]string { diff --git a/test/integration/api/clustermanager_test.go b/test/integration/api/clustermanager_test.go index 4898f9c6..fbab08ff 100644 --- a/test/integration/api/clustermanager_test.go +++ b/test/integration/api/clustermanager_test.go @@ -77,10 +77,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", }, } @@ -92,10 +92,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", }, } @@ -107,10 +107,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", }, } @@ -120,12 +120,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", }, } @@ -139,11 +139,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", }, } @@ -155,11 +155,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, },