Exploring the Options to Persist State

If we want to persist state that will survive even server failures, we have two options we can choose.

Local Storage

We could, for example, store data locally and replicate it to multiple servers. That way, a container could use local storage knowing that the files are available on all the servers. Such a setup would be too complicated if we’d like to implement the process ourselves. Truth be told, we could use one of the volume drivers for that. However, we’ll opt for a more commonly used method to persist the state across failures. We’ll use external storage.

External Storage

Since we are running our cluster in AWS, we can choose between S3, Elastic File System (EFS), and Elastic Block Store.

S3 is meant to be accessed through its API and is not suitable as a local disk replacement. That leaves us with EFS and EBS.

Elastic File System (EFS)

Elastic File System (EFS), has a distinct advantage that it can be mounted to multiple EC2 instances spread across multiple availability zones. It is closest we can get to fault-tolerant storage. Even if a whole zone (datacenter) fails, we’ll still be able to use EFS in the rest of the zones used by our cluster. However, that comes at a cost. EFS introduces a performance penalty. It is, after all, a network file system (NFS), and that entails higher latency.

Elastic Block Store (EBS)

Elastic Block Store (EBS) is the fastest storage we can use in AWS. Its data access latency is very low thus making it the best choice when performance is the primary concern. The downside is availability. It doesn’t work in multiple availability zones. Failure of one will mean downtime, at least until the zone is restored to its operational state.

Our Choice

We’ll choose EBS for our storage needs. Jenkins depends heavily on IO, and we need data access to be as fast as possible. However, there is another reason for such a choice. EBS is fully supported by Kubernetes. EFS will come but, at the time of this writing, it is still in the experimental stage. As a bonus advantage, EBS is much cheaper than EFS.

Given the requirements and what Kubernetes offers, the choice is obvious. We’ll use EBS, even though we might run into trouble if the availability zone where our Jenkins will run goes down. In such a case, we’d need to migrate EBS volume to a healthy zone. There’s no such thing as a perfect solution.

We are jumping ahead of ourselves. We’ll leave Kubernetes aside for a while and concentrate on creating an EBS volume.

Creating an EBS Volume

Each EBS volume is tied to an availability zone. Unlike EFS, Elastic Block Store cannot span multiple zones. So, the first thing we need to do is to find out which are the zones worker nodes are running in.

Looking into the Description

We can get the above information by describing the EC2 instances belonging to the security group nodes.devops23.k8s.local.

Get hands-on with 1200+ tech skills courses.