Tutorial: Install and Configure OpenEBS on Amazon Elastic Kubernetes Service

In a previous article, I introduced the architecture of the OpenEBS, an open source container attached storage package for Kubernetes. In this part, we will install and configure OpenEBS on the Amazon Elastic Kubernetes Service (EKS), with a focus on the cStor Storage Engine.
By the end of this tutorial, you will have a storage pool that can be used for deploying highly available stateful workloads on Kubernetes.
Launching an Amazon EKS Cluster
The first step is to provision an Amazon EKS cluster with three nodes. Download and configure eksctl, the nifty tool to manage EKS clusters.
1 2 3 4 5 6 7 8 9 10 11 |
eksctl create cluster \ --name openebs-demo \ --version 1.14 \ --nodegroup-name ng-workers \ --node-type t3.medium \ --nodes 3 \ --nodes-min 3 \ --nodes-max 6 \ --node-ami auto \ --node-ami-family Ubuntu1804 \ --set-kubeconfig-context=true |
1 |
kubectl get nodes |
Attaching Amazon EBS Volumes to Worker Nodes
OpenEBS cStor storage engine creates a pool from attached block storage devices.
If you have a large cluster, you can label a subset of nodes for running stateful workloads and configure OpenEBS on the nodes.
Let’s create and attach an EBS volume to each node of the cluster. Before that, we need to get the Amazon EC2 instance id and availability zone of the worker nodes.
1 2 3 |
aws ec2 describe-instances \ --query 'Reservations[].Instances[].[Tags[?Key==`Name`].Value[] | [0], InstanceId, Placement.AvailabilityZone]' \ --output text |
1 2 3 |
aws ec2 create-volume \ --size 20 \ --availability-zone ap-south-1a \ |
Note the volume id of the EBS device. We need it for the next step where we attach the volume to an instance from the same availability zone.
1 2 3 4 |
aws ec2 attach-volume \ --volume-id vol-035af55d5b38f441c \ --instance-id i-09f1e8c7fae5c7c24 \ --device /dev/sdf |
Repeat these steps for the remaining two nodes of the cluster. Make sure that the availability zone is the same for the EBS volume and EC2 instance (worker node).
By the end of this step, we have three EBS volumes of 20GiB each attached to the worker nodes.
Verify that the volumes are attached to the nodes with the below command:
1 2 3 |
aws ec2 describe-instances \ --query 'Reservations[*].Instances[*].[Tags[?Key==`Name`].Value,InstanceId,BlockDeviceMappings[*].Ebs.VolumeId]' \ --output text |
The first volume is the root while the second volume is the disk that we attached.
Note: The steps involved in creating and attaching volumes to worker nodes can be easily automated through a BASH script or an AWS CloudFormation template.
Installing OpenEBS
We will use the OpenEBS operator to install it. This will create a dedicated namespace and deploys OpenEBS.
1 |
kubectl apply -f https://openebs.github.io/charts/openebs-operator.yaml |
Wait for the Pods to become ready before proceeding to the next step.
1 |
kubectl get pod -n openebs |
The next step is to initialize Ubuntu to ensure that iSCSI service is up and running.
1 |
kubectl apply -f https://openebs.github.io/charts/openebs-ubuntu-setup.yaml |
The last line confirms that iSCSI is initialized.
Configuring cStor Storage Engine on OpenEBS
With OpenEBS in place, we will now configure a storage engine based on cStor which will create a storage pool from the attached EBS volumes.
Let’s start by getting the block device id associated with the EBS volumes.
1 |
kubectl get blockdevice -n openebs |
From these raw devices, we will now create a cStor storage pool. Add the list of block devices to the below YAML file and apply it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
apiVersion: openebs.io/v1alpha1 kind: StoragePoolClaim metadata: name: cstor-disk-pool annotations: cas.openebs.io/config: | - name: PoolResourceRequests value: |- memory: 2Gi - name: PoolResourceLimits value: |- memory: 4Gi spec: name: cstor-disk-pool type: disk poolSpec: poolType: striped blockDevices: blockDeviceList: - blockdevice-371f31f8dad830daa7fc90123779fc5d - blockdevice-5f112c01babaa05438b796f545613cd1 - blockdevice-aadb62b32b1be2d1113698ceeab8a6ee |
This step can be easily automated through a BASH script by reading the output of the kubectl command listing the block devices and adding them to the YAML file.
1 |
kubectl apply -f cstor-pool-config.yaml |
Let’s check the storage pool claim.
1 |
kubectl get spc |
Finally, we will verify that the cStor storage pool is created and ready for use.
1 |
kubectl get csp |
Congratulations! You are now ready to deploy stateful workloads backed by OpenEBS.
In the next part of this tutorial, I will walk you through the steps involved in deploying a highly available instance of PostgreSQL backed by OpenEBS cStor storage engine. Stay tuned!
Janakiram MSV’s Webinar series, “Machine Intelligence and Modern Infrastructure (MI2)” offers informative and insightful sessions covering cutting-edge technologies. Sign up for the upcoming MI2 webinar at http://mi2.live.
Amazon Web Services is a sponsor of The New Stack.
Feature image via Pixabay.