Hi everyone :slightly_smiling_face: I have a quest...
# general
f
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
@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
c
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
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
What is the status object?
How are you setting it?
f
I am not setting it, it should be returned by the ingress when it's finished
c
My bad. Then my question should have been, “What do you see when you export
ingress.status
?
Or just
ingress
?
f
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
What about
ingress
itself?
f
that had some information like urn, metadata etc
b
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
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
Sounds plausible.
f
@bored-table-20691 do you mean to lookup the k8s
service
or the elastic load balancer that is being created ?
b
look up the k8s service and get the
LoadBalancer
from that.
f
ah, let me give it a try
seems like the same issue.
service.status.loadBalancer.ingress
is
{}
b
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.