diff --git a/Documentation/CRDs/specification.md b/Documentation/CRDs/specification.md
index e24b01db5..03120f23d 100644
--- a/Documentation/CRDs/specification.md
+++ b/Documentation/CRDs/specification.md
@@ -592,6 +592,32 @@ string
+secretName
+
+string
+
+ |
+
+(Optional)
+ SecretName is the name of the secret created for this ceph client.
+If not specified, the default name is “rook-ceph-client-” as a prefix to the CR name.
+ |
+
+
+
+removeSecret
+
+bool
+
+ |
+
+(Optional)
+ RemoveSecret indicates whether the current secret for this ceph client should be removed or not.
+If true, the K8s secret will be deleted, but the cephx keyring will remain until the CR is deleted.
+ |
+
+
+
caps
map[string]string
@@ -4661,6 +4687,32 @@ string
|
+secretName
+
+string
+
+ |
+
+(Optional)
+ SecretName is the name of the secret created for this ceph client.
+If not specified, the default name is “rook-ceph-client-” as a prefix to the CR name.
+ |
+
+
+
+removeSecret
+
+bool
+
+ |
+
+(Optional)
+ RemoveSecret indicates whether the current secret for this ceph client should be removed or not.
+If true, the K8s secret will be deleted, but the cephx keyring will remain until the CR is deleted.
+ |
+
+
+
caps
map[string]string
diff --git a/deploy/charts/rook-ceph/templates/resources.yaml b/deploy/charts/rook-ceph/templates/resources.yaml
index 28ac9cf7d..aecfe701d 100644
--- a/deploy/charts/rook-ceph/templates/resources.yaml
+++ b/deploy/charts/rook-ceph/templates/resources.yaml
@@ -1293,6 +1293,19 @@ spec:
x-kubernetes-preserve-unknown-fields: true
name:
type: string
+ removeSecret:
+ description: |-
+ RemoveSecret indicates whether the current secret for this ceph client should be removed or not.
+ If true, the K8s secret will be deleted, but the cephx keyring will remain until the CR is deleted.
+ type: boolean
+ secretName:
+ description: |-
+ SecretName is the name of the secret created for this ceph client.
+ If not specified, the default name is "rook-ceph-client-" as a prefix to the CR name.
+ type: string
+ x-kubernetes-validations:
+ - message: SecretName is immutable and cannot be changed
+ rule: self == oldSelf
required:
- caps
type: object
diff --git a/deploy/examples/crds.yaml b/deploy/examples/crds.yaml
index d34ad9a60..5a57b0313 100644
--- a/deploy/examples/crds.yaml
+++ b/deploy/examples/crds.yaml
@@ -1292,6 +1292,19 @@ spec:
x-kubernetes-preserve-unknown-fields: true
name:
type: string
+ removeSecret:
+ description: |-
+ RemoveSecret indicates whether the current secret for this ceph client should be removed or not.
+ If true, the K8s secret will be deleted, but the cephx keyring will remain until the CR is deleted.
+ type: boolean
+ secretName:
+ description: |-
+ SecretName is the name of the secret created for this ceph client.
+ If not specified, the default name is "rook-ceph-client-" as a prefix to the CR name.
+ type: string
+ x-kubernetes-validations:
+ - message: SecretName is immutable and cannot be changed
+ rule: self == oldSelf
required:
- caps
type: object
diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go
index 04bd2ed25..1e8455f3e 100755
--- a/pkg/apis/ceph.rook.io/v1/types.go
+++ b/pkg/apis/ceph.rook.io/v1/types.go
@@ -3079,6 +3079,16 @@ type CephClientList struct {
type ClientSpec struct {
// +optional
Name string `json:"name,omitempty"`
+ // SecretName is the name of the secret created for this ceph client.
+ // If not specified, the default name is "rook-ceph-client-" as a prefix to the CR name.
+ // +kubebuilder:validation:XValidation:message="SecretName is immutable and cannot be changed",rule="self == oldSelf"
+ // +optional
+ SecretName string `json:"secretName,omitempty"`
+
+ // RemoveSecret indicates whether the current secret for this ceph client should be removed or not.
+ // If true, the K8s secret will be deleted, but the cephx keyring will remain until the CR is deleted.
+ // +optional
+ RemoveSecret bool `json:"removeSecret,omitempty"`
// +kubebuilder:pruning:PreserveUnknownFields
Caps map[string]string `json:"caps"`
}
diff --git a/pkg/operator/ceph/client/controller.go b/pkg/operator/ceph/client/controller.go
index 8f3e64bbd..0c3fb4dea 100644
--- a/pkg/operator/ceph/client/controller.go
+++ b/pkg/operator/ceph/client/controller.go
@@ -399,5 +399,8 @@ func generateStatusInfo(client *cephv1.CephClient) map[string]string {
}
func generateCephUserSecretName(client *cephv1.CephClient) string {
+ if client.Spec.SecretName != "" {
+ return client.Spec.SecretName // return the secret name as requested by user.
+ }
return fmt.Sprintf("rook-ceph-client-%s", client.Name)
}
diff --git a/pkg/operator/ceph/client/controller_test.go b/pkg/operator/ceph/client/controller_test.go
index 0a04e1875..97dd18ded 100644
--- a/pkg/operator/ceph/client/controller_test.go
+++ b/pkg/operator/ceph/client/controller_test.go
@@ -312,5 +312,21 @@ func TestBuildUpdateStatusInfo(t *testing.T) {
statusInfo := generateStatusInfo(cephClient)
assert.NotEmpty(t, statusInfo["secretName"])
- assert.Equal(t, "rook-ceph-client-client-ocp", statusInfo["secretName"])
+ assert.Equal(t, generateCephUserSecretName(cephClient), statusInfo["secretName"])
+}
+
+func TestCustomSecretname(t *testing.T) {
+ secretName := "test-secret"
+ cephClient := &cephv1.CephClient{
+ ObjectMeta: metav1.ObjectMeta{
+ Name: "client-ocp",
+ },
+ Spec: cephv1.ClientSpec{
+ SecretName: secretName,
+ },
+ }
+
+ statusInfo := generateStatusInfo(cephClient)
+ assert.NotEmpty(t, statusInfo["secretName"])
+ assert.Equal(t, secretName, statusInfo["secretName"])
}
|