https://pulumi.com logo
#getting-started
Title
# getting-started
p

prehistoric-london-9917

05/26/2021, 11:35 PM
Hi everyone - hoping for some guidance here. I have a k8s Ingress resource I’m creating that ends up provisioning an AWS ALB. I then want to create a Route 53 Alias based on the provisioned ALB. I’m using
getLoadBalancer
to retrieve the provisioned ALB, but this seems to be in a race condition for the ALB controller to fully provision it. So I get a “load balancer not found” error. I’ve tried wrapping the Ingress resource in an
all
, but that doesn’t seem to help. Any suggestions on what I can do to make the
getLoadBalancer
function to wait for the load balancer to provision?
This is the current code.
I think line 30 is the bit causing me issues.
b

billowy-army-68599

05/26/2021, 11:41 PM
so the problem here is that the Kubernetes ingress might have been created (ie, registered in the API server) but the backing load balancer (I'm guessing you're using the AWS load balancer controller?) might not have been provisioned yet
p

prehistoric-london-9917

05/26/2021, 11:41 PM
Exactly..
here’s the error
preview
throws, which is understandable.
up
behaves the same way, though:
Copy code
pulumi:pulumi:Stack (demo_env-mattr):
    error: Running program '/Users/matthew.riedel/Source/devex/demo_env' failed with an unhandled exception:
    Error: invocation of aws:lb/getLoadBalancer:getLoadBalancer returned an error: invoking aws:lb/getLoadBalancer:getLoadBalancer: 1 error occurred:
    	* error retrieving LB: LoadBalancerNotFound: Load balancers '[mattr-mattr-lb]' not found
    	status code: 400, request id: 25a5f702-7435-435c-a5a7-ccd7aa948357
b

billowy-army-68599

05/26/2021, 11:41 PM
does the ingress resource return a
status
field that gets populated with the load balancer name? if it does, might be able to use an
apply()
on that
p

prehistoric-london-9917

05/26/2021, 11:42 PM
I started that way, but maybe I goofed something up.. Let me try again
b

billowy-army-68599

05/26/2021, 11:42 PM
I don't have a great answer off the top of my head here, but I'll have a crack at this tonight to see if I can find a solution, because I agree this is a problem that we need to try figure out
you might try deploying the ingress manually, inspecting the status output and seeing what's there
p

prehistoric-london-9917

05/26/2021, 11:44 PM
Thanks @billowy-army-68599
Here’s what I have now. Will give this a shot.
Just an update on this @billowy-army-68599 - I tried a few
.apply
approaches (the current one below), and they exhibit the same issue. My hunch is that k8s gets the LB hostname, but AWS hasn’t actually finished creating it yet, so when
getLoadBalancer
is called, it’s not found. I suppose I could wrap the whole thing in some sort of delay, but wondering if there might be a better solution.
FWIW, I decided to use the
ts-retry
module as a workaround. This seems to work for my purposes.
🙌 1
Any drawbacks / idiom-breaking issues with that approach?
3 Views