Using EBS volumes for persistent storage

As an alternative to creating PVCs and dynamically creating volumes, you can also manually create a volume and attach it to your application directly as a persistent volume by carrying out the following steps:

  1. Create an EBS volume in the same zone as your worker nodes by using the following aws CLI:
$ aws ec2 create-volume --availability-zone=us-west-2a --size=10 --volume-type=gp2
  1. Deploy a test application using the EBS volumeID you created in Step 1:
$ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: test-server
spec:
containers:
- image: gcr.io/google_containers/test-webserver
name: test-container
volumeMounts:
- mountPath: /test-ebs
name: test-volume
volumes:
- name: test-volume
awsElasticBlockStore:
volumeID: vol-02f4bc9b938604f72
fsType: ext4
EOF
  1. Verify that your pod is in the Running state:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
test-server 1/1 Running 0 4m32s

The main advantage of manually created persistent volumes (PVs) is that PVs are not attached to a single cluster or namespace. They exist as a resource on your AWS cloud account and they can even be shared across clusters where dynamically created PVCs only exist in the namespace created and can only be used by a pod within that same namespace.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.93.64