https://pulumi.com logo
#general
Title
# general
f

future-refrigerator-88869

09/02/2021, 8:32 PM
Hi everyone 🙂 I have a question about the EKS, more specifically about deploying an application and its respective ingress. I am using the
aws load balancer controller
,create the
IngressClass
and create the ingress itself using
k8s.networking.v1.Ingress
. Everything works fine, the load balancer is created, traffic is getting to the instance. However, when I try to expose the ingress URL as a pulumi output, it seems that pulumi doesn't know that it has to wait for the load balancer to be created and it seems like it finishes execution before having access to that load balancer. This is how I am trying to expose it and still doesn't work. The value is empty when exposing it. Anyone has any ideas here ?
Copy code
export const ingressUrl = ingress.status.apply(
  (status) => status.loadBalancer.ingress[0].hostname
);
b

bored-table-20691

09/02/2021, 8:52 PM
@future-refrigerator-88869 I’m not super familiar with Ingress specifically and how it exposes it, but I do something similar with Contour and getting the LB information (it’s in Go but similar constructs):
Copy code
contourDeploy, err := yaml.NewConfigFile(ctx, "contour-deploy-file", &yaml.ConfigFileArgs{
		File: "./contour.yaml",
		Transformations: []yaml.Transformation{
			// Use an NLB instead of an ELB
			func(state map[string]interface{}, opts ...pulumi.ResourceOption) {
				metadata := state["metadata"].(map[string]interface{})
				name := metadata["name"]
				if state["kind"] == "Service" && name == "envoy" {
					annotations := metadata["annotations"].(map[string]interface{})
					delete(annotations, "<http://service.beta.kubernetes.io/aws-load-balancer-backend-protocol|service.beta.kubernetes.io/aws-load-balancer-backend-protocol>")
					annotations["<http://service.beta.kubernetes.io/aws-load-balancer-type|service.beta.kubernetes.io/aws-load-balancer-type>"] = "nlb"
				}
			},
		},
	}, pulumi.Provider(eksConfig.Provider))
	if err != nil {
		return nil, err
	}

	contourService := contourDeploy.GetResource("v1/Service", "envoy", "projectcontour").(*corev1.Service)
	contourServiceLB := contourService.Status.LoadBalancer().Ingress().Index(<http://pulumi.Int|pulumi.Int>(0)).Hostname().Elem()
f

future-refrigerator-88869

09/02/2021, 8:56 PM
c

calm-quill-21760

09/02/2021, 8:56 PM
I’ve sometimes been bitten by assuming the structure of the returned object. Do you see output if you export just
status
and then
status.loadBalancer
?
f

future-refrigerator-88869

09/02/2021, 8:57 PM
Copy code
contourServiceLB := contourService.Status.LoadBalancer().Ingress().Index(<http://pulumi.Int|pulumi.Int>(0)).Hostname().Elem()
that should be the equivalent of my export (i tried just exporting it without applying too). the result is undefined.
No. the while
status
is empty.
c

calm-quill-21760

09/02/2021, 8:57 PM
What is the status object?
How are you setting it?
f

future-refrigerator-88869

09/02/2021, 8:57 PM
I am not setting it, it should be returned by the ingress when it's finished
c

calm-quill-21760

09/02/2021, 8:58 PM
My bad. Then my question should have been, “What do you see when you export
ingress.status
?
Or just
ingress
?
f

future-refrigerator-88869

09/02/2021, 8:59 PM
ingress.status
is the one i am interested in but it is empty. It seems like it's not awaiting the creation of the ELB. I can see in aws console that when the ELB begins creation the
pulumi up
finishes execution while the elb is still deploying.
c

calm-quill-21760

09/02/2021, 8:59 PM
What about
ingress
itself?
f

future-refrigerator-88869

09/02/2021, 9:00 PM
that had some information like urn, metadata etc
b

bored-table-20691

09/02/2021, 9:00 PM
Yeah, it is possible that
ingress
is not marked correctly in terms of this being an output, I’m not sure. In my case, I am not using an ingress object and I go to the underlying
Service
@future-refrigerator-88869 can yuo lookup the specific
Service
that
Ingress
is creating under the hood (I believe it does this)?
f

future-refrigerator-88869

09/02/2021, 9:02 PM
one of the github issues i linked mentioned that using
k8s.networking.v1.Ingress
is not exporting the
ingress.status
while the
k8s.extensions.v1beta1.Ingress
is working fine. So maybe there's a problem there
b

bored-table-20691

09/02/2021, 9:03 PM
Sounds plausible.
f

future-refrigerator-88869

09/02/2021, 9:03 PM
@bored-table-20691 do you mean to lookup the k8s
service
or the elastic load balancer that is being created ?
b

bored-table-20691

09/02/2021, 9:03 PM
look up the k8s service and get the
LoadBalancer
from that.
f

future-refrigerator-88869

09/02/2021, 9:04 PM
ah, let me give it a try
seems like the same issue.
service.status.loadBalancer.ingress
is
{}
b

bored-table-20691

09/02/2021, 9:13 PM
Hmm. Not sure I have much that is helpful to add.
I can’t tell if what I have works to do to being lucky on timing or if it’s something else.
7 Views