https://pulumi.com logo
#general
Title
# general
c

chilly-photographer-60932

01/30/2019, 5:05 PM
I am trying to get the service load balancer that is created within
k8s
? I have deployed this using helm chart. I am able to get the hang of the service withsomething like this
istio.getResource("v1/Service", "istio-ingressgateway");
which returns the
k8s
service object https://github.com/pulumi/pulumi-kubernetes/blob/d301148551488034535fc2a66c29aa5a2f86380b/sdk/nodejs/provider.ts#L8435 From this service how do I get the reference to load balancer that was created?
c

chilly-photographer-60932

01/30/2019, 5:12 PM
@gorgeous-egg-16927 Thank you!
🙂 1
I am running into an error.
Copy code
pulumi:pulumi:Stack (eks-eks-naveen):
    (node:61714) ExperimentalWarning: queueMicrotask() is experimental.
    TypeError: Cannot read property 'status' of undefined
Copy code
const i = istio.getResource("v1/Service", "istio-ingressgateway");
const s = i.apply(u => u.status);
@gorgeous-egg-16927 ☝️
g

gorgeous-egg-16927

01/30/2019, 6:15 PM
@chilly-photographer-60932 I haven't used
.getResource
myself yet, but I suspect you need to add a type hint to
const i
so that the compiler knows what kind of resource that call is returning.
c

chilly-photographer-60932

01/30/2019, 6:16 PM
It is a runtime error
g

gorgeous-egg-16927

01/30/2019, 6:16 PM
@creamy-potato-29402 Any ideas?
c

creamy-potato-29402

01/30/2019, 6:17 PM
I'm not in yet
I will be soon
the problem seems to be that you failed to get a service
try enumerating all the keys in the object to see what your options are
this is not a type error. TS knows nothing about types at run time
c

chilly-photographer-60932

01/30/2019, 6:32 PM
Which keys?
c

creamy-potato-29402

01/30/2019, 6:32 PM
the chart object has a dictionary of resources somewhere in there
I am not at my computer so I forget what it's called
c

chilly-photographer-60932

01/30/2019, 6:59 PM
Is there an example that you can share?
c

creamy-potato-29402

01/30/2019, 6:59 PM
no
do you have autocomplete in your editor?
c

chilly-photographer-60932

01/30/2019, 7:01 PM
Yes
I am using vscode
Copy code
const istio = createIstio(cluster);

const i = istio.getResource(
  "v1/Service",
  "istio-ingressgateway.istio-system.svc.cluster.local"
);
c

creamy-potato-29402

01/30/2019, 7:01 PM
when you type
.
what shows up?
istio.
c

chilly-photographer-60932

01/30/2019, 7:01 PM
createIstio
returns an helm chart
c

creamy-potato-29402

01/30/2019, 7:02 PM
no
c

chilly-photographer-60932

01/30/2019, 7:02 PM
c

creamy-potato-29402

01/30/2019, 7:02 PM
I mean, type
istio.
ok so resoruces
can you iterate over the object keys and print out what’s in there?
c

chilly-photographer-60932

01/30/2019, 7:03 PM
istio.resources.apply(o => console.log(o));
Is that good?
c

creamy-potato-29402

01/30/2019, 7:04 PM
that will probably print
[Object object]
or something like that.
Copy code
istio.resources.apply(o => Object.keys(o).forEach(console.log));
something like that.
c

chilly-photographer-60932

01/30/2019, 7:06 PM
A huge dump
Copy code
urn:
          Output {
            __pulumiOutput: true,
            isKnown: Promise { true },
            resources: [Function],
            promise: [Function],
            apply: [Function],
            get: [Function] },
         id:
          Output {
            __pulumiOutput: true,
            isKnown: Promise { <pending> },
            resources: [Function],
            promise: [Function],
            apply: [Function],
            get: [Function] },
         apiVersion:
          Output {
            __pulumiOutput: true,
            isKnown: Promise { <pending> },
            resources: [Function],
            promise: [Function],
            apply: [Function],
            get: [Function] },
         kind:
          Output {
            __pulumiOutput: true,
            isKnown: Promise { <pending> },
            resources: [Function],
            promise: [Function],
            apply: [Function],
            get: [Function] },
         metadata:
          Output {
            __pulumiOutput: true,
            isKnown: Promise { <pending> },
            resources: [Function],
            promise: [Function],
            apply: [Function],
            get: [Function]
c

creamy-potato-29402

01/30/2019, 7:07 PM
Hmm.
pulumi.all(istio.resources).apply(...
?
or
pulumi.output(istio.resources)
, maybe
c

chilly-photographer-60932

01/30/2019, 7:12 PM
My pulumi up is stuck and can’t cancel it
c

creamy-potato-29402

01/30/2019, 7:12 PM
stuck how?
c

chilly-photographer-60932

01/30/2019, 7:14 PM
And now
error: refusing to proceed
@creamy-potato-29402?
c

creamy-potato-29402

01/30/2019, 7:26 PM
pulumi cancel
I don’t know why that happened, it could be for any number of reasons.
that list of things shoudl tell you the name to put into
getResource
c

chilly-photographer-60932

01/30/2019, 7:26 PM
I did pulumi cancel
c

creamy-potato-29402

01/30/2019, 7:27 PM
You mean
pulumi cancel
doesn’t work?
c

chilly-photographer-60932

01/30/2019, 7:28 PM
Copy code
Output {
      __pulumiOutput: true,
      isKnown: Promise { <pending> },
      resources: [Function],
      promise: [Function],
      apply: [Function],
      get: [Function] }
c

creamy-potato-29402

01/30/2019, 7:29 PM
metadata is populated, right?
that’s all you need, is it not?
c

chilly-photographer-60932

01/30/2019, 7:29 PM
Yes
console.log(pulumi.output(istio.resources));
c

creamy-potato-29402

01/30/2019, 7:30 PM
ok, so this should solve your original issue, I think?
c

chilly-photographer-60932

01/30/2019, 7:30 PM
Copy code
const istio = createIstio(cluster);
console.log(pulumi.output(istio.resources));
const i = istio.getResource(
  "v1/Service",
  "istio-ingressgateway.istio-system.svc.cluster.local"
);

const s = i.apply(u => u.status);
console.log(s);
I am still running into an error.
Cannot read property 'status' of undefined
c

creamy-potato-29402

01/30/2019, 7:32 PM
is that the actual name of the service?
evidently not, right?
what does the metadata look like for that object.
c

chilly-photographer-60932

01/30/2019, 7:35 PM
Waiting for the output of this.
Copy code
const istio = createIstio(cluster);
pulumi.output(istio.resources).apply(({ a, b }) => console.log(a, b));
c

creamy-potato-29402

01/30/2019, 7:35 PM
at its core this means that
getResource
has failed to return something sensible. That means your second argument is wrong.
that name does not seem right.
so let’s figure out what the name should be.
it looks like you’re asking for the DNS name, which is probably not what you want.
c

chilly-photographer-60932

01/30/2019, 7:35 PM
Copy code
pulumi:pulumi:Stack (eks-eks-naveen):
    undefined undefined
Istio resource are
undefined
c

creamy-potato-29402

01/30/2019, 7:36 PM
wait, you already printed this out
I see it in the screenshot above
c

chilly-photographer-60932

01/30/2019, 7:36 PM
Copy code
const istio = createIstio(cluster);
pulumi.output(istio.resources).apply(({ a, b }) => console.log(a, b));
c

creamy-potato-29402

01/30/2019, 7:37 PM
can you look at the metadata emitted for that object, from what you printed above?
c

chilly-photographer-60932

01/30/2019, 7:37 PM
istio.resources
?
c

creamy-potato-29402

01/30/2019, 7:38 PM
you are looking for a service object.
you emitted the metadata.name for that object.
in that screenshot above I see you did it.
so if you scroll up and look for the service you’re trying to print, that shoudl solve the problem.
c

chilly-photographer-60932

01/30/2019, 7:39 PM
Let me try that
c

creamy-potato-29402

01/30/2019, 7:40 PM
Youw ere on the right track, now you are doing things that are not on the right track. YOu need to find the metadata for the service you’re looking for which is, I guess:
istio.getResource("v1/Service", "istio-ingressgateway")
so it looks like you already printed out what you need. So you need to find the metadata for that service,
istio-ingressgateway
, if that’s what you’re looking for.
c

chilly-photographer-60932

01/30/2019, 7:44 PM
I am trying it.
c

creamy-potato-29402

01/30/2019, 7:47 PM
you can’t just scroll up and look?
c

chilly-photographer-60932

01/30/2019, 7:48 PM
Yes, waiting for the code to run
The issue was
"istio-system/istio-ingressgateway"
I didn’t know how to get the servicename within a namespace.
Thank you!
c

creamy-potato-29402

01/30/2019, 7:54 PM
ok
np, lmk if you have more questions
c

chilly-photographer-60932

01/30/2019, 7:56 PM
The docs on the code would have helped. Just some feedback.
But you guys are awesome!!
Love the framework and the support
3 Views