Deploying the Stateful Services

Next, launch a set of two pods with the following commands.

cd ~/environment/efs
wget https://eksworkshop.com/beginner/190_efs/efs.files/efs-writer.yaml
wget https://eksworkshop.com/beginner/190_efs/efs.files/efs-reader.yaml
kubectl apply -f efs-writer.yaml
kubectl apply -f efs-reader.yaml

Each one of these pods references the PVC resource named efs-storage-claim created earlier and mounts the backing PV to a local directory named /shared.

Verify that the efs-writer pod is successfully writing data to the shared persistent volume.

kubectl exec -it efs-writer -n storage -- tail /shared/out.txt

The output from the above command will look as follows:


efs-writer.storage - Thu Mar 5 20:52:19 UTC 2020
efs-writer.storage - Thu Mar 5 20:52:24 UTC 2020
efs-writer.storage - Thu Mar 5 20:52:29 UTC 2020
efs-writer.storage - Thu Mar 5 20:52:34 UTC 2020

Verify that the efs-reader pod is able to successfully read the same data from the shared persistent volume.

kubectl exec -it efs-reader -n storage -- tail /shared/out.txt

The output from the above command will be the same as the one from the efs-writer pod.


efs-writer.storage - Thu Mar 5 20:52:19 UTC 2020
efs-writer.storage - Thu Mar 5 20:52:24 UTC 2020
efs-writer.storage - Thu Mar 5 20:52:29 UTC 2020
efs-writer.storage - Thu Mar 5 20:52:34 UTC 2020
efs-writer.storage - Thu Mar 5 20:52:39 UTC 2020
efs-writer.storage - Thu Mar 5 20:52:44 UTC 2020