Can we control the restartPolicy in deploy.contain...
# 🌱|help-and-getting-started
w
I want to simulate Kubernetes job behavior using
Deploy.Container
instead of
Deploy.Kubernetes
to utilize
$merge: ${var}
, which isn't supported by
Deploy.Kubernetes
. The only issue is ensuring the pod exits successfully without restarting. Is there a way to control the
restartPolicy
to set it to
OnFailure
, or any alternative solutions? I couldn’t find anything in the garden.io docs.
I think I've found a solution! However, I can't use sync mode with this solution.
Copy code
---
kind: Build
name: sync-images-job
type: container
dependencies:
  - deploy.datastore
source:
  path: ../../
include:
  - "go.mod"
  - "go.sum"
  - "pkg"
  - "jobs/sync-images"
  - "services/datastore/pkg/models"
  - "services/datastore/pkg/views"
spec:
  dockerfile: jobs/sync-images/Dockerfile.dev
  buildArgs:
    SSH_DEPLOY_PRIVATE_KEY: ${local.env.SSH_DEPLOY_PRIVATE_KEY}
---
kind: Deploy
name: sync-images-job
type: kubernetes
dependencies:
  - build.sync-images-job
  - deploy.datastore
spec:
  manifests:
    - apiVersion: v1
      kind: ConfigMap
      metadata:
        name: sync-images-job-config
      data:
        $merge: ${variables}
    - apiVersion: batch/v1
      kind: Job
      metadata:
        name: sync-images-job-${datetime.timestamp}
      spec:
        ttlSecondsAfterFinished: 30
        template:
          spec:
            restartPolicy: OnFailure
            imagePullSecrets:
              - name: regcred
            containers:
              - name: sync-images-job
                image: ${actions.build.sync-images-job.outputs.deploymentImageId}
                args: [ "sh", "garden.sh" ]
                envFrom:
                  - configMapRef:
                      name: sync-images-job-config
f
Hi @witty-pilot-66879 , you are correct the Deploy.container action type does not expose the
restartPolicy
field and a Deploy.kuberntes is the right choice here. Regarding your solution, what exactly doesn't work about sync mode with this config?
3 Views