Created
May 29, 2020 21:05
-
-
Save timmyers/4d2fed53a358d4c98557a5886ae2afbb to your computer and use it in GitHub Desktop.
Wait for a resource in pulumi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make sure x is a true output so pulumi doesn't try to run this function during preview. | |
const ingressIP = pulumi.all([x]).apply(async ([x]) => { | |
const kc = new k8sClient.KubeConfig(); | |
const provider = (this.getProvider('kubernetes::') as any) | |
const kubeConfig = provider.kubeconfig as pulumi.Output<string>; | |
const ip = kubeConfig.apply(async (config) => { | |
kc.loadFromString(config); | |
const k8sApi = kc.makeApiClient(k8sClient.CoreV1Api); | |
while (true) { | |
try { | |
pulumi.log.info('Waiting for load balancer IP...', this); | |
const res = await k8sApi.readNamespacedService('istio-ingressgateway', namespace) | |
return res.body.status.loadBalancer.ingress[0].ip; | |
} catch (err) { | |
await new Promise(r => setTimeout(r, 2000)); | |
} | |
} | |
}); | |
return ip; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm developing a script to grab the status of a CustomResource based on this: