How to copy s3 bucket files in to the Kubernetes running pods?

4/6/2020

I have multiple files in s3 bucket which I need to copy to one of the running Kubernetes pods under /tmp path . Need any reliable command or try and tested way to do the same.

Let's say my bucket name "learning" and pod name is "test-5c7cd9c-l6qng"

-- me25
amazon-eks
amazon-web-services
kubernetes

1 Answer

4/6/2020

AWS CLI commands "aws s3api get-object" or "aws s3 cp" can be used to copy the data onto the Pod from S3. To make these calls AWS Access Keys are required. These keys provide the authentication to call the S3 service. "aws configure" command can be used to configure the Access Keys in the Pod.

Coming to K8S, an Init Container can be used to execute the above command before the actual application container starts. Instead of having the Access Keys directly written into the Pod which is not really safe, K8S Secrets feature can be used to pass/inject the Access Keys to the Pods.

FYI ... the download can be done programmatically by using the AWS SDK and the S3Client Interface for Java.

-- Praveen Sripati
Source: StackOverflow