I use this yaml to my charts
<code>apiVersion: batch/v1
kind: Job
metadata:
name: "createmysql-hook"
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "5"
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
spec:
backoffLimit: 1
template:
spec:
restartPolicy: Never
containers:
- name: precheck
image: busybox:1.32
command: ['/bin/sh']
args:
- -c
- |
echo "准备创建 mysql 账户,账户名称: {{ .Chart.Name }}"
accountName="{{ .Chart.Name }}"
wget -O res "http://172.17.0.1:30503/free/device/getNodeCode/$accountName"
res=$(cat res)
if [ "$res" = "success" ]; then
echo "账户创建成功"
exit 0
else
echo "账户创建失败,错误信息:$res"
exit 1
fi
</code>
<code>apiVersion: batch/v1
kind: Job
metadata:
name: "createmysql-hook"
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "5"
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
spec:
backoffLimit: 1
template:
spec:
restartPolicy: Never
containers:
- name: precheck
image: busybox:1.32
command: ['/bin/sh']
args:
- -c
- |
echo "准备创建 mysql 账户,账户名称: {{ .Chart.Name }}"
accountName="{{ .Chart.Name }}"
wget -O res "http://172.17.0.1:30503/free/device/getNodeCode/$accountName"
res=$(cat res)
if [ "$res" = "success" ]; then
echo "账户创建成功"
exit 0
else
echo "账户创建失败,错误信息:$res"
exit 1
fi
</code>
apiVersion: batch/v1
kind: Job
metadata:
name: "createmysql-hook"
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "5"
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
spec:
backoffLimit: 1
template:
spec:
restartPolicy: Never
containers:
- name: precheck
image: busybox:1.32
command: ['/bin/sh']
args:
- -c
- |
echo "准备创建 mysql 账户,账户名称: {{ .Chart.Name }}"
accountName="{{ .Chart.Name }}"
wget -O res "http://172.17.0.1:30503/free/device/getNodeCode/$accountName"
res=$(cat res)
if [ "$res" = "success" ]; then
echo "账户创建成功"
exit 0
else
echo "账户创建失败,错误信息:$res"
exit 1
fi
then use helm Request to creat deployment
the shell in busybox while nevet success
so i think this job while run once and exit
but when i see event it’s always retry
like this
res
so i think maybe retry police is set for pod,not job
but i don’t know how to make job just run once
thanks
I try to set backofflimit and restartpolicy but not use
New contributor
dcdyouget is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.