![]() |
VOOZH | about |
We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.
Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.
Follow TNS on your favorite social media networks.
Become a TNS follower on LinkedIn.
Check out the latest featured and trending stories while you wait for your first TNS newsletter.
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.
The first step is to provision an Amazon EKS cluster with three nodes. Download and configure eksctl, the nifty tool to manage EKS clusters.
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
kubectl get 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.
aws ec2 describe-instances \ --query 'Reservations[].Instances[].[Tags[?Key==`Name`].Value[] | [0], InstanceId, Placement.AvailabilityZone]' \ --output text
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.
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:
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.
We will use the OpenEBS operator to install it. This will create a dedicated namespace and deploys OpenEBS.
kubectl apply -f https://openebs.github.io/charts/openebs-operator.yaml
Wait for the Pods to become ready before proceeding to the next step.
kubectl get pod -n openebs
The next step is to initialize Ubuntu to ensure that iSCSI service is up and running.
kubectl apply -f https://openebs.github.io/charts/openebs-ubuntu-setup.yaml
The last line confirms that iSCSI is initialized.
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.
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.
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.
kubectl apply -f cstor-pool-config.yaml
Let’s check the storage pool claim.
kubectl get spc
Finally, we will verify that the cStor storage pool is created and ready for use.
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.