Search code examples
amazon-web-serviceskubernetesdnsterraformnlb

Kubernetes service usage for NLB from different AWS account


I have a requirement to add kubernetes Service with an ExternalName pointing to NLB(in a different AWS account). I am using terraform to implement this. I am not sure how to use NLB info external name section. Can someone please help?

   resource "kubernetes_service" "test_svc" {
      metadata {
        name      = "test"
        namespace = var.environment
        labels = {
          app = "test"
        }
      }
      spec {
        type          = "ExternalName"
        **external_name =** 
      }
    }

Solution

  • Usage of external name is as follows:

    apiVersion: v1
    kind: Service
    metadata:
      name: my-service
      namespace: prod
    spec:
      type: ExternalName
      externalName: my.database.example.com
    

    Try to put the NLB CNAME as the external name