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

full-dress-10026

12/11/2021, 12:39 AM
I have created an ingress-nginx chart. I'd like to get the hostname of the AWS NLB that was created. Does anyone know how I might go about doing that?
Chart creation code:
Copy code
const ingressNginx = new k8s.helm.v3.Chart("ingress-nginx", {
    fetchOpts: {
        repo: "<https://kubernetes.github.io/ingress-nginx>"
    },
    chart: "ingress-nginx",
    namespace: ingressNginxNs.metadata.name,
    values: {

    },
}, {providers: {"kubernetes": cluster.provider}});
b

billowy-army-68599

12/11/2021, 12:42 AM
Copy code
export let ingressIP = ingressNginx
    .getResourceProperty("v1/Service", "ingress-nginx", "status")
    .apply(status => status.loadBalancer.ingress[0].ip);
Something like this, untested
f

full-dress-10026

12/11/2021, 12:46 AM
Oooo! Thank you so much. I'll try that out right now.
Alright so I think the concept is correct. It'd be super helpful if you had a pointer on how I could determine what the correct values are to pass to
getResourceProperty
. I'm not even sure what docs I should be looking at to determine that. I can see the NLB host name in the pulumi stack export JSON, so I know it's there 🙂
Located deep in the stack export:
Copy code
"status": {
                        "loadBalancer": {
                            "ingress": [
                                {
                                    "hostname": "..."
                                }
                            ]
                        }
                    }
This is what occurs when trying the code you pasted verbatim:
Copy code
error: TypeError: Cannot read properties of undefined (reading 'status')
        at /Users/kenny/work/computesoftware/kubecost-explore/pulumi/node_modules/@pulumi/yaml/yaml.ts:2582:33
        at /Users/kenny/work/computesoftware/kubecost-explore/pulumi/node_modules/@pulumi/pulumi/output.js:250:35
        at Generator.next (<anonymous>)
        at /Users/kenny/work/computesoftware/kubecost-explore/pulumi/node_modules/@pulumi/pulumi/output.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/Users/kenny/work/computesoftware/kubecost-explore/pulumi/node_modules/@pulumi/pulumi/output.js:17:12)
        at applyHelperAsync (/Users/kenny/work/computesoftware/kubecost-explore/pulumi/node_modules/@pulumi/pulumi/output.js:229:12)
        at /Users/kenny/work/computesoftware/kubecost-explore/pulumi/node_modules/@pulumi/pulumi/output.js:183:65
        at runMicrotasks (<anonymous>)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
Looks like it's nested under
outputs
in a map that contains
Copy code
"id": "ingress-nginx/ingress-nginx-controller",
                "type": "kubernetes:core/v1:Service",
I've tried the following for the name arg to getResourceProperty and all fail with the above exception. • ingress-nginx • ingress-nginx/ingress-nginx • ingress-nginx/ingress-nginx-controller
b

billowy-army-68599

12/11/2021, 1:03 AM
i'll have a go myself when I get chance, I haven't used this myself for a while
f

full-dress-10026

12/11/2021, 1:05 AM
Ok, thank you. Here's a simple repro:
Copy code
const ingressNginxNs = new k8s.core.v1.Namespace("ingress-nginx-ns", {
    metadata: {
        name: "ingress-nginx"
    }
}, {provider: cluster.provider})

const ingressNginx = new k8s.helm.v3.Chart("ingress-nginx", {
    fetchOpts: {
        repo: "<https://kubernetes.github.io/ingress-nginx>"
    },
    chart: "ingress-nginx",
    namespace: ingressNginxNs.metadata.name,
    values: {},
}, {providers: {"kubernetes": cluster.provider}});

const ingressHost = ingressNginx.getResourceProperty("v1/Service", "ingress-nginx", "status")
    .apply(status => console.log(status))
w

wonderful-twilight-70958

12/11/2021, 1:37 AM
If you're deleting a helm chart there may be a helm release prefix on your service?
Are you sure it's called just ingress-nginx? (check with kubectl)
f

full-dress-10026

12/11/2021, 2:26 AM
It's the exact code snippet above. That's a good idea though. I will verify that tomorrow.
4 Views