在 job.yaml 下面用于创建作业。未创建初始化容器。
[root@app]# kubectl version 客户端版本:version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.5", GitCommit:"", GitTreeState:"clean", BuildDate:"2019 -10-15T19:16:51Z", GoVersion:"go1.12.10", 编译器:"gc", 平台:"linux/amd64"} 服务器版本: version.Info{Major:"1", Minor:"15" ,GitVersion:“v1.15.5”,GitCommit:“”,GitTreeState:“clean”,BuildDate:“2019-10-15T19:07:57Z”,GoVersion:“go1.12.10”,编译器:“gc”,平台: “linux/amd64”}
apiVersion: batch/v1
kind: Job
metadata:
name: pi
spec:
template:
metadata:
name: pi
annotations:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "init-myservice",
"image": "busybox",
"command": ["sh", "-c", "until nslookup myservice; do echo waiting for myservice; sleep 2; done;"]
},
{
"name": "init-mydb",
"image": "busybox",
"command": ["sh", "-c", "until nslookup mydb; do echo waiting for mydb; sleep 2; done;"]
}
]'
spec:
containers:
- …
Run Code Online (Sandbox Code Playgroud) kubernetes ×1