作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 terraform 将容差值传递到 helm 中。但是我收到了不同的错误消息。
chart are here 的默认值.
...
tolerations:
[]
...
我使用这个代码。
locals {
victoria_tolerations = [{ "key" : "k8s-app", "operator" : "Equal", "value" : "grafana", "effect" : "NoSchedule" }]
}
resource "helm_release" "victoria_metrics" {
name = var.vm_release_name
chart = var.vm_chart
repository = var.vm_chart_repository_url
version = var.vm_chart_version
namespace = local.namespace_victoria
max_history = var.max_history
set {
name = "vmselect.tolerations"
value = jsonencode(local.victoria_tolerations)
}
}
得到错误信息:
Error: failed parsing key "vmselect.tolerations" with value [{"effect":"NoSchedule","key":"k8s-app","operator":"Equal","value":"grafana"}], key "\"key\":\"k8s-app\"" has no value (cannot end with ,)
如果我使用这个变量
victoria_tolerations = <<EOF
- key: k8s-app
operator: Equal
value: grafana
effect: NoSchedule
EOF
我遇到了这个错误:
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Deployment.spec.template.spec.tolerations): invalid type for io.k8s.api.core.v1.PodSpec.tolerations: got "string", expected "array"
附言此外,我尝试以 values
的形式传递。这在这种情况下不起作用。
locals {
victoria_values = {
"tolerations" : [
{
"key" : "k8s-app",
"operator" : "Equal",
"value" : "grafana",
"effect" : "NoSchedule"
}
]
}
}
resource "helm_release" "victoria_metrics" {
name = var.vm_release_name
...
values = [
yamlencode(local.victoria_values)
]
}
最佳答案
尝试动态 block
dynamic "toleration" {
for_each = var.tolerations
content {
key = toleration.value["key"]
operator = toleration.value["operator"]
value = toleration.value["value"]
effect = toleration.value["effect"]
}
}
var 文件
variable "tolerations" {
type = list(map(string))
default = []
description = "Tolerations to apply to deployment"
}
参数
tolerations = [
{
key = "node.kubernetes.io/role",
operator = "Equal",
value = "true",
effect = "NoSchedule"
}
]
关于Terraform helm chart 设置值容差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71126527/
我是一名优秀的程序员,十分优秀!