Skip to content

Commit 0ce554f

Browse files
committed
✨ support add-on registration
Signed-off-by: Yang Le <[email protected]>
1 parent 5102852 commit 0ce554f

12 files changed

+634
-56
lines changed

addon/v1alpha1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,19 @@ spec:
300300
RegistrationConfig defines the configuration of the addon agent to register to hub. The Klusterlet agent will
301301
create a csr for the addon agent with the registrationConfig.
302302
properties:
303+
driver:
304+
description: |-
305+
Deprecated: Will be replaced with kubeClient.driver in v1beta1.
306+
Driver specifies the authentication driver used by the ManagedClusterAddOn
307+
for this registration configuration when the signer name is
308+
`kubernetes.io/kube-apiserver-client`.
309+
This field is ignored for other signer names.
310+
Supported values are `csr` and `token`.
311+
The field is set by the agent to declare which authentication driver it is using.
312+
enum:
313+
- csr
314+
- token
315+
type: string
303316
signerName:
304317
description: |-
305318
Deprecated: Will be replaced with type: kubeClient and type: csr in v1beta1.

addon/v1alpha1/types_managedclusteraddon.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ type RegistrationConfig struct {
7373
//
7474
// +optional
7575
Subject Subject `json:"subject,omitempty"`
76+
77+
// Deprecated: Will be replaced with kubeClient.driver in v1beta1.
78+
// Driver specifies the authentication driver used by the ManagedClusterAddOn
79+
// for this registration configuration when the signer name is
80+
// `kubernetes.io/kube-apiserver-client`.
81+
// This field is ignored for other signer names.
82+
// Supported values are `csr` and `token`.
83+
// The field is set by the agent to declare which authentication driver it is using.
84+
// +optional
85+
// +kubebuilder:validation:Enum=csr;token
86+
Driver string `json:"driver,omitempty"`
7687
}
7788

7889
type AddOnConfig struct {

addon/v1beta1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,19 @@ spec:
300300
RegistrationConfig defines the configuration of the addon agent to register to hub. The Klusterlet agent will
301301
create a csr for the addon agent with the registrationConfig.
302302
properties:
303+
driver:
304+
description: |-
305+
Deprecated: Will be replaced with kubeClient.driver in v1beta1.
306+
Driver specifies the authentication driver used by the ManagedClusterAddOn
307+
for this registration configuration when the signer name is
308+
`kubernetes.io/kube-apiserver-client`.
309+
This field is ignored for other signer names.
310+
Supported values are `csr` and `token`.
311+
The field is set by the agent to declare which authentication driver it is using.
312+
enum:
313+
- csr
314+
- token
315+
type: string
303316
signerName:
304317
description: |-
305318
Deprecated: Will be replaced with type: kubeClient and type: csr in v1beta1.
@@ -642,10 +655,10 @@ spec:
642655
description: RegistrationConfig defines the configuration for the
643656
addon agent to register to the hub cluster.
644657
properties:
645-
csr:
658+
customSigner:
646659
description: |-
647-
csr holds the configuration for csr type registration.
648-
It should be set when type is "csr".
660+
customSigner holds the configuration for customSigner type registration.
661+
It should be set when type is "customSigner".
649662
properties:
650663
signerName:
651664
description: signerName is the name of signer that addon
@@ -681,6 +694,14 @@ spec:
681694
kubeClient holds the configuration for kubeClient type registration.
682695
It should be set when type is "kubeClient".
683696
properties:
697+
driver:
698+
description: |-
699+
Driver is the authentication driver used by managedclusteraddon for kubeClient registration. Possible values are csr and token.
700+
This field is set by the agent to declare which driver it is using.
701+
enum:
702+
- csr
703+
- token
704+
type: string
684705
subject:
685706
description: subject is the user subject of the addon agent
686707
to be registered to the hub.
@@ -699,7 +720,7 @@ spec:
699720
description: type specifies the type of registration configuration.
700721
enum:
701722
- kubeClient
702-
- csr
723+
- customSigner
703724
type: string
704725
required:
705726
- type

addon/v1beta1/conversion.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package v1beta1
33

44
import (
55
"fmt"
6+
67
certificates "k8s.io/api/certificates/v1"
78
"k8s.io/apimachinery/pkg/conversion"
89
"open-cluster-management.io/api/addon/v1alpha1"
@@ -117,12 +118,13 @@ func Convert_v1beta1_RegistrationConfig_To_v1alpha1_RegistrationConfig(in *Regis
117118
User: in.KubeClient.Subject.User,
118119
Groups: in.KubeClient.Subject.Groups,
119120
}
121+
out.Driver = in.KubeClient.Driver
120122
} else {
121-
if in.CSR == nil {
122-
return fmt.Errorf("nil CSR")
123+
if in.CustomSigner == nil {
124+
return fmt.Errorf("nil CustomSigner")
123125
}
124-
out.SignerName = in.CSR.SignerName
125-
if err := Convert_v1beta1_Subject_To_v1alpha1_Subject(&in.CSR.Subject, &out.Subject, s); err != nil {
126+
out.SignerName = in.CustomSigner.SignerName
127+
if err := Convert_v1beta1_Subject_To_v1alpha1_Subject(&in.CustomSigner.Subject, &out.Subject, s); err != nil {
126128
return err
127129
}
128130
}
@@ -141,10 +143,11 @@ func Convert_v1alpha1_RegistrationConfig_To_v1beta1_RegistrationConfig(in *v1alp
141143
Groups: in.Subject.Groups,
142144
},
143145
},
146+
Driver: in.Driver,
144147
}
145148
} else {
146-
out.Type = CSR
147-
out.CSR = &CSRConfig{
149+
out.Type = CustomSigner
150+
out.CustomSigner = &CustomSignerConfig{
148151
SignerName: in.SignerName,
149152
Subject: Subject{
150153
BaseSubject: BaseSubject{

0 commit comments

Comments
 (0)