0

Hi I keep getting the below error no mater how I set up my ingress with alb controller for AWS, running on Kubernetes 1.22

Error: Failed to read Ingress '/' because: the server could not find the requested resource (get ingresses.extensions my-ingress)
  on .terraform/modules/service/kubernetes.tf line 144, in data "kubernetes_ingress" "sticky_ingresses":
 144: data "kubernetes_ingress" "sticky_ingresses" {

My ingress looks like this:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    alb.ingress.kubernetes.io/scheme: internal
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/target-group-attributes: stickiness.enabled=true,stickiness.lb_cookie.duration_seconds=60
    # SSL Settings
    alb.ingress.kubernetes.io/backend-protocol: HTTPS
    alb.ingress.kubernetes.io/listen-ports: '[ { "HTTPS": 443 }, { "HTTP": 80 } ]'
    alb.ingress.kubernetes.io/certificate-arn: my:arn
    alb.ingress.kubernetes.io/ssl-policy: ELBSecurityPolicy-TLS-1-2-2017-01
    # SSL Redirect Setting
    alb.ingress.kubernetes.io/ssl-redirect: '443'
    # Tags
    alb.ingress.kubernetes.io/tags: 'some_tags=tags'
spec:
  ingressClassName: alb
  rules:
    - http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: my-ingress-ui
                port: 
                  number: 443

Specific block where error is coming from

data "kubernetes_ingress" "sticky_ingresses" {
  provider = kubernetes.local

  for_each = local.present && !local.service.maintenance ? local.service.sticky_services : {}

  metadata {
    name = each.value
    namespace = local.app_namespace
  }
}

there are no errors in the controller, the service is running, the ingress is up and load balancer is present. What am I missing?

Kurse
  • 33
  • 1
  • 1
  • 9
  • 1
    Shouldn't the data source be `kubernetes_ingress_v1`: https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/data-sources/ingress_v1? – Marko E Jan 13 '23 at 09:08
  • 1
    It doesn't seem like it, just tried running it "The provider provider.kubernetes.local does not support data source "kubernetes_ingress_v1"." – Kurse Jan 13 '23 at 09:25
  • 1
    Is this a third party provider? We need to know what custom provider this is if it is not the official one. – Matthew Schuchard Jan 13 '23 at 11:57
  • 1
    Thank you Matt and Marko, your comments were correct, I was using a custom provider instead of the official one, fixed by replacing provider and using kubernetes_ingress_v1 – Kurse Jan 13 '23 at 14:33

1 Answers1

0

As suggested by Marko E, The data source should be kubernetes_ingress_v1 which is the offical one .

Ingress is a collection of rules that allow inbound connections to reach the endpoints defined by a backend. An Ingress can be configured to give services externally-reachable urls, load balance traffic, terminate SSL, offer name based virtual hosting etc. This data source allows you to pull data about such ingress.

Refer to the document for more infromation.

Fariya Rahmat
  • 2,123
  • 3
  • 11