kubectl icon indicating copy to clipboard operation
kubectl copied to clipboard

Feature Request: ignore error flag

Open spencerdcarlson opened this issue 7 months ago • 0 comments

It would nice if there were a ignore_error option that could be set to true and default to false.

Use case: I want to execute kubectl delete job <job-name> and not fail if the job doesn't exist, so that in the next stage I can execute kubectl apply -f job.yaml

Here is my current workaround

- name: Delete Migration Job
  if: ${{ contains(fromJSON('["prod"]'), matrix.env) }}
  env:
    KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
  run: |
    set -e
    if [ ! -f "$HOME/.kube/config" ]; then
      if [ ! -z "${KUBE_CONFIG}" ]; then
        mkdir -p $HOME/.kube
        echo "$KUBE_CONFIG" | base64 -d > $HOME/.kube/config
      fi
    fi
    kubectl delete job accounts-migrate-database || true
- name: Run Database Migration Job
  if: ${{ contains(fromJSON('["prod"]'), matrix.env) }}
  uses: actions-hub/kubectl@master
  env:
    KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
  with:
    args: apply -f kube/job-db-migrate.yaml    

spencerdcarlson avatar Jan 03 '24 04:01 spencerdcarlson