Skip to content

Commit 9492e04

Browse files
committed
Update clustermanager API spec for auto approval identities
Signed-off-by: “Jeffrey <[email protected]>
1 parent bda1321 commit 9492e04

5 files changed

+133
-5
lines changed

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

+30-1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,32 @@ spec:
216216
description: RegistrationConfiguration contains the configuration
217217
of registration
218218
properties:
219+
autoApprovalIdentities:
220+
description: |-
221+
AutoApprovalIdentities represent the list of approved identities which is used to whitelist certain identities to join with the hub cluster
222+
An ApprovedIdentities contains details of the driver type (csr, awsirsa) and a list of identities to whitelist.
223+
items:
224+
properties:
225+
driver:
226+
default: csr
227+
description: Type of authentication used for specific set
228+
of identities to whitelist. Possible values are csr and
229+
awsirsa.
230+
enum:
231+
- csr
232+
- awsirsa
233+
type: string
234+
identities:
235+
description: Identities represent a list of users in which
236+
we will allow to join with hub cluster
237+
items:
238+
type: string
239+
type: array
240+
type: object
241+
type: array
242+
x-kubernetes-list-map-keys:
243+
- driver
244+
x-kubernetes-list-type: map
219245
autoApproveUsers:
220246
description: |-
221247
AutoApproveUser represents a list of users that can auto approve CSR and accept client. If the credential of the
@@ -270,7 +296,10 @@ spec:
270296
- awsirsa
271297
type: string
272298
hubClusterArn:
273-
description: This represents the hub cluster ARN
299+
description: |-
300+
This represents the hub cluster ARN
301+
Example - arn:eks:us-west-2:12345678910:cluster/hub-cluster1
302+
pattern: ^arn:aws:eks:([a-zA-Z0-9-]+):(\d{12}):cluster/([a-zA-Z0-9-]+)$
274303
type: string
275304
type: object
276305
type: array

operator/v1/types_clustermanager.go

+21
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ type RegistrationHubConfiguration struct {
115115
// +listType=map
116116
// +listMapKey=authType
117117
RegistrationDrivers []RegistrationDriverHub `json:"registrationDrivers,omitempty"`
118+
119+
// AutoApprovalIdentities represent the list of approved identities which is used to whitelist certain identities to join with the hub cluster
120+
// An ApprovedIdentities contains details of the driver type (csr, awsirsa) and a list of identities to whitelist.
121+
// +optional
122+
// +listType=map
123+
// +listMapKey=driver
124+
AutoApprovalIdentities []ApprovedIdentities `json:"autoApprovalIdentities,omitempty"`
118125
}
119126

120127
type RegistrationDriverHub struct {
@@ -126,10 +133,24 @@ type RegistrationDriverHub struct {
126133
AuthType string `json:"authType,omitempty"`
127134

128135
// This represents the hub cluster ARN
136+
// Example - arn:eks:us-west-2:12345678910:cluster/hub-cluster1
129137
// +optional
138+
// +kubebuilder:validation:Pattern=`^arn:aws:eks:([a-zA-Z0-9-]+):(\d{12}):cluster/([a-zA-Z0-9-]+)$`
130139
HubClusterArn string `json:"hubClusterArn,omitempty"`
131140
}
132141

142+
type ApprovedIdentities struct {
143+
// Type of authentication used for specific set of identities to whitelist. Possible values are csr and awsirsa.
144+
// +required
145+
// +kubebuilder:default:=csr
146+
// +kubebuilder:validation:Enum=csr;awsirsa
147+
Driver string `json:"driver,omitempty"`
148+
149+
// Identities represent a list of users in which we will allow to join with hub cluster
150+
// +required
151+
Identities []string `json:"identities,omitempty"`
152+
}
153+
133154
type WorkConfiguration struct {
134155
// FeatureGates represents the list of feature gates for work
135156
// If it is set empty, default feature gates will be used.

operator/v1/zz_generated.deepcopy.go

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operator/v1/zz_generated.swagger_doc_generated.go

+14-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/integration/api/clustermanager_test.go

+40
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,46 @@ var _ = Describe("ClusterManager API test with RegistrationConfiguration", func(
261261
Expect(clusterManager.Spec.RegistrationConfiguration.FeatureGates[0].Mode).Should(Equal(operatorv1.FeatureGateModeTypeDisable))
262262
Expect(clusterManager.Spec.RegistrationConfiguration.FeatureGates[1].Mode).Should(Equal(operatorv1.FeatureGateModeTypeEnable))
263263
})
264+
265+
It("Create a cluster manager with aws registration and invalid hubClusterArn", func() {
266+
clusterManager := &operatorv1.ClusterManager{
267+
ObjectMeta: metav1.ObjectMeta{
268+
Name: clusterManagerName,
269+
},
270+
Spec: operatorv1.ClusterManagerSpec{
271+
RegistrationConfiguration: &operatorv1.RegistrationHubConfiguration{
272+
RegistrationDrivers: []operatorv1.RegistrationDriverHub{
273+
{
274+
AuthType: "awsirsa",
275+
HubClusterArn: "arn:aws:bks:us-west-2:123456789012:cluster/hub-cluster1",
276+
},
277+
},
278+
},
279+
},
280+
}
281+
_, err := operatorClient.OperatorV1().ClusterManagers().Create(context.TODO(), clusterManager, metav1.CreateOptions{})
282+
Expect(err).ToNot(BeNil())
283+
})
284+
285+
It("Create a cluster manager with aws registration and valid hubClusterArn", func() {
286+
clusterManager := &operatorv1.ClusterManager{
287+
ObjectMeta: metav1.ObjectMeta{
288+
Name: clusterManagerName,
289+
},
290+
Spec: operatorv1.ClusterManagerSpec{
291+
RegistrationConfiguration: &operatorv1.RegistrationHubConfiguration{
292+
RegistrationDrivers: []operatorv1.RegistrationDriverHub{
293+
{
294+
AuthType: "awsirsa",
295+
HubClusterArn: "arn:aws:eks:us-west-2:123456789012:cluster/hub-cluster1",
296+
},
297+
},
298+
},
299+
},
300+
}
301+
_, err := operatorClient.OperatorV1().ClusterManagers().Create(context.TODO(), clusterManager, metav1.CreateOptions{})
302+
Expect(err).To(BeNil())
303+
})
264304
})
265305

266306
var _ = Describe("ClusterManager API test with WorkConfiguration", func() {

0 commit comments

Comments
 (0)