我以这种方式(EKS环境)成功调用Kaniko(可以构建Docker镜像的Docker镜像):
cat build.tar.gz | kubectl run kaniko-httpd-ex --quiet --stdin --rm --restart=Never --image=748960220740.dkr.ecr.eu-west-1.amazonaws.com/kaniko:0 --env=AWS_SDK_LOAD_CONFIG=true -- --destination=748960220740.dkr.ecr.eu-west-1.amazonaws.com/httpd-ex:23-04-26_08-54-DV-6525-kube --context tar://stdin --label commit=8e3a236f702c689891a50a60acf7e05658fa3939 --label build_url=Sin-Jenkins
这可以正常工作,除非没有足够的临时存储可用。
现在我想指定限制,如ephemereal-storage
。由于--limits
选项在最近版本的Kubernetes中已经被删除,所以我必须使用--overrides
,并且我必须改变很多东西。
我是这样做的:
cat build.tar.gz | kubectl run kaniko-httpd-ex --quiet --restart=Never -i --rm --image=748960220740.dkr.ecr.eu-west-1.amazonaws.com/kaniko:0 --overrides='{"apiVersion":"v1",
"spec":
{"containers":[{
"name":"kaniko",
"stdin": true,
"restartPolicy":"Never",
"image":"748960220740.dkr.ecr.eu-west-1.amazonaws.com/kaniko:0",
"env":[{"name":"AWS_SDK_LOAD_CONFIG","value":"true"}],
"resources":{"requests":{
"ephemeral-storage":"116Mi",
"memory": "50Mi",
"cpu": "50m"
}},
"args":[
"--destination=748960220740.dkr.ecr.eu-west-1.amazonaws.com/httpd-ex:23-04-26_08-57-DV-6525-kube",
"--context","tar://stdin"
,"--label","commit=8e3a236f702c689891a50a60acf7e05658fa3939","--label","build_url=Sin-Jenkins"]
}]}'
它正确地启动了kaniko,但65秒后,kaniko被杀死,唯一的错误消息是:
error: timed out waiting for the condition
$ kubectl get ev | grep kaniko
19m Normal Scheduled pod/kaniko-httpd-ex Successfully assigned sbt-david/kaniko-httpd-ex to ip-10-120-134-171.eu-west-1.compute.internal
19m Normal Pulled pod/kaniko-httpd-ex Container image "748960220740.dkr.ecr.eu-west-1.amazonaws.com/kaniko:0" already present on machine
19m Normal Created pod/kaniko-httpd-ex Created container kaniko
19m Normal Started pod/kaniko-httpd-ex Started container kaniko
17m Normal Killing pod/kaniko-httpd-ex Stopping container kaniko
如何在使用stdin
时指定资源限制?
相关信息:
备注:
- 我不能使用
kubectl run
中的--limits
标志,因为它最近被删除了。
2条答案
按热度按时间rhfm7lfc1#
您的样品:
尝试:
下面是一个运行5m的pod的工作示例。执行
kubectl describe pod busybox
并检查Requests
部分:yws3nbqq2#
它运行正常,如果我这样做,我可以设置限制:
因此,对于高级用途,
kubectl run
并不合适,至少对于版本1是这样。27.1.