Persistent storage in Kubernetes with Rook Ceph / CephFS - Operator
Ceph is a highly-reliable, scalable network storage platform which uses individual disks across participating nodes to provide fault-tolerant storage.
Rook provides an operator for Ceph, decomposing the 10-year-old, at-time-arcane, platform into cloud-native components, created declaratively, whose lifecycle is managed by an operator.
To start off with, we need to deploy the ceph operator into the cluster, after which, we'll be able to actually deploy our ceph cluster itself.
We need a namespace to deploy our HelmRelease and associated ConfigMaps into. Per the flux design, I create this example yaml in my flux repo at /bootstrap/namespaces/namespace-rook-ceph.yaml:
Now that the "global" elements of this deployment (just the HelmRepository in this case) have been defined, we do some "flux-ception", and go one layer deeper, adding another Kustomization, telling flux to deploy any YAMLs found in the repo at /rook-ceph. I create this example Kustomization in my flux repo:
apiVersion:kustomize.toolkit.fluxcd.io/v1beta2kind:Kustomizationmetadata:name:rook-cephnamespace:flux-systemspec:interval:30mpath:./rook-cephprune:true# remove any elements later removed from the above pathtimeout:10m# if not set, this defaults to interval duration, which is 1hsourceRef:kind:GitRepositoryname:flux-systemhealthChecks:-apiVersion:apiextensions.k8s.io/v1kind:CustomResourceDefinitionname:cephblockpools.ceph.rook.io
Fast-track your fluxing! 🚀
Is crafting all these YAMLs by hand too much of a PITA?
"Premix" is a git repository, which includes an ansible playbook to auto-create all the necessary files in your flux repository, for each chosen recipe!
Let the machines do the TOIL!
ConfigMap
Now we're into the app-specific YAMLs. First, we create a ConfigMap, containing the entire contents of the helm chart's values.yaml. Paste the values into a values.yaml key as illustrated below, indented 4 spaces (since they're "encapsulated" within the ConfigMap YAML). I create this example yaml in my flux repo:
apiVersion:v1kind:ConfigMapmetadata:name:rook-ceph-helm-chart-value-overridesnamespace:rook-cephdata:values.yaml:|-# <upstream values go here>
Values I change from the default are:
pspEnable:false
HelmRelease
Finally, having set the scene above, we define the HelmRelease which will actually deploy the rook-ceph operator into the cluster. I save this in my flux repo:
/rook-ceph/helmrelease-rook-ceph.yaml
apiVersion:helm.toolkit.fluxcd.io/v2beta1kind:HelmReleasemetadata:name:rook-cephnamespace:rook-cephspec:chart:spec:chart:rook-cephversion:1.9.xsourceRef:kind:HelmRepositoryname:rook-releasenamespace:flux-systeminterval:30mtimeout:10minstall:remediation:retries:3upgrade:remediation:retries:-1# keep trying to remediatecrds:CreateReplace# Upgrade CRDs on package updatereleaseName:rook-cephvaluesFrom:-kind:ConfigMapname:rook-ceph-helm-chart-value-overridesvaluesKey:values.yaml
Install Rook Ceph Operator!
Commit the changes to your flux repository, and either wait for the reconciliation interval, or force a reconcilliation using flux reconcile source git flux-system. You should see the kustomization appear...
What have we achieved? We're half-way to getting a ceph cluster, having deployed the operator which will manage the lifecycle of the ceph cluster we're about to create!
Summary
Created:
Rook ceph operator running and ready to deploy a cluster!
Did you receive excellent service? Want to compliment the chef? (..and support development of current and future recipes!) Sponsor me on Github / Ko-Fi / Patreon, or see the contribute page for more (free or paid) ways to say thank you! 👏
Employ your chef (engage) 🤝
Is this too much of a geeky PITA? Do you just want results, stat? I do this for a living - I'm a full-time Kubernetes contractor, providing consulting and engineering expertise to businesses needing short-term, short-notice support in the cloud-native space, including AWS/Azure/GKE, Kubernetes, CI/CD and automation.
Want to know now when this recipe gets updated, or when future recipes are added? Subscribe to the RSS feed, or leave your email address below, and we'll keep you updated.