<p>I have an S3 bucket with some sql scripts and some backup files using mysqldump.</p>

<p>I also have a .yaml file that deploys a fresh mariadb image.</p>

<p>As I'm not very experienced with kubernetes yet, if I want to restore one of those backup files into the pod, I need to bash into it, run aws cli, insert my credentials, then sync the bucket locally and run mysql &lt; backup.sql</p>

<p>This, obviously, destroys the concept of full automated deployment.</p>

<p>So, the question is... how can I securely make this pod immediately configured to access S3?</p>

<p>I think you should consider mounting S3 bucket inside the pod.</p>

<p>This can be achieved by for example <a href="https://github.com/s3fs-fuse/s3fs-fuse" rel="noreferrer">s3fs-fuse</a>.</p>

<p>There are two nice articled about <a href="https://devops-bordeaux.net/blog/mounting-s3-bucket-in-kubernetes-pod/" rel="noreferrer">Mounting a S3 bucket inside a Kubernetes pod</a> and <a href="https://icicimov.github.io/blog/virtualization/Kubernetes-shared-storage-with-S3-backend/" rel="noreferrer">Kubernetes shared storage with S3 backend</a>, I do recommend reading both to understand how this works.</p>

<p>You basically have to build your own image from Dockerfile and supply necessary S3 bucket info and <a href="https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html" rel="noreferrer">AWS security credentials</a>.</p>

<p>Once you have the storage mounted you will be able to call scripts from it in a following way:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: test-world
spec:  # specification of the pod’s contents
  restartPolicy: Never
  containers:
  - name: hello
    image: debian
    command: ["/bin/sh","-c"]
    args: ["command one; command two &amp;&amp; command three"]
</code></pre>
