Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document how to have StorageClass consume Rados Namespace #14173

Merged
merged 1 commit into from
May 20, 2024

Conversation

obnoxxx
Copy link
Contributor

@obnoxxx obnoxxx commented May 7, 2024

description

This change expands the documentation to describe how to create a storageclass that consumes a CephBlockPoolRadodNamespace.

Issue resolved by this Pull Request:
Resolves #13214

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Reviewed the developer guide on Submitting a Pull Request
  • Pending release notes updated with breaking and/or notable changes for the next minor release.
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

@obnoxxx obnoxxx changed the title docs: document how to hace StorageClass consume Rados Namespace docs: document how to have StorageClass consume Rados Namespace May 7, 2024
@@ -0,0 +1,8 @@
apiVersion: ceph.rook.io/v1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only "test.yaml" files needed are basically for pools to use replica 1, or when some other component needs to define a single daemon. Since there is nothing related to replica 1 in this file, let's revert this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,66 @@
apiVersion: ceph.rook.io/v1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename this file without the "test" suffix. I think no need to commit a test version of this file. It won't be common to use during development. Normally the "test" file are only used during development.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

spec:
# The name of the CephBlockPool CR where the namespace is created.
blockPoolName: replicapool

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@obnoxxx obnoxxx force-pushed the sc-radosnamespace branch 5 times, most recently from 919c271 to 10890c7 Compare May 7, 2024 20:42
Copy link
Member

@travisn travisn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few more suggestions on whitespace and comments

failureDomain: osd
replicated:
size: 3
# Disallow setting pool with replica 1, this could lead to data loss without recovery.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is not accurate since we changed back to a replica 3 pool. For simplicity of the example, how about just remove the comments from the CephBlockPool? They can see comments in other pool examples if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

# normally, clusterID is the kubernetes namespace where the rook cluster is running
# But putting the ClusterID of a CephBlockPoolRadosNamespace CR here instead
# will let the storageClass consume that Rados namespace.
clusterID: 80fc4f4bacc064be641633e6ed25ba7e
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this be always same for this example setup, if not we should not hardcode this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best I know yes, it will be the same (being a hash of the blockpool name etc). this is why I put it into the example file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay that's great, seems constant

clusterID := fmt.Sprintf("%s-%s-block-%s", cephBlockPoolRadosNamespace.Namespace, cephBlockPoolRadosNamespace.Spec.BlockPoolName, getRadosNamespaceName(cephBlockPoolRadosNamespace))

I'm not sure why we decided to have a hash, instead we can always use the full name. Or request a new field from csi for enrolling radosnamesapce

Copy link
Member

@BlaineEXE BlaineEXE May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parth-gr the line you are copying is missing the surrounding context.

func buildClusterID(cephBlockPoolRadosNamespace *cephv1.CephBlockPoolRadosNamespace) string {
clusterID := fmt.Sprintf("%s-%s-block-%s", cephBlockPoolRadosNamespace.Namespace, cephBlockPoolRadosNamespace.Spec.BlockPoolName, getRadosNamespaceName(cephBlockPoolRadosNamespace))
return k8sutil.Hash(clusterID)
}

Notice that the function here (buildClusterID()) returns Hash(clusterID). Thus, the ID is the hashed form of the name.

I believe Hash() was used because it ensures that the ID doesn't exceed the allowed number of characters for naming.

Extract the clusterID from the CephBlockPoolRadosNamespace CR:

```shell
$ kubectl -n rook-ceph get cephblockpoolradosnamespace -o yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we provide the direct cmd

$KUBECTL -n "$NAMESPACE" get cephblockpoolradosnamespace.ceph.rook.io/"$RADOS_NAMESPACE" -o jsonpath='{.status.info.clusterID}'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parth-gr wrote:

can we provide the direct cmd

$KUBECTL -n "$NAMESPACE" get cephblockpoolradosnamespace.ceph.rook.io/"$RADOS_NAMESPACE" -o jsonpath='{.status.info.clusterID}'

good idea! I will play with it a bit but it is currently unclear to me how/where the variables $KUBECTL, $NAMESPACE, etc are expected to be set.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can directly use kubectl and namespace as rook-ceph

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can directly use kubectl and namespace as rook-ceph

Makes sense, thanks! I will try an possibly update it this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parth-gr , I tried this:

kubectl  -n rook-ceph get cephblockpoolradosnamespaces.ceph.rook.io/namespace-a  -o jsonpath='{status.info.ClusterID}'

but only got garbage as output.

I also tried to find a command to use jsonpath to directly get the namespace name (in this case namespace-a, but no success yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets catch up and check, if it doesn't works

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parth-gr more details about the error I am facing:

$ kubectl  -n rook-ceph get cephblockpoolradosnamespaces.ceph.rook.io/namespace-a  -o jsonpath='{status.info.ClusterID}'

error: error executing jsonpath "{status.info.ClusterID}": Error executing template: unrecognized identifier status. Printing more information for debugging the template:
	template was:
		{status.info.ClusterID}
	object given to jsonpath engine was:
		map[string]interface {}{"apiVersion":"ceph.rook.io/v1", "kind":"CephBlockPoolRadosNamespace", "metadata":map[string]interface {}{"creationTimestamp":"2024-05-07T14:27:11Z", "finalizers":[]interface {}{"cephblockpoolradosnamespace.ceph.rook.io"}, "generation":1, "managedFields":[]interface {}{map[string]interface {}{"apiVersion":"ceph.rook.io/v1", "fieldsType":"FieldsV1", "fieldsV1":map[string]interface {}{"f:spec":map[string]interface {}{".":map[string]interface {}{}, "f:blockPoolName":map[string]interface {}{}}}, "manager":"kubectl-create", "operation":"Update", "time":"2024-05-07T14:27:11Z"}, map[string]interface {}{"apiVersion":"ceph.rook.io/v1", "fieldsType":"FieldsV1", "fieldsV1":map[string]interface {}{"f:metadata":map[string]interface {}{"f:finalizers":map[string]interface {}{".":map[string]interface {}{}, "v:\"cephblockpoolradosnamespace.ceph.rook.io\"":map[string]interface {}{}}}}, "manager":"rook", "operation":"Update", "time":"2024-05-07T14:27:11Z"}, map[string]interface {}{"apiVersion":"ceph.rook.io/v1", "fieldsType":"FieldsV1", "fieldsV1":map[string]interface {}{"f:status":map[string]interface {}{".":map[string]interface {}{}, "f:info":map[string]interface {}{".":map[string]interface {}{}, "f:clusterID":map[string]interface {}{}}, "f:phase":map[string]interface {}{}}}, "manager":"rook", "operation":"Update", "subresource":"status", "time":"2024-05-08T12:34:52Z"}}, "name":"namespace-a", "namespace":"rook-ceph", "resourceVersion":"28365", "uid":"fcae1125-b349-4260-b9da-d46f795128ce"}, "spec":map[string]interface {}{"blockPoolName":"replicapool"}, "status":map[string]interface {}{"info":map[string]interface {}{"clusterID":"80fc4f4bacc064be641633e6ed25ba7e"}, "phase":"Failure"}}
$

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be a small c not the capital one for clusterID

Copy link
Contributor Author

@obnoxxx obnoxxx May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parth-gr , I tried this:

kubectl  -n rook-ceph get cephblockpoolradosnamespaces.ceph.rook.io/namespace-a  -o jsonpath='{status.info.ClusterID}'

but only got garbage as output.

I also tried to find a command to use jsonpath to directly get the namespace name (in this case namespace-a, but no success yet.

@parth-gr now I managed to produce a working command and updated the doc accordingly :)

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: rook-ceph-block
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we name this something else as we already have this name for RBD storageclass created for blockpool

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Madhu-1 wrote:

can we name this something else as we already have this name for RBD storageclass created for blockpool

sure. what do you suggest? How about rook-ceph-block-rados-ns?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we name this something else as we already have this name for RBD storageclass created for blockpool

sure. what do you suggest? How about rook-ceph-block-rados-ns?

@Madhu-1 fwiw, I used this name in the doc now.

Extract the clusterID from the CephBlockPoolRadosNamespace CR:

```shell
$ kubectl -n rook-ceph get cephblockpoolradosnamespace -o yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be a small c not the capital one for clusterID

@@ -0,0 +1,64 @@
apiVersion: ceph.rook.io/v1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only concern of this new storageclass is that we need to take care of updating this as well if we add/remove any new fields for rbd specific option for rbd storageclass , this is kind of a maintenance burden we will get :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I share this concern. Though I'm on the fence about whether to keep the example. At the end of the day, though, I think the only truly unique thing here is rados namespace and storageclass's clusterID. I think the documentation is sufficiently clear enough that users shouldn't require an example manifest to understand, and maybe it would be best to remove this so it doesn't grow stale over time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BlaineEXE wrote:

I share this concern. Though I'm on the fence about whether to keep the example. At the end of the day, though, I think the only truly unique thing here is rados namespace and storageclass's clusterID. I think the documentation is sufficiently clear enough that users shouldn't require an example manifest to understand, and maybe it would be best to remove this so it doesn't grow stale over time.

Agreed. I can remove the example manifest from the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BlaineEXE example manifest is now removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think the full example manifests are worth the maintenance burden for common scenarios. But I'm fine skipping this example for now since it's less common.

@obnoxxx obnoxxx force-pushed the sc-radosnamespace branch 3 times, most recently from 31d26d8 to 08bc131 Compare May 17, 2024 15:40
```

In this example, replace `namespace-a` by the actual name of the radosnamespace
created before
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing part of the sentence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@travisn wrote:

missing part of the sentence?

sorry, what is missing or unclear here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no period at the end of what I presume to be a full sentence. I think that is the source of the confusion.

@obnoxxx obnoxxx force-pushed the sc-radosnamespace branch 2 times, most recently from 117cc48 to 614c7ea Compare May 17, 2024 15:58

Extract the clusterID from the CephBlockPoolRadosNamespace CR:

```shell
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shell is used for shell scripts. console is for console/terminal commands and output.

Also, there is no need to indent this one space from the left.

Suggested change
```shell
```console

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BlaineEXE wrote :

shell is used for shell scripts. console is for console/terminal commands and output.

Also, there is no need to indent this one space from the left.

done (manually.

@obnoxxx obnoxxx force-pushed the sc-radosnamespace branch 5 times, most recently from f04620a to d8accad Compare May 17, 2024 16:45
Comment on lines 69 to 71
Now set the `clusterID` retrieved from the previous step into the `clusterID` of the storage class.
Example:
Copy link
Member

@BlaineEXE BlaineEXE May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it your intent to have "Example:" on a new line? If so, by markdown syntax rules, there needs to be an empty line between "Now set..." and "Example:". Otherwise, "Example:" will appear at the end of the previous sentence when rendered.

I usually use VSCodes "markdown preview" feature when writing docs so I can be sure the basic rendering shows what I intend.

Copy link
Member

@travisn travisn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after commits are squashed!

closes: rook#13214

Co-authored-by: Travis Nielsen <tnielsen@redhat.com>
Co-authored-by: Blaine Gardner <b.blaine.gardner@gmail.com>
Signed-off-by: Michael Adam <obnox@samba.org>
@obnoxxx
Copy link
Contributor Author

obnoxxx commented May 18, 2024

@travisn wrote:

LGTM after commits are squashed!

done. squashed now.

@travisn travisn merged commit 3d62020 into rook:master May 20, 2024
19 checks passed
travisn added a commit that referenced this pull request May 20, 2024
docs: document how to have StorageClass consume Rados Namespace (backport #14173)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document how to create a storage class to consume a RADOS namespace
5 participants