导语:尝试在job名称后添加唯一随机字符串来使job重复执行。正常情况下job类型是不会重复执行的,考虑到升级时需要删除对应的job,再执行不太友好。

文件如下templates/aiserver-migration.yaml

---templates/aiserver-migration.yaml
apiVersion: batch/v1
kind: Job
metadata:
  name: aiserver-migration-{{ randAlphaNum 5 | lower  }}
spec:
 template:
  metadata:
    name: aiserver-migration
  spec:
   initContainers:
     - command: ['sh', '-c', "until nc -w 3  -zv mysql-headless 3306 ; do echo waiting for mydb; sleep 5; done"]
     #- command: ['sh', '-c', "until mysqladmin ping -hmysql-headless -pdeepwise ; do echo waiting for mydb; sleep 5; done"]
       image: harbor.deepwise.com/base/busybox:stable-alpine
       name: wait-for-mysql
   containers:
   - name: aiserver-migration
     image: {{ .Values.images.migration_aiserver }}
     command: ["sh","-c","sh /srv/aiserver-migration/startup.sh"]
#     volumeMounts:
#       - name: migration-log
#         mountPath: /root/migration/
   restartPolicy: OnFailure
#   volumes:
#     - name: migration-log
#       hostPath:
#         path: /data1/deepwise/container-root/migration/aiserver

以下都可以

-{{ randAlphaNum 5 | lower  }}
-{{ randAlphaNum 5 | quote }}

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐