0

我尝试在 terraform 上创建入口资源。我收到以下错误消息

错误:无法创建入口“jenkins/jenkins-ingress”,因为:服务器找不到请求的资源(发布 ingresses.extensions)││使用 kubernetes_ingress.jenkins-ingress,│在 main.tf 第 160 行,在资源“kubernetes_ingress”中““詹金斯入口”:│160:资源“kubernetes_ingress”“詹金斯入口”{

我的 terraform 资源如下所示:

resource "kubernetes_ingress" "jenkins-ingress" {
    metadata {
        name = "${var.name}-ingress"
        namespace = var.namespace
        annotations = {
            "ingress.kubernetes.io/rewrite-target" = "/"
            "kubernetes.io/ingress.class" = "nginx"
        }
    }
    spec {
        rule {
            host = "domain.com"
            http {
                path {
                    path = "/"
                    backend {
                        service_name = var.name
                        service_port = 8080
                    }
                }
            }
        }
   }
}

如果我通过 yaml 创建入口,它可以工作:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: jenkins-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: domain.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: jenkins
            port:
              number: 8080

令我印象深刻的是规则(参见kubernetes_ingress)与terraform 脚本和 yaml 中的规则之间的区别。想法?

4

0 回答 0