Skip to content

Commit cde7377

Browse files
authored
Merge pull request #280 from iPraveenParihar/api/controller-publish-secret
api: ClientProfile default controller publish secret
2 parents 39d2e6c + 2740520 commit cde7377

File tree

9 files changed

+280
-8
lines changed

9 files changed

+280
-8
lines changed

api/v1/clientprofile_types.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ import (
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
)
2323

24+
// CephCsiSecretsSpec defines the secrets used by the client profile
25+
// to access the Ceph cluster and perform operations
26+
// on volumes.
27+
type CephCsiSecretsSpec struct {
28+
//+kubebuilder:validation:Optional
29+
ControllerPublishSecret corev1.SecretReference `json:"controllerPublishSecret,omitempty"`
30+
}
31+
2432
// CephFsConfigSpec defines the desired CephFs configuration
2533
type CephFsConfigSpec struct {
2634
//+kubebuilder:validation:Optional
@@ -35,13 +43,19 @@ type CephFsConfigSpec struct {
3543
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="field is immutable"
3644
//+kubebuilder:validation:Optional
3745
RadosNamespace *string `json:"radosNamespace,omitempty"`
46+
47+
//+kubebuilder:validation:Optional
48+
CephCsiSecrets *CephCsiSecretsSpec `json:"cephCsiSecrets,omitempty"`
3849
}
3950

4051
// RbdConfigSpec defines the desired RBD configuration
4152
type RbdConfigSpec struct {
4253
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="field is immutable"
4354
//+kubebuilder:validation:Optional
4455
RadosNamespace string `json:"radosNamespace,omitempty"`
56+
57+
//+kubebuilder:validation:Optional
58+
CephCsiSecrets *CephCsiSecretsSpec `json:"cephCsiSecrets,omitempty"`
4559
}
4660

4761
// NfsConfigSpec cdefines the desired NFS configuration

api/v1/zz_generated.deepcopy.go

Lines changed: 27 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/csi.ceph.io_clientprofiles.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,28 @@ spec:
6464
cephFs:
6565
description: CephFsConfigSpec defines the desired CephFs configuration
6666
properties:
67+
cephCsiSecrets:
68+
description: |-
69+
CephCsiSecretsSpec defines the secrets used by the client profile
70+
to access the Ceph cluster and perform operations
71+
on volumes.
72+
properties:
73+
controllerPublishSecret:
74+
description: |-
75+
SecretReference represents a Secret Reference. It has enough information to retrieve secret
76+
in any namespace
77+
properties:
78+
name:
79+
description: name is unique within a namespace to reference
80+
a secret resource.
81+
type: string
82+
namespace:
83+
description: namespace defines the space within which
84+
the secret name must be unique.
85+
type: string
86+
type: object
87+
x-kubernetes-map-type: atomic
88+
type: object
6789
fuseMountOptions:
6890
additionalProperties:
6991
type: string
@@ -86,6 +108,28 @@ spec:
86108
rbd:
87109
description: RbdConfigSpec defines the desired RBD configuration
88110
properties:
111+
cephCsiSecrets:
112+
description: |-
113+
CephCsiSecretsSpec defines the secrets used by the client profile
114+
to access the Ceph cluster and perform operations
115+
on volumes.
116+
properties:
117+
controllerPublishSecret:
118+
description: |-
119+
SecretReference represents a Secret Reference. It has enough information to retrieve secret
120+
in any namespace
121+
properties:
122+
name:
123+
description: name is unique within a namespace to reference
124+
a secret resource.
125+
type: string
126+
namespace:
127+
description: namespace defines the space within which
128+
the secret name must be unique.
129+
type: string
130+
type: object
131+
x-kubernetes-map-type: atomic
132+
type: object
89133
radosNamespace:
90134
type: string
91135
x-kubernetes-validations:

deploy/all-in-one/install.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,28 @@ spec:
338338
cephFs:
339339
description: CephFsConfigSpec defines the desired CephFs configuration
340340
properties:
341+
cephCsiSecrets:
342+
description: |-
343+
CephCsiSecretsSpec defines the secrets used by the client profile
344+
to access the Ceph cluster and perform operations
345+
on volumes.
346+
properties:
347+
controllerPublishSecret:
348+
description: |-
349+
SecretReference represents a Secret Reference. It has enough information to retrieve secret
350+
in any namespace
351+
properties:
352+
name:
353+
description: name is unique within a namespace to reference
354+
a secret resource.
355+
type: string
356+
namespace:
357+
description: namespace defines the space within which
358+
the secret name must be unique.
359+
type: string
360+
type: object
361+
x-kubernetes-map-type: atomic
362+
type: object
341363
fuseMountOptions:
342364
additionalProperties:
343365
type: string
@@ -360,6 +382,28 @@ spec:
360382
rbd:
361383
description: RbdConfigSpec defines the desired RBD configuration
362384
properties:
385+
cephCsiSecrets:
386+
description: |-
387+
CephCsiSecretsSpec defines the secrets used by the client profile
388+
to access the Ceph cluster and perform operations
389+
on volumes.
390+
properties:
391+
controllerPublishSecret:
392+
description: |-
393+
SecretReference represents a Secret Reference. It has enough information to retrieve secret
394+
in any namespace
395+
properties:
396+
name:
397+
description: name is unique within a namespace to reference
398+
a secret resource.
399+
type: string
400+
namespace:
401+
description: namespace defines the space within which
402+
the secret name must be unique.
403+
type: string
404+
type: object
405+
x-kubernetes-map-type: atomic
406+
type: object
363407
radosNamespace:
364408
type: string
365409
x-kubernetes-validations:

deploy/charts/ceph-csi-operator/templates/clientprofile-crd.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,28 @@ spec:
6565
cephFs:
6666
description: CephFsConfigSpec defines the desired CephFs configuration
6767
properties:
68+
cephCsiSecrets:
69+
description: |-
70+
CephCsiSecretsSpec defines the secrets used by the client profile
71+
to access the Ceph cluster and perform operations
72+
on volumes.
73+
properties:
74+
controllerPublishSecret:
75+
description: |-
76+
SecretReference represents a Secret Reference. It has enough information to retrieve secret
77+
in any namespace
78+
properties:
79+
name:
80+
description: name is unique within a namespace to reference
81+
a secret resource.
82+
type: string
83+
namespace:
84+
description: namespace defines the space within which the
85+
secret name must be unique.
86+
type: string
87+
type: object
88+
x-kubernetes-map-type: atomic
89+
type: object
6890
fuseMountOptions:
6991
additionalProperties:
7092
type: string
@@ -87,6 +109,28 @@ spec:
87109
rbd:
88110
description: RbdConfigSpec defines the desired RBD configuration
89111
properties:
112+
cephCsiSecrets:
113+
description: |-
114+
CephCsiSecretsSpec defines the secrets used by the client profile
115+
to access the Ceph cluster and perform operations
116+
on volumes.
117+
properties:
118+
controllerPublishSecret:
119+
description: |-
120+
SecretReference represents a Secret Reference. It has enough information to retrieve secret
121+
in any namespace
122+
properties:
123+
name:
124+
description: name is unique within a namespace to reference
125+
a secret resource.
126+
type: string
127+
namespace:
128+
description: namespace defines the space within which the
129+
secret name must be unique.
130+
type: string
131+
type: object
132+
x-kubernetes-map-type: atomic
133+
type: object
90134
radosNamespace:
91135
type: string
92136
x-kubernetes-validations:

deploy/multifile/crd.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,28 @@ spec:
329329
cephFs:
330330
description: CephFsConfigSpec defines the desired CephFs configuration
331331
properties:
332+
cephCsiSecrets:
333+
description: |-
334+
CephCsiSecretsSpec defines the secrets used by the client profile
335+
to access the Ceph cluster and perform operations
336+
on volumes.
337+
properties:
338+
controllerPublishSecret:
339+
description: |-
340+
SecretReference represents a Secret Reference. It has enough information to retrieve secret
341+
in any namespace
342+
properties:
343+
name:
344+
description: name is unique within a namespace to reference
345+
a secret resource.
346+
type: string
347+
namespace:
348+
description: namespace defines the space within which
349+
the secret name must be unique.
350+
type: string
351+
type: object
352+
x-kubernetes-map-type: atomic
353+
type: object
332354
fuseMountOptions:
333355
additionalProperties:
334356
type: string
@@ -351,6 +373,28 @@ spec:
351373
rbd:
352374
description: RbdConfigSpec defines the desired RBD configuration
353375
properties:
376+
cephCsiSecrets:
377+
description: |-
378+
CephCsiSecretsSpec defines the secrets used by the client profile
379+
to access the Ceph cluster and perform operations
380+
on volumes.
381+
properties:
382+
controllerPublishSecret:
383+
description: |-
384+
SecretReference represents a Secret Reference. It has enough information to retrieve secret
385+
in any namespace
386+
properties:
387+
name:
388+
description: name is unique within a namespace to reference
389+
a secret resource.
390+
type: string
391+
namespace:
392+
description: namespace defines the space within which
393+
the secret name must be unique.
394+
type: string
395+
type: object
396+
x-kubernetes-map-type: atomic
397+
type: object
354398
radosNamespace:
355399
type: string
356400
x-kubernetes-validations:

internal/controller/clientprofile_controller.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,22 @@ type csiClusterInfoRecord struct {
6767
ClusterId string `json:"clusterID,omitempty"`
6868
Monitors []string `json:"monitors,omitempty"`
6969
CephFs struct {
70-
SubvolumeGroup string `json:"subvolumeGroup,omitempty"`
71-
KernelMountOptions string `json:"kernelMountOptions"`
72-
FuseMountOptions string `json:"fuseMountOptions"`
73-
RadosNamespace string `json:"radosNamespace,omitempty"`
70+
SubvolumeGroup string `json:"subvolumeGroup,omitempty"`
71+
KernelMountOptions string `json:"kernelMountOptions"`
72+
FuseMountOptions string `json:"fuseMountOptions"`
73+
RadosNamespace string `json:"radosNamespace,omitempty"`
74+
ControllerPublishSecretRef struct {
75+
Name string `json:"name,omitempty"`
76+
Namespace string `json:"namespace,omitempty"`
77+
} `json:"controllerPublishSecretRef,omitempty"`
7478
} `json:"cephFS,omitempty"`
7579
Rbd struct {
76-
RadosNamespace string `json:"radosNamespace,omitempty"`
77-
MirrorCount int `json:"mirrorCount,omitempty"`
80+
RadosNamespace string `json:"radosNamespace,omitempty"`
81+
MirrorCount int `json:"mirrorCount,omitempty"`
82+
ControllerPublishSecretRef struct {
83+
Name string `json:"name,omitempty"`
84+
Namespace string `json:"namespace,omitempty"`
85+
} `json:"controllerPublishSecretRef,omitempty"`
7886
} `json:"rbd,omitempty"`
7987
Nfs struct{} `json:"nfs,omitempty"`
8088
ReadAffinity struct {
@@ -322,10 +330,18 @@ func composeCsiClusterInfoRecord(clientProfile *csiv1.ClientProfile, cephConn *c
322330
if mountOpt := cephFs.FuseMountOptions; mountOpt != nil {
323331
record.CephFs.FuseMountOptions = utils.MapToString(mountOpt, "=", ",")
324332
}
333+
if cephCsiSecrets := cephFs.CephCsiSecrets; cephCsiSecrets != nil {
334+
record.CephFs.ControllerPublishSecretRef.Name = cephCsiSecrets.ControllerPublishSecret.Name
335+
record.CephFs.ControllerPublishSecretRef.Namespace = cephCsiSecrets.ControllerPublishSecret.Namespace
336+
}
325337
}
326338
if rbd := clientProfile.Spec.Rbd; rbd != nil {
327339
record.Rbd.RadosNamespace = rbd.RadosNamespace
328340
record.Rbd.MirrorCount = cephConn.Spec.RbdMirrorDaemonCount
341+
if cephCsiSecrets := rbd.CephCsiSecrets; cephCsiSecrets != nil {
342+
record.Rbd.ControllerPublishSecretRef.Name = cephCsiSecrets.ControllerPublishSecret.Name
343+
record.Rbd.ControllerPublishSecretRef.Namespace = cephCsiSecrets.ControllerPublishSecret.Namespace
344+
}
329345
}
330346
if readAffinity := cephConn.Spec.ReadAffinity; readAffinity != nil {
331347
record.ReadAffinity.Enabled = true

0 commit comments

Comments
 (0)