Skip to content

Commit 8d8c7a9

Browse files
committed
Networking configuration options for webhooks
Signed-off-by: Ben Perry <[email protected]>
1 parent c0d6364 commit 8d8c7a9

File tree

4 files changed

+223
-16
lines changed

4 files changed

+223
-16
lines changed

operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,71 @@ spec:
9191
DeployOption contains the options of deploying a cluster-manager
9292
Default mode is used if DeployOption is not set.
9393
properties:
94+
default:
95+
description: Default includes configurations for clustermanager
96+
in the Default mode
97+
properties:
98+
registrationWebhookConfiguration:
99+
description: RegistrationWebhookConfiguration represents the
100+
customized webhook-server configuration of registration.
101+
properties:
102+
healthProbeBindAddress:
103+
default: :8000
104+
description: |-
105+
HealthProbeBindAddress represents the healthcheck address of a webhook-server. The default value is ":8000".
106+
Healthchecks may be disabled by setting a value of "0" or "".
107+
type: string
108+
hostNetwork:
109+
description: |-
110+
HostNetwork enables running webhook pods with hostNetwork: true
111+
This may be required in some installations, such as EKS with Calico CNI,
112+
to allow the API Server to communicate with the webhook pods.
113+
type: boolean
114+
metricsBindAddress:
115+
default: :8080
116+
description: |-
117+
MetricsBindAddress represents the metrics address of a webhook-server. The default value is ":8080"
118+
Metrics may be disabled by setting a value of "0" or "".
119+
type: string
120+
port:
121+
default: 9443
122+
description: Port represents the port of a webhook-server.
123+
The default value of Port is 9443.
124+
format: int32
125+
maximum: 65535
126+
type: integer
127+
type: object
128+
workWebhookConfiguration:
129+
description: WorkWebhookConfiguration represents the customized
130+
webhook-server configuration of work.
131+
properties:
132+
healthProbeBindAddress:
133+
default: :8000
134+
description: |-
135+
HealthProbeBindAddress represents the healthcheck address of a webhook-server. The default value is ":8000".
136+
Healthchecks may be disabled by setting a value of "0" or "".
137+
type: string
138+
hostNetwork:
139+
description: |-
140+
HostNetwork enables running webhook pods with hostNetwork: true
141+
This may be required in some installations, such as EKS with Calico CNI,
142+
to allow the API Server to communicate with the webhook pods.
143+
type: boolean
144+
metricsBindAddress:
145+
default: :8080
146+
description: |-
147+
MetricsBindAddress represents the metrics address of a webhook-server. The default value is ":8080"
148+
Metrics may be disabled by setting a value of "0" or "".
149+
type: string
150+
port:
151+
default: 9443
152+
description: Port represents the port of a webhook-server.
153+
The default value of Port is 9443.
154+
format: int32
155+
maximum: 65535
156+
type: integer
157+
type: object
158+
type: object
94159
hosted:
95160
description: Hosted includes configurations we need for clustermanager
96161
in the Hosted mode.
@@ -106,6 +171,24 @@ spec:
106171
The Address must be reachable by apiserver of the hub cluster.
107172
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])$
108173
type: string
174+
healthProbeBindAddress:
175+
default: :8000
176+
description: |-
177+
HealthProbeBindAddress represents the healthcheck address of a webhook-server. The default value is ":8000".
178+
Healthchecks may be disabled by setting a value of "0" or "".
179+
type: string
180+
hostNetwork:
181+
description: |-
182+
HostNetwork enables running webhook pods with hostNetwork: true
183+
This may be required in some installations, such as EKS with Calico CNI,
184+
to allow the API Server to communicate with the webhook pods.
185+
type: boolean
186+
metricsBindAddress:
187+
default: :8080
188+
description: |-
189+
MetricsBindAddress represents the metrics address of a webhook-server. The default value is ":8080"
190+
Metrics may be disabled by setting a value of "0" or "".
191+
type: string
109192
port:
110193
default: 443
111194
description: Port represents the port of a webhook-server.
@@ -127,6 +210,24 @@ spec:
127210
The Address must be reachable by apiserver of the hub cluster.
128211
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])$
129212
type: string
213+
healthProbeBindAddress:
214+
default: :8000
215+
description: |-
216+
HealthProbeBindAddress represents the healthcheck address of a webhook-server. The default value is ":8000".
217+
Healthchecks may be disabled by setting a value of "0" or "".
218+
type: string
219+
hostNetwork:
220+
description: |-
221+
HostNetwork enables running webhook pods with hostNetwork: true
222+
This may be required in some installations, such as EKS with Calico CNI,
223+
to allow the API Server to communicate with the webhook pods.
224+
type: boolean
225+
metricsBindAddress:
226+
default: :8080
227+
description: |-
228+
MetricsBindAddress represents the metrics address of a webhook-server. The default value is ":8080"
229+
Metrics may be disabled by setting a value of "0" or "".
230+
type: string
130231
port:
131232
default: 443
132233
description: Port represents the port of a webhook-server.

operator/v1/types_clustermanager.go

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,19 +281,62 @@ const (
281281
FeatureGateModeTypeDisable FeatureGateModeType = "Disable"
282282
)
283283

284+
// DefaultClusterManagerConfiguration represents customized configurations for clustermanager in the Default mode
285+
type DefaultClusterManagerConfiguration struct {
286+
// RegistrationWebhookConfiguration represents the customized webhook-server configuration of registration.
287+
// +optional
288+
RegistrationWebhookConfiguration DefaultWebhookConfiguration `json:"registrationWebhookConfiguration,omitempty"`
289+
290+
// WorkWebhookConfiguration represents the customized webhook-server configuration of work.
291+
// +optional
292+
WorkWebhookConfiguration DefaultWebhookConfiguration `json:"workWebhookConfiguration,omitempty"`
293+
}
294+
284295
// HostedClusterManagerConfiguration represents customized configurations we need to set for clustermanager in the Hosted mode.
285296
type HostedClusterManagerConfiguration struct {
286297
// RegistrationWebhookConfiguration represents the customized webhook-server configuration of registration.
287298
// +optional
288-
RegistrationWebhookConfiguration WebhookConfiguration `json:"registrationWebhookConfiguration,omitempty"`
299+
RegistrationWebhookConfiguration HostedWebhookConfiguration `json:"registrationWebhookConfiguration,omitempty"`
289300

290301
// WorkWebhookConfiguration represents the customized webhook-server configuration of work.
291302
// +optional
292-
WorkWebhookConfiguration WebhookConfiguration `json:"workWebhookConfiguration,omitempty"`
303+
WorkWebhookConfiguration HostedWebhookConfiguration `json:"workWebhookConfiguration,omitempty"`
293304
}
294305

295-
// WebhookConfiguration has two properties: Address and Port.
306+
// WebhookConfiguration represents customization of webhook servers
296307
type WebhookConfiguration struct {
308+
// HealthProbeBindAddress represents the healthcheck address of a webhook-server. The default value is ":8000".
309+
// Healthchecks may be disabled by setting a value of "0" or "".
310+
// +optional
311+
// +kubebuilder:default=":8000"
312+
HealthProbeBindAddress string `json:"healthProbeBindAddress"`
313+
314+
// MetricsBindAddress represents the metrics address of a webhook-server. The default value is ":8080"
315+
// Metrics may be disabled by setting a value of "0" or "".
316+
// +optional
317+
// +kubebuilder:default=":8080"
318+
MetricsBindAddress string `json:"metricsBindAddress"`
319+
320+
// HostNetwork enables running webhook pods with hostNetwork: true
321+
// This may be required in some installations, such as EKS with Calico CNI,
322+
// to allow the API Server to communicate with the webhook pods.
323+
// +optional
324+
HostNetwork bool `json:"hostNetwork,omitempty"`
325+
}
326+
327+
// DefaultWebhookConfiguration represents customization of webhook servers running in default installation mode
328+
type DefaultWebhookConfiguration struct {
329+
// Port represents the port of a webhook-server. The default value of Port is 9443.
330+
// +optional
331+
// +kubebuilder:default=9443
332+
// +kubebuilder:validation:Maximum=65535
333+
Port int32 `json:"port,omitempty"`
334+
335+
WebhookConfiguration `json:",inline"`
336+
}
337+
338+
// HostedWebhookConfiguration represents customization of webhook servers running in hosted installation mode
339+
type HostedWebhookConfiguration struct {
297340
// Address represents the address of a webhook-server.
298341
// It could be in IP format or fqdn format.
299342
// The Address must be reachable by apiserver of the hub cluster.
@@ -307,6 +350,8 @@ type WebhookConfiguration struct {
307350
// +kubebuilder:default=443
308351
// +kubebuilder:validation:Maximum=65535
309352
Port int32 `json:"port,omitempty"`
353+
354+
WebhookConfiguration `json:",inline"`
310355
}
311356

312357
// ClusterManagerDeployOption describes the deployment options for cluster-manager
@@ -323,6 +368,10 @@ type ClusterManagerDeployOption struct {
323368
// +kubebuilder:validation:Enum=Default;Hosted
324369
Mode InstallMode `json:"mode,omitempty"`
325370

371+
// Default includes configurations for clustermanager in the Default mode
372+
// +optional
373+
Default *DefaultClusterManagerConfiguration `json:"default,omitempty"`
374+
326375
// Hosted includes configurations we need for clustermanager in the Hosted mode.
327376
// +optional
328377
Hosted *HostedClusterManagerConfiguration `json:"hosted,omitempty"`

operator/v1/zz_generated.deepcopy.go

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/integration/api/clustermanager_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ var _ = Describe("Create Cluster Manager Hosted mode", func() {
7878
Context("Set wrong format address", func() {
7979
It("should return err", func() {
8080
clusterManager.Spec.DeployOption.Hosted = &operatorv1.HostedClusterManagerConfiguration{
81-
RegistrationWebhookConfiguration: operatorv1.WebhookConfiguration{
81+
RegistrationWebhookConfiguration: operatorv1.HostedWebhookConfiguration{
8282
Address: "test:test",
8383
},
84-
WorkWebhookConfiguration: operatorv1.WebhookConfiguration{
84+
WorkWebhookConfiguration: operatorv1.HostedWebhookConfiguration{
8585
Address: "test:test",
8686
},
8787
}
@@ -93,10 +93,10 @@ var _ = Describe("Create Cluster Manager Hosted mode", func() {
9393
Context("Set IPV4 format addresses", func() {
9494
It("should create successfully", func() {
9595
clusterManager.Spec.DeployOption.Hosted = &operatorv1.HostedClusterManagerConfiguration{
96-
RegistrationWebhookConfiguration: operatorv1.WebhookConfiguration{
96+
RegistrationWebhookConfiguration: operatorv1.HostedWebhookConfiguration{
9797
Address: "192.168.2.3",
9898
},
99-
WorkWebhookConfiguration: operatorv1.WebhookConfiguration{
99+
WorkWebhookConfiguration: operatorv1.HostedWebhookConfiguration{
100100
Address: "192.168.2.4",
101101
},
102102
}
@@ -108,10 +108,10 @@ var _ = Describe("Create Cluster Manager Hosted mode", func() {
108108
Context("Set FQDN format addresses", func() {
109109
It("should create successfully", func() {
110110
clusterManager.Spec.DeployOption.Hosted = &operatorv1.HostedClusterManagerConfiguration{
111-
RegistrationWebhookConfiguration: operatorv1.WebhookConfiguration{
111+
RegistrationWebhookConfiguration: operatorv1.HostedWebhookConfiguration{
112112
Address: "localhost",
113113
},
114-
WorkWebhookConfiguration: operatorv1.WebhookConfiguration{
114+
WorkWebhookConfiguration: operatorv1.HostedWebhookConfiguration{
115115
Address: "foo.com",
116116
},
117117
}
@@ -121,12 +121,12 @@ var _ = Describe("Create Cluster Manager Hosted mode", func() {
121121
})
122122

123123
Context("Set nothing in ports", func() {
124-
It("should has 443 as default value", func() {
124+
It("should have 443 as default value in hosted mode", func() {
125125
clusterManager.Spec.DeployOption.Hosted = &operatorv1.HostedClusterManagerConfiguration{
126-
RegistrationWebhookConfiguration: operatorv1.WebhookConfiguration{
126+
RegistrationWebhookConfiguration: operatorv1.HostedWebhookConfiguration{
127127
Address: "localhost",
128128
},
129-
WorkWebhookConfiguration: operatorv1.WebhookConfiguration{
129+
WorkWebhookConfiguration: operatorv1.HostedWebhookConfiguration{
130130
Address: "foo.com",
131131
},
132132
}
@@ -140,11 +140,11 @@ var _ = Describe("Create Cluster Manager Hosted mode", func() {
140140
Context("Set port bigger than 65535", func() {
141141
It("should return err", func() {
142142
clusterManager.Spec.DeployOption.Hosted = &operatorv1.HostedClusterManagerConfiguration{
143-
RegistrationWebhookConfiguration: operatorv1.WebhookConfiguration{
143+
RegistrationWebhookConfiguration: operatorv1.HostedWebhookConfiguration{
144144
Address: "localhost",
145145
Port: 65536,
146146
},
147-
WorkWebhookConfiguration: operatorv1.WebhookConfiguration{
147+
WorkWebhookConfiguration: operatorv1.HostedWebhookConfiguration{
148148
Address: "foo.com",
149149
},
150150
}
@@ -156,11 +156,11 @@ var _ = Describe("Create Cluster Manager Hosted mode", func() {
156156
Context("Set customized WebhookConfiguration", func() {
157157
It("should have euqually value after create", func() {
158158
clusterManager.Spec.DeployOption.Hosted = &operatorv1.HostedClusterManagerConfiguration{
159-
RegistrationWebhookConfiguration: operatorv1.WebhookConfiguration{
159+
RegistrationWebhookConfiguration: operatorv1.HostedWebhookConfiguration{
160160
Address: "foo1.com",
161161
Port: 1443,
162162
},
163-
WorkWebhookConfiguration: operatorv1.WebhookConfiguration{
163+
WorkWebhookConfiguration: operatorv1.HostedWebhookConfiguration{
164164
Address: "foo2.com",
165165
Port: 2443,
166166
},

0 commit comments

Comments
 (0)