Skip to content

Commit

Permalink
radosnamespace: add new CRD
Browse files Browse the repository at this point in the history
This introduces a new CRD to add the ability
to create rados namespace for a given
ceph block pool. Typically the name of the pool
is the name of the blockpool created by rook.

Closes: #7035

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Feb 14, 2022
1 parent c3e02e7 commit c2a01c0
Show file tree
Hide file tree
Showing 33 changed files with 1,812 additions and 2 deletions.
1 change: 1 addition & 0 deletions .commitlintrc.json
Expand Up @@ -30,6 +30,7 @@
"rgw",
"security",
"subvolumegroup",
"radosnamespace",
"test"
]
],
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/canary-integration-test.yml
Expand Up @@ -91,6 +91,11 @@ jobs:
toolbox=$(kubectl get pod -l app=rook-ceph-tools -n rook-ceph -o jsonpath='{.items[*].metadata.name}')
timeout 60 sh -c "until kubectl -n rook-ceph exec $toolbox -- ceph fs subvolumegroup ls myfs|jq .[0].name|grep -q "group-a"; do sleep 1 && echo 'waiting for the subvolumegroup to be created'; done"
- name: wait for the rados namespace to be created
run: |
toolbox=$(kubectl get pod -l app=rook-ceph-tools -n rook-ceph -o jsonpath='{.items[*].metadata.name}')
timeout 60 sh -c "until kubectl -n rook-ceph exec $toolbox -- rbd namespace ls replicapool|jq .[0].name|grep -q "namespace-a"; do sleep 1 && echo 'waiting for the rados namespace to be created'; done"
- name: test external script with restricted_auth_permission flag and without having cephfs_filesystem flag
run: |
toolbox=$(kubectl get pod -l app=rook-ceph-tools -n rook-ceph -o jsonpath='{.items[*].metadata.name}')
Expand Down
44 changes: 44 additions & 0 deletions Documentation/ceph-pool-radosnamespace.md
@@ -0,0 +1,44 @@
---
title: RadosNamespace CRD
weight: 3610
indent: true
---

{% include_relative branch.liquid %}

This guide assumes you have created a Rook cluster as explained in the main [Quickstart guide](quickstart.md)

# CephBlockPoolRadosNamespace CRD

Rook allows creation of Ceph BlockPool
[RadosNamespaces](https://docs.ceph.com/en/latest/man/8/rbd/) through the
custom resource definitions (CRDs). BlockPool Rados Namespace is an abstraction
for a block pool. For more information about BlockPool and namespace refer to
the [Ceph docs](https://docs.ceph.com/en/latest/man/8/rbd/).

## Creating daemon

To get you started, here is a simple example of a CRD to create a CephBlockPoolRadosNamespace on the CephBlockPool "replicapool".

```yaml
apiVersion: ceph.rook.io/v1
kind: CephBlockPoolRadosNamespace
metadata:
name: namespace-a
namespace: rook-ceph # namespace:cluster
spec:
# blockpoolName is the name of Ceph BlockPool. Typically it's the name of the CephBlockPool CR.
blockpoolName: replicapool
```

## Settings

If any setting is unspecified, a suitable default will be used automatically.

### CephBlockPoolRadosNamespace metadata

- `name`: The name that will be used for the Ceph BlockPool rados namespace.

### CephBlockPoolRadosNamespace spec

- `blockPoolName`: The metadata name of the CephBlockPool CR where the rados namespace will be created.
3 changes: 3 additions & 0 deletions deploy/charts/rook-ceph/templates/clusterrole.yaml
Expand Up @@ -136,6 +136,7 @@ rules:
- cephrbdmirrors
- cephfilesystemmirrors
- cephfilesystemsubvolumegroups
- cephblockpoolradosnamespaces
verbs:
- get
- list
Expand All @@ -160,6 +161,7 @@ rules:
- cephrbdmirrors/status
- cephfilesystemmirrors/status
- cephfilesystemsubvolumegroups/status
- cephblockpoolradosnamespaces/status
verbs: ["update"]
# The "*/finalizers" permission may need to be strictly given for K8s clusters where
# OwnerReferencesPermissionEnforcement is enabled so that Rook can set blockOwnerDeletion on
Expand All @@ -182,6 +184,7 @@ rules:
- cephrbdmirrors/finalizers
- cephfilesystemmirrors/finalizers
- cephfilesystemsubvolumegroups/finalizers
- cephblockpoolradosnamespaces/finalizers
verbs: ["update"]
- apiGroups:
- policy
Expand Down
89 changes: 89 additions & 0 deletions deploy/charts/rook-ceph/templates/resources.yaml
@@ -1,6 +1,73 @@
{{- if .Values.crds.enabled }}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.5.1-0.20210420220833-f284e2e8098c
helm.sh/resource-policy: keep
creationTimestamp: null
name: cephblockpoolradosnamespaces.ceph.rook.io
spec:
group: ceph.rook.io
names:
kind: CephBlockPoolRadosNamespace
listKind: CephBlockPoolRadosNamespaceList
plural: cephblockpoolradosnamespaces
singular: cephblockpoolradosnamespace
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: CephBlockPoolRadosNamespace represents a Ceph BlockPool Rados Namespace
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: Spec represents the specification of a Ceph BlockPool Rados Namespace
properties:
blockpoolName:
description: BlockPoolName is the name of Ceph BlockPool. Typically it's the name of the CephBlockPool CR.
type: string
required:
- blockpoolName
type: object
status:
description: Status represents the status of a CephBlockPool Rados Namespace
properties:
info:
additionalProperties:
type: string
nullable: true
type: object
phase:
description: ConditionType represent a resource's status
type: string
type: object
x-kubernetes-preserve-unknown-fields: true
required:
- metadata
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.5.1-0.20210420220833-f284e2e8098c
Expand Down Expand Up @@ -200,6 +267,28 @@ spec:
status:
description: CephBlockPoolStatus represents the mirroring status of Ceph Storage Pool
properties:
conditions:
items:
description: Condition represents a status condition on any Rook-Ceph Custom Resource.
properties:
lastHeartbeatTime:
format: date-time
type: string
lastTransitionTime:
format: date-time
type: string
message:
type: string
reason:
description: ConditionReason is a reason for a condition
type: string
status:
type: string
type:
description: ConditionType represent a resource's status
type: string
type: object
type: array
info:
additionalProperties:
type: string
Expand Down
3 changes: 3 additions & 0 deletions deploy/examples/common.yaml
Expand Up @@ -312,6 +312,7 @@ rules:
- cephrbdmirrors
- cephfilesystemmirrors
- cephfilesystemsubvolumegroups
- cephblockpoolradosnamespaces
verbs:
- get
- list
Expand All @@ -336,6 +337,7 @@ rules:
- cephrbdmirrors/status
- cephfilesystemmirrors/status
- cephfilesystemsubvolumegroups/status
- cephblockpoolradosnamespaces/status
verbs: ["update"]
# The "*/finalizers" permission may need to be strictly given for K8s clusters where
# OwnerReferencesPermissionEnforcement is enabled so that Rook can set blockOwnerDeletion on
Expand All @@ -358,6 +360,7 @@ rules:
- cephrbdmirrors/finalizers
- cephfilesystemmirrors/finalizers
- cephfilesystemsubvolumegroups/finalizers
- cephblockpoolradosnamespaces/finalizers
verbs: ["update"]
- apiGroups:
- policy
Expand Down
88 changes: 88 additions & 0 deletions deploy/examples/crds.yaml
Expand Up @@ -5,6 +5,72 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.5.1-0.20210420220833-f284e2e8098c
creationTimestamp: null
name: cephblockpoolradosnamespaces.ceph.rook.io
spec:
group: ceph.rook.io
names:
kind: CephBlockPoolRadosNamespace
listKind: CephBlockPoolRadosNamespaceList
plural: cephblockpoolradosnamespaces
singular: cephblockpoolradosnamespace
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: CephBlockPoolRadosNamespace represents a Ceph BlockPool Rados Namespace
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: Spec represents the specification of a Ceph BlockPool Rados Namespace
properties:
blockpoolName:
description: BlockPoolName is the name of Ceph BlockPool. Typically it's the name of the CephBlockPool CR.
type: string
required:
- blockpoolName
type: object
status:
description: Status represents the status of a CephBlockPool Rados Namespace
properties:
info:
additionalProperties:
type: string
nullable: true
type: object
phase:
description: ConditionType represent a resource's status
type: string
type: object
x-kubernetes-preserve-unknown-fields: true
required:
- metadata
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.5.1-0.20210420220833-f284e2e8098c
Expand Down Expand Up @@ -203,6 +269,28 @@ spec:
status:
description: CephBlockPoolStatus represents the mirroring status of Ceph Storage Pool
properties:
conditions:
items:
description: Condition represents a status condition on any Rook-Ceph Custom Resource.
properties:
lastHeartbeatTime:
format: date-time
type: string
lastTransitionTime:
format: date-time
type: string
message:
type: string
reason:
description: ConditionReason is a reason for a condition
type: string
status:
type: string
type:
description: ConditionType represent a resource's status
type: string
type: object
type: array
info:
additionalProperties:
type: string
Expand Down
9 changes: 9 additions & 0 deletions deploy/examples/radosnamespace.yaml
@@ -0,0 +1,9 @@
---
apiVersion: ceph.rook.io/v1
kind: CephBlockPoolRadosNamespace
metadata:
name: namespace-a
namespace: rook-ceph # namespace:cluster
spec:
# blockpoolName is the name of Ceph BlockPool. Typically it's the name of the CephBlockPool CR.
blockpoolName: replicapool
5 changes: 5 additions & 0 deletions deploy/olm/assemble/metadata-common.yaml
Expand Up @@ -168,6 +168,11 @@ spec:
version: v1
displayName: Ceph Filesystem SubVolumeGroup
description: Represents a Ceph Filesystem SubVolumeGroup.
- kind: CephBlockPoolRadosNamespace
name: cephblockpoolradosnamespaces.ceph.rook.io
version: v1
displayName: Ceph BlockPool Rados Namespace
description: Represents a CCeph BlockPool Rados Namespace.
displayName: Rook-Ceph
description: |
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/ceph.rook.io/v1/pool.go
Expand Up @@ -118,6 +118,10 @@ func (p *CephBlockPool) ValidateDelete() error {
return nil
}

func (p *CephBlockPool) GetStatusConditions() *[]Condition {
return &p.Status.Conditions
}

// SnapshotSchedulesEnabled returns whether snapshot schedules are desired
func (p *MirroringSpec) SnapshotSchedulesEnabled() bool {
return len(p.SnapshotSchedules) > 0
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/ceph.rook.io/v1/register.go
Expand Up @@ -85,6 +85,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&CephFilesystemMirrorList{},
&CephFilesystemSubVolumeGroup{},
&CephFilesystemSubVolumeGroupList{},
&CephBlockPoolRadosNamespace{},
&CephBlockPoolRadosNamespaceList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
scheme.AddKnownTypes(bktv1alpha1.SchemeGroupVersion,
Expand Down

0 comments on commit c2a01c0

Please sign in to comment.