K8s postgres 备份在 S3 复制期间失败

K8s postgres backup failed during S3 copy

我正在尝试使用 K8s cronjob 从 RDS 备份 postgres 数据库。 我已经为它创建了 cronjob,我的 EKS 集群和凭证在 Secrets 中。 当它尝试将备份复制到 AWS S3 桶 pod 失败并出现错误时: aws:错误:参数命令:无效的选择,有效的选择是: 我尝试了不同的选项,但它不起作用。

任何人都可以帮助解决这个问题。 这是简要信息: K8s 集群在 AWS EKS 上 Db 在 RDS 上 我正在为我的 cronjob 使用以下配置:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
 name: postgres-backup
 spec:
  schedule: "*/3 * * * *"
  jobTemplate:
    spec:
      backoffLimit: 0
      template:
        spec:
          initContainers:
            - name: dump
              image: postgres:12.1-alpine
              volumeMounts:
                - name: data
                  mountPath: /backup
              args:
                - pg_dump
                - "-Fc"
                - "-f"
                - "/backup/redash-postgres.pgdump"
                - "-Z"
                - "9"
                - "-v"
                - "-h"
                - "postgress.123456789.us-east-2.rds.amazonaws.com"
                - "-U"
                - "postgress"
                - "-d"
                - "postgress"
              env:
                - name: PGPASSWORD
                  valueFrom:
                    secretKeyRef:
                      # Retrieve postgres password from a secret 
                      name: postgres
                      key: POSTGRES_PASSWORD
          containers:
            - name: save
              image: amazon/aws-cli
              volumeMounts:
                - name: data
                  mountPath: /backup
              args:
                - aws
                - "--version"
              envFrom:
                - secretRef:
                    # Must contain AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION
                    name: s3-backup-credentials
          restartPolicy: Never
          volumes:
            - name: data
              emptyDir: {}

试试这个:

...
containers:
- name: save
  image: amazon/aws-cli
  ...
  args:
  - "--version"  # <-- the image entrypoint already call "aws", you only need to specify the arguments here.
...