Created
August 22, 2022 14:31
-
-
Save ilyesAj/ed1cdb588597252f48e4fceeb2085a0f to your computer and use it in GitHub Desktop.
aws cp job kubernetes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: s3-copy | |
--- | |
apiVersion: batch/v1 | |
kind: Job | |
metadata: | |
name: s3-bucket-a-sync | |
namespace: s3-copy | |
spec: | |
backoffLimit: 0 | |
template: | |
metadata: | |
name: s3-sync | |
spec: | |
containers: | |
- image: amazon/aws-cli | |
name: s3-sync | |
command: ["/bin/sh"] | |
args: | |
- -c | |
- "/scripts/run.sh" | |
env: | |
- name: AWS_SECRET_ACCESS_KEY | |
valueFrom: | |
secretKeyRef: | |
name: aws-s3-sync-credentials | |
key: AWS_SECRET_ACCESS_KEY | |
- name: AWS_ACCESS_KEY_ID | |
valueFrom: | |
secretKeyRef: | |
name: aws-s3-sync-credentials | |
key: AWS_ACCESS_KEY_ID | |
- name: SOURCE_BUCKET | |
value: bucket-a | |
- name: DESTINATION_BUCKET | |
value: bucket-b | |
- name: SOURCE_REGION | |
value: eu-west-1 | |
- name: DESTINATION_REGION | |
value: eu-west-3 | |
volumeMounts: | |
- name: script | |
mountPath: /scripts | |
resources: | |
requests: | |
cpu: 300m | |
memory: 200Mi | |
limits: | |
cpu: 500m | |
memory: 400Mi | |
restartPolicy: Never | |
volumes: | |
- name: script | |
configMap: | |
name: s3-sync | |
defaultMode: 0777 | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: s3-sync | |
namespace: s3-copy | |
labels: | |
app: s3-sync | |
data: | |
run.sh: | | |
#!/bin/sh | |
echo "[DEBUG] BEGIN COPY" | |
echo "[DEBUG] aws s3 sync s3://$SOURCE_BUCKET s3://$DESTINATION_BUCKET --source-region $SOURCE_REGION --region $DESTINATION_REGION --no-progress " | |
aws s3 sync s3://$SOURCE_BUCKET s3://$DESTINATION_BUCKET --source-region $SOURCE_REGION --region $DESTINATION_REGION --no-progress | |
echo "[DEBUG] COPY FINISH" | |
--- | |
apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: aws-s3-sync-credentials | |
namespace: s3-copy | |
type: Opaque | |
stringData: | |
AWS_ACCESS_KEY_ID: XX | |
AWS_SECRET_ACCESS_KEY: XX | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
full implementation of this code here