gpt4 book ai didi

kubernetes - 如何在Kubernetes Go Client Pod规范中提供资源限制?

转载 作者:行者123 更新时间:2023-12-03 16:28:10 25 4
gpt4 key购买 nike

    Spec: v1.PodSpec{
Containers: []v1.Container{
v1.Container{
Name: podName,
Image: deploymentName,
ImagePullPolicy: "IfNotPresent",
Ports: []v1.ContainerPort{},
Env: []v1.EnvVar{
v1.EnvVar{
Name: "RASA_NLU_CONFIG",
Value: os.Getenv("RASA_NLU_CONFIG"),
},
v1.EnvVar{
Name: "RASA_NLU_DATA",
Value: os.Getenv("RASA_NLU_DATA"),
},
},
Resources: v1.ResourceRequirements{},
},
},
RestartPolicy: v1.RestartPolicyOnFailure,
},

我想提供相应的资源限制,例如:

resources:
limits:
cpu: "1"
requests:
cpu: "0.5"
args:
- -cpus
- "2"


我如何继续做到这一点。我尝试添加Limits及其映射键值对,但这似乎是一个嵌套的结构。关于如何在kube client go中提供资源似乎没有任何示例。

最佳答案

在创建有状态集时,我一直在努力。也许我的代码被窃取将帮助您:

Resources: apiv1.ResourceRequirements{
Limits: apiv1.ResourceList{
"cpu": resource.MustParse(cpuLimit),
"memory": resource.MustParse(memLimit),
},
Requests: apiv1.ResourceList{
"cpu": resource.MustParse(cpuReq),
"memory": resource.MustParse(memReq),
},
},

vars cpuReq,memReq,cpuLimit和memLimit应该是字符串

关于kubernetes - 如何在Kubernetes Go Client Pod规范中提供资源限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52983173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com