From f3eb9ce12f4b157ff404ee2dc3d867423c2d4dc2 Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Fri, 9 Apr 2021 12:51:38 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=80=20Review=20+=20improve=20OpenEBS?= =?UTF-8?q?=20content?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- k8s/openebs-pod.yaml | 7 +- slides/k8s/openebs.md | 514 ++++++++++++++++++++++++++++++++------ slides/kube-fullday.yml | 1 + slides/kube-selfpaced.yml | 1 + slides/kube-twodays.yml | 1 + 5 files changed, 444 insertions(+), 80 deletions(-) diff --git a/k8s/openebs-pod.yaml b/k8s/openebs-pod.yaml index 1a5cc6de..9a38a86f 100644 --- a/k8s/openebs-pod.yaml +++ b/k8s/openebs-pod.yaml @@ -13,7 +13,12 @@ spec: command: - sh - -c - - 'while true; do echo "`date` [`hostname`] Kubernetes is better with PVs." >> /mnt/storage/greet.txt; sleep $(($RANDOM % 5 + 20)); done' + - | + while true; do + echo "$(date) [$(hostname)] Kubernetes is better with PVs." >> /mnt/storage/greet.txt + sleep $(($RANDOM % 5 + 20)) + done volumeMounts: - mountPath: /mnt/storage name: storage + diff --git a/slides/k8s/openebs.md b/slides/k8s/openebs.md index 7193e2e4..942b398e 100644 --- a/slides/k8s/openebs.md +++ b/slides/k8s/openebs.md @@ -1,111 +1,172 @@ # OpenEBS - - OpenEBS is a popular open-source storage solution for Kubernetes + - [OpenEBS] is a popular open-source storage solution for Kubernetes - - Think "Container Attached Storage" + - Uses the concept of "Container Attached Storage" + + (1 volume = 1 dedicated controller pod + a set of replica pods) - Supports a wide range of storage engines: + + - LocalPV: local volumes (hostpath or device), no replication + - Jiva: for lighter workloads with basic cloning/snapshotting - - cStor: based on iSCSI + - cStor: more powerful engine that also supports resizing, RAID, disk pools ... - - Mayastor: light-weight abstraction layer with nVME and vhost-user support + - [Mayastor]: newer, even more powerful engine with NVMe and vhost-user support - - OpenEBS Local PV - for lowest latency local volumes +[OpenEBS]: https://openebs.io/ + +[Mayastor]: https://github.com/openebs/MayaStor#mayastor --- -## Installing OpenEBS with Helm -OpenEBS control plane runs as a set of containers on Kubernetes worker nodes. -It can be installed with helm: +class: extra-details -.exercise[ +## What are all these storage engines? - - Install OpenEBS -```bash - kubectl create ns openebs - helm repo add openebs https://openebs.github.io/charts - helm repo update - helm install openebs openebs/openebs --namespace openebs -``` -] +- LocalPV is great if we want good performance, no replication, easy setup + + (it is similar to the Rancher local path provisioner) + +- Jiva is great if we want replication and easy setup + + (data is stored in containers' filesystems) + +- cStor is more powerful and flexible, but requires more extensive setup + +- Mayastor is designed to achieve extreme performance levels + + (with the right hardware and disks) + +- The OpenEBS documentation has a [good comparison of engines] to help us pick + +[good comparison of engines]: https://docs.openebs.io/docs/next/casengines.html#cstor-vs-jiva-vs-localpv-features-comparison --- ## Installing OpenEBS with Helm -Let's check the running OpenEBS components: +- The OpenEBS control plane can be installed with Helm + +- It will run as a set of containers on Kubernetes worker nodes .exercise[ -```bash - kubectl get pod -n openebs -``` -] - -Let's check the new StorageClasses: - -.exercise[ - -```bash - kubectl get sc -``` + - Install OpenEBS: + ```bash + helm upgrade --install openebs openebs \ + --repo https://openebs.github.io/charts \ + --namespace openebs --create-namespace + ``` ] --- -## Default Storage Classes +## Checking what was installed -For a simple testing of OpenEBS, you can use the below default storage classes: +- Wait a little bit ... - - **openebs-jiva-default** for provisioning Jiva Volume (this uses default pool which means the data replicas are created in the /mnt/openebs_disk directory of the Jiva replica pod) +.exercise[ - - **openebs-hostpath** for provisioning Local PV on hostpath. +- Look at the pods in the `openebs` namespace: + ```bash + kubectl get pods --namespace openebs + ``` - - **openebs-device** for provisioning Local PV on device. +- And the StorageClasses that were created: + ```bash + kubectl get sc + ``` -For using real disks, you have to create *cStorPools* or *Jiva* pools or *OpenEBS Local PV* based on the requirement and then create corresponding StorageClasses or use default StorageClasses to use them. +] --- -## Selecting an OpenEBS Storage Engine +## The default StorageClasses -Storage engine is chosen by specifying the annotation `openebs.io/cas-type` in the StorageClass specification. StorageClass defines the provisioner details. Separate provisioners are specified for each CAS engine. +- OpenEBS typically creates three default StorageClasses -Example for Local PV host path: +- `openebs-jiva-default` provisions 3 replicated Jiva pods per volume + + - data is stored in `/openebs` in the replica pods + - `/openebs` is a localpath volume mapped to `/var/openebs/pvc-...` on the node + +- `openebs-hostpath` uses LocalPV with local directories + + - volumes are hostpath volumes created in `/var/openebs/local` on each node + +- `openebs-device` uses LocalPV with local block devices + + - requires available disks and/or a bit of extra configuration + - the default configuration filters out loop, LVM, MD devices + +--- + +## When do we need custom StorageClasses? + +- To store LocalPV hostpath volumes on a different path on the host + +- To change the number of replicated Jiva pods + +- To use a different Jiva pool + + (i.e. a different path on the host to store the Jiva volumes) + +- To create a cStor pool + +- ... + +--- + +class: extra-details + +## Defining a custom StorageClass + +Example for a LocalPV hostpath class using an extra mount on `/mnt/vol001`: ```yaml apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: - name: localpv-hostpath-sc + name: localpv-hostpath-mntvol001 annotations: openebs.io/cas-type: local cas.openebs.io/config: | - name: BasePath - value: "/var/openebs/local" + value: "/mnt/vol001" - name: StorageType value: "hostpath" provisioner: openebs.io/local ``` +- `provisioner` needs to be set accordingly +- Storage engine is chosen by specifying the annotation `openebs.io/cas-type` +- Storage engine configuration is set with the annotation `cas.openebs.io/config` + --- -## Exploring the host path StorageClass +## Checking the default hostpath StorageClass + +- Let's inspect the StorageClass that OpenEBS created for us .exercise[ - - Let's look at the OpenEBS Local PV host path StorageClass - ```bash - kubectl get sc openebs-hostpath -oyaml - ``` + +- Let's look at the OpenEBS LocalPV hostpath StorageClass: + ```bash + kubectl get storageclass openebs-hostpath -o yaml + ``` ] --- -## Create a host path PVC +## Create a host path PVC + +- Let's create a Persistent Volume Claim using an explicit StorageClass -Let's create a Persistent Volume Claim .exercise[ + ```bash kubectl apply -f - <