[Infrastructure as Code (IaC) Pulumi] Use Pulumi kubernetes (K8S) Helm Chart to deploy Rook Ceph to provide distributed storage
Rook Storage Operators for Kubernetes
Rook turns distributed storage systems into self-managing, self-scaling, self-healing storage services. It automates the tasks of a storage administrator: deployment, bootstrapping, configuration, provisioning, scaling, upgrading, migration, disaster recovery, monitoring, and resource management.
This article is about how to use Pulumi, kubernetes (K8S) provider, Helm Chart and TypeScript SDK to deploy Rook Ceph within Kubernetes (K8S).
Prerequisites
-
Kubernetes (K8s) is an open-source system for automating deployment, scaling, and management of containerized applications.
See Getting started | Kubernetes - https://kubernetes.io/docs/setup/ to leanr more.
-
Pulumi - Modern Infrastructure as Code - https://www.pulumi.com/
Pulumi is a modern infrastructure-as-code platform that allows you to use common programming languages, tools, and frameworks, to provision, update, and manage cloud infrastructure resources.
Install the Pulumi - https://www.pulumi.com/ CLI.
1
2Mac OS X
brew install pulumiSee Download and Install | Pulumi - https://www.pulumi.com/docs/get-started/install/ to learn more about others OS.
-
Node.js - https://nodejs.org/en/
Node.js® is a JavaScript runtime built on Chrome’s V8 JavaScript engine.
Install Node.js - https://nodejs.org/en/ CLI.
1
2Mac OS X
brew install nodeSee Node.js - https://nodejs.org/en/ to learn more about others OS.
-
LVM2
Some Linux distributions do not ship with the lvm2 package. This package is required on all storage nodes in your k8s cluster. Please install it using your Linux distribution’s package manager; for example:
1
2
3
4
5Centos
sudo yum install -y lvm2
Ubuntu
sudo apt-get install -y lvm2
Usage
Pulumi New
Create the workspace directory.
1 | mkdir -p col-example-pulumi-typescript-rook-ceph |
Pulumi login into local file system.
1 | pulumi login file://. |
Pulumi new a project with kubernetes-typescript SDK.
1 | pulumi new kubernetes-typescript |
The above command will create some files within the current directory.
1 | tree . -L 1 |
Install js-yaml
package to load and parse yaml file.
1 | npm i js-yaml |
Pulumi Configuration
Configure Kubernetes
By default, Pulumi will look for a kubeconfig file in the following locations, just like kubectl:
-
The environment variable:
$KUBECONFIG
, -
Or in current user’s default kubeconfig directory:
~/.kube/config
If the kubeconfig file is not in either of these locations, Pulumi will not find it, and it will fail to authenticate against the cluster. Set one of these locations to a valid kubeconfig file, if you have not done so already.
Ceph Operator Helm Chart
The Ceph Operator helm chart will install the basic components necessary to create a storage platform for your Kubernetes cluster.
Ceph Operator Helm Chart | Ceph Docs - https://rook.io/docs/rook/v1.7/helm-operator.html
Configure Values.yaml
Edit values.rook-ceph.yaml and replace content within {{ }}
.
1 | # values.rook-ceph.yaml |
See and modify main.ts file.
1 | // main.ts |
Pulumi Up
Run pulumi up to create the namespace and pods.
1 | pulumi up |
See pods about rook-ceph.
1 | kubectl get pods -n rook-ceph |
Ceph Cluster Helm Chart
Creates Rook resources to configure a Ceph cluster using the Helm package manager. This chart is a simple packaging of templates that will optionally create Rook resources such as:
-
CephCluster, CephFilesystem, and CephObjectStore CRs
-
Storage classes to expose Ceph RBD volumes, CephFS volumes, and RGW buckets
-
Ingress for external access to the dashboard
-
Toolbox
Ceph Docs - https://rook.io/docs/rook/v1.7/helm-ceph-cluster.html
Edit values.rook-ceph-cluster…yaml and replace content within {{ }}
.
1 | # rook-ceph-cluster.yaml |
See and append the follow code into main.ts file.
1 | // main.ts |
Pulumi Up
Run pulumi up to create the namespace and pods.
1 | pulumi up |
See pods about rook-ceph.
1 | kubectl get pods -n rook-ceph |
Then, you can visit Ceph Dashboard with http://<Your Ceph Dashboard Host>
.
Initialize RDB Pool
Remember to initialize before use RDB Pool.
-
Execute
rbd pool init <pool_name>
command from toolbox or ceph-csi pods(similar to this). -
Restart the csi-rbdplugin-provisioner-xxx pods.
1
kubectl -n rook-ceph delete pods -l app=csi-rbdplugin-provisioner
Test Ceph Block Storage Class
Create or edit a pvc.yaml
manifest file.
1 | # pvc.yaml |
Run command to run and check.
1 | kubectl apply -f pvc.yaml |
Pulumi Destroy
Destroy all resources created by Pulumi.
1 | pulumi destroy |
FAQs
cephobjectstores.ceph.rook.io “ceph-objectstore” already exists or cephfilesystems.ceph.rook.io “ceph-filesystem” already exists when run pulumi up
1 | pulumi up |
Delete previouse CRD resources related to ceph.rook.io
.
1 | kubectl patch -p '{"metadata":{"finalizers":[]}}' --type=merge -n rook-ceph CephObjectStore ceph-objectstore |
Delete CRD related to ceph.rook.io
.
1 | kubectl patch -p '{"metadata":{"finalizers":[]}}' --type=merge crd cephblockpools.ceph.rook.io |
Then, run pulumi up
.
failed to read label for lvm2
Some Linux distributions do not ship with the lvm2 package. This package is required on all storage nodes in your k8s cluster. Please install it using your Linux distribution’s package manager; for example:
1 | Centos |
PersistentVolumeClaim or PersistentVolume Creation hangs and fails, failed to provision volume with StorageClass “ceph-block”: an operation with the given Volume ID pvc-ID already exists
Particularly, ceph csi v3.4.0 (built with ceph pacific base image) and rook v1.7.1(which ships with cephcsi v3.4.0 as default) is affected by this issue.
See New BlockPool / SC + Parallel RBD Volume Creation hangs and fails · Issue #8696 · rook/rook - https://github.com/rook/rook/issues/8696 to learn more.
-
Execute
rbd pool init <pool_name>
command from toolbox or ceph-csi pods(similar to this). -
Restart the csi-rbdplugin-provisioner-xxx pods.
1
kubectl -n rook-ceph delete pods -l app=csi-rbdplugin-provisioner
References
[1] Ceph Operator Helm Chart | Ceph Docs - https://rook.io/docs/rook/v1.7/helm-operator.html
[2] Ceph Docs - https://rook.io/docs/rook/v1.7/helm-ceph-cluster.html