sidecar与kubernetes提供程序的terraform



我必须在k8s部署中添加2个容器作为侧车。我正在使用terraform Kubernetes提供商。它在terraform Kubernetes provider中可用吗?如果有,请举个例子。

resource "kubernetes_deployment" "test_deployment" {
metadata {
name = test_nginx
namespace = test
labels = {
app = test_nginx
}
}

spec {
replicas = "2"

selector {
match_labels = {
app = test_nginx
}
}

template {
metadata {
labels = {
app = test_nginx
}
}
spec {
container {
image             = nginx
name              = local_nginx
.
.
.
image             = logrotate
name              = local_logrotate
.
.
.
}
}
}
}
}

错误:

错误:属性重新定义││在部署部署。第84行:参数"image"已经设置│at deploymentdeployment.tf:28,11-16。每个实参只能设置一次。

您需要使用另一个container块:

resource "kubernetes_deployment" "test_deployment" {
metadata {
name = test_nginx
namespace = test
labels = {
app = test_nginx
}
}
spec {
replicas = "2"
selector {
match_labels = {
app = test_nginx
}
}
template {
metadata {
labels = {
app = test_nginx
}
}
spec {
container {
image             = nginx
name              = local_nginx
.
.
.
}
# new container block
container {
image             = logrotate
name              = local_logrotate
.
.
.
}
}
}
}
}

我还建议迁移到新版本的部署[1],即kubernetes_deployment_v1


[1] https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/deployment_v1

相关内容

  • 没有找到相关文章

最新更新