Skip to content

Commit d22cb1f

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

12 files changed

+632
-57
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,18 @@ 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+
driver specifies the authentication driver used by the ManagedClusterAddOn
306+
for this registration configuration when the signer name is
307+
`kubernetes.io/kube-apiserver-client`.
308+
This field is ignored for other signer names.
309+
Supported values are `csr` and `token`.
310+
The field is set by the agent to declare which authentication driver it is using.
311+
enum:
312+
- csr
313+
- token
314+
type: string
303315
signerName:
304316
description: |-
305317
Deprecated: Will be replaced with type: kubeClient and type: csr in v1beta1.

addon/v1alpha1/types_managedclusteraddon.go

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

7888
type AddOnConfig struct {

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,18 @@ 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+
driver specifies the authentication driver used by the ManagedClusterAddOn
306+
for this registration configuration when the signer name is
307+
`kubernetes.io/kube-apiserver-client`.
308+
This field is ignored for other signer names.
309+
Supported values are `csr` and `token`.
310+
The field is set by the agent to declare which authentication driver it is using.
311+
enum:
312+
- csr
313+
- token
314+
type: string
303315
signerName:
304316
description: |-
305317
Deprecated: Will be replaced with type: kubeClient and type: csr in v1beta1.
@@ -642,10 +654,10 @@ spec:
642654
description: RegistrationConfig defines the configuration for the
643655
addon agent to register to the hub cluster.
644656
properties:
645-
csr:
657+
customSigner:
646658
description: |-
647-
csr holds the configuration for csr type registration.
648-
It should be set when type is "csr".
659+
customSigner holds the configuration for customSigner type registration.
660+
It should be set when type is "customSigner".
649661
properties:
650662
signerName:
651663
description: signerName is the name of signer that addon
@@ -681,6 +693,14 @@ spec:
681693
kubeClient holds the configuration for kubeClient type registration.
682694
It should be set when type is "kubeClient".
683695
properties:
696+
driver:
697+
description: |-
698+
driver is the authentication driver used by managedclusteraddon for kubeClient registration. Possible values are csr and token.
699+
This field is set by the agent to declare which driver it is using.
700+
enum:
701+
- csr
702+
- token
703+
type: string
684704
subject:
685705
description: subject is the user subject of the addon agent
686706
to be registered to the hub.
@@ -699,7 +719,7 @@ spec:
699719
description: type specifies the type of registration configuration.
700720
enum:
701721
- kubeClient
702-
- csr
722+
- customSigner
703723
type: string
704724
required:
705725
- 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)