Hi, I am trying to run the following code: ```moni...
# general
e
Hi, I am trying to run the following code:
Copy code
monitoring = kubernetes.helm.v3.Release(
    "monitoring",
    name="monitoring",
    chart="kube-prometheus-stack",
    namespace="monitoring",
    repository_opts=kubernetes.helm.v3.RepositoryOptsArgs(
        repo="<https://prometheus-community.github.io/helm-charts>",
    ),
    values={
        "grafana": {
            "ingress": {
                "enabled": True,
            },
        },
    },
)

grafana_ingress = kubernetes.networking.v1.Ingress.get(
    "grafana-ingress",
    Output.concat("monitoring/monitoring-grafana"),
)
grafana_ip = grafana_ingress.status.load_balancer.ingress[0].ip
But it errors as
status.loadBalancer
does not have the
ip
value. If I rerun multiple times
pulumi up
it will register and continue. Is there a why to define a sort of
timeout
for the
kubernetes.networking.v1.Ingress.get
? Thanks
q
Hey @echoing-postman-88590. I believe that the first time this program runs, it probably crashes on the
.get
because the Ingress doesn't exist, but on subsequent runs it finds the resource. Is that correct?
e
Yes exacly:
Copy code
kubernetes:<http://networking.k8s.io/v1:Ingress|networking.k8s.io/v1:Ingress> (grafana-ingress):
    error: 2 errors occurred:
    	* Resource 'monitoring-grafana' was created but failed to initialize
    	* Ingress .status.loadBalancer field was not updated with a hostname/IP address.
        for more information about this error, see <https://pulumi.io/xdv72s>
I would like to avoid the rerun, I would prefer to just wait
q
I believe if you change your
.get
to:
Copy code
grafana_ingress = kubernetes.networking.v1.Ingress.get(
    "grafana-ingress",
    Output.concat("monitoring/monitoring-grafana"),
    { dependsOn: [monitoring] },
)
it should help
the
helm.v3.Release
creation will actually wait for the Ingress to get the public IP, but we need to code that dependency via
dependsOn
e
Is it:
Copy code
{"dependsOn": [monitoring]},
or
Copy code
{dependsOn: [monitoring]},
Otherwise how do I import the
dependsOn
function?
q
dependsOn
isn't a function, it's a property on the
CustomResourceOptions
of Pulumi Resources. Let me check this is an option on Kubernetes provider, please give me a moment.
Yep, looks good:
Copy code
get(name: string, id: pulumi.Input<string>, opts?: pulumi.CustomResourceOptions | undefined): k8s.networking.v1.Ingress
e
I am still getting the same error:
Copy code
grafana_ingress = kubernetes.networking.v1.Ingress.get(
    "grafana-ingress",
    Output.concat(monitoring.status.namespace, "/", monitoring.status.name, "-grafana"),
    opts=ResourceOptions(depends_on=[monitoring]),
)
I was expecting the
monitoring.status
to already establish the dependency
I was monitoring the creation of ingress during the deployment. The
helm.v3.Release
wait for the creation of the
monitoring-grafana
ingress but the ingress itself got a public ip after 90 seconds. That's why it is failing.
@quiet-wolf-18467 should I open an issue on pulumi-kubernetes? Thanks
q
Yeah. Tag me in it and I'll try to reproduce and work out what is wrong
e
done