<pre><code>
**Yaml for kubernetes that is first used to create raft backup and then upload into gas bucket**

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  labels:
    app.kubernetes.io/component: raft-backup
    numenapp: raft-backup
  name: raft-backup
  namespace: raft-backup
spec:
  concurrencyPolicy: Forbid
  failedJobsHistoryLimit: 3
  jobTemplate:
    spec:
      template:
        metadata:
          annotations:
            vault.security.banzaicloud.io/vault-addr: https://vault.vault-internal.net:8200
          labels:
            app.kubernetes.io/component: raft-backup
        spec:
          containers:
          - args:
              - |
                SA_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token);
                export VAULT_TOKEN=$(vault write -field=token auth/kubernetes/login jwt=$SA_TOKEN role=raft-backup);
                vault operator raft snapshot save /share/vault-raft.snap;
                echo &quot;snapshot is success&quot;
            command: [&quot;/bin/sh&quot;, &quot;-c&quot;]
            env:
            - name: VAULT_ADDR
              value: https://vault.vault-internl.net:8200
            image: vault:1.10.9
            imagePullPolicy: Always
            name: snapshot
            volumeMounts:
            - mountPath: /share
              name: share
          - args:
            - -ec
            - sleep 500
            - &quot;until [ -f /share/vault-raft.snap ]; do sleep 5; done;\ngsutil cp /share/vault-raft.snap\
              \ gs://raft-backup/vault_raft_$(date +\&quot;\
              %Y%m%d_%H%M%S\&quot;).snap;\n&quot;
            command:
            - /bin/sh
            image: gcr.io/google.com/cloudsdktool/google-cloud-cli:latest
            imagePullPolicy: IfNotPresent
            name: upload
            securityContext:
              allowPrivilegeEscalation: false
            volumeMounts:
            - mountPath: /share
              name: share
          restartPolicy: OnFailure
          securityContext:
            fsGroup: 1000
            runAsGroup: 1000
            runAsUser: 1000
          serviceAccountName: raft-backup
          volumes:
          - emptyDir: {}
            name: share
  schedule: '*/3 * * * *'
  startingDeadlineSeconds: 60
  successfulJobsHistoryLimit: 3
  suspend: false
</code></pre>
<p><strong>Error while running gsutil command inside the upload pod</strong></p>
<p>$ gsutil
Traceback (most recent call last):
File &quot;/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/configurations/named_configs.py&quot;, line 172, in ActiveConfig
return ActiveConfig(force_create=True)
File &quot;/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/configurations/named_configs.py&quot;, line 492, in ActiveConfig
config_name = _CreateDefaultConfig(force_create)
File &quot;/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/configurations/named_configs.py&quot;, line 640, in _CreateDefaultConfig
file_utils.MakeDir(paths.named_config_directory)
File &quot;/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/util/files.py&quot;, line 125, in MakeDir
os.makedirs(path, mode=mode)
File &quot;/usr/bin/../lib/google-cloud-sdk/platform/bundledpythonunix/lib/python3.9/os.py&quot;, line 215, in makedirs
makedirs(head, exist_ok=exist_ok)
File &quot;/usr/bin/../lib/google-cloud-sdk/platform/bundledpythonunix/lib/python3.9/os.py&quot;, line 215, in makedirs
makedirs(head, exist_ok=exist_ok)
File &quot;/usr/bin/../lib/google-cloud-sdk/platform/bundledpythonunix/lib/python3.9/os.py&quot;, line 225, in makedirs
mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/home/cloudsdk/.config'
$ command terminated with exit code 137</p>
<pre><code></code></pre>

kapil dev
<p><code>OSError: [Errno 30] Read-only file system: '/home/cloudsdk/.config' $ command terminated with exit code 137</code></p>
<p>It seems you don't give enought permission in your cronJob.</p>
<p>Try to change :</p>
<pre><code>securityContext:
  fsGroup: 1000
  runAsGroup: 1000
  runAsUser: 1000
</code></pre>
<p>by :</p>
<pre><code>securityContext:
  privileged: true
</code></pre>
<p>Tell me if it works or not and we can discuss about it.</p>
<p>Edit for complete response :</p>
<p>Use this <code>apiVersion: batch/v1</code> instead of <code>apiVersion: batch/v1beta1</code></p>
