faint-motherboard-95438
06/23/2020, 2:32 PMgetResource()
on a k8s.helm.v2.Chart
yields a weird error:
Error: invocation of kubernetes:yaml:decode returned an error: error converting YAML to JSON: yaml: line 29: could not find expected ':'
I’m installing mongodb-replicaset
chart and try to access the StatefulSet
:
this.statefulSet = this.chart.getResource(
'apps/v1/StatefulSet',
replicaSetName,
)
const uri = `mongodb://${this.statefulSet.spec.serviceName}:27017`
Following snippet example from here : https://www.pulumi.com/docs/guides/adopting/from_kubernetes/#provisioning-a-helm-chartgorgeous-egg-16927
06/23/2020, 3:32 PMfaint-motherboard-95438
06/23/2020, 3:38 PMstatefulSet
of this chart I get with getResource()
, its always undefined
I can’t access its properties (metadata
, spec
, etc). I try to apply()
or interpolate
but there’s no way to get anything out of a getResource()
at that point for me. Doing like your example yields undefined
too.gorgeous-egg-16927
06/23/2020, 4:01 PMconst wordpress = new k8s.helm.v2.Chart("wpdev", {
repo: "stable",
chart: "wordpress",
version: "9.0.3",
});
// Export the public IP for WordPress.
export const frontend = wordpress.getResource("v1/Service", "wpdev-wordpress");
I did notice that the frontendIp
was undefined running on docker for mac because the loadbalancer status field is actually frontend.status.loadBalancer.ingress[0].hostname
. This varies depending on which k8s you’re running.faint-motherboard-95438
06/23/2020, 4:13 PMgetResource()
returns a component of the expected type with its properties set no matter what ? How can I rely on it if it does not ? I need the StatefulSet.spec.serviceName
and it seems I can’t get it and will have to rely on a manual concatenation guess.gorgeous-egg-16927
06/23/2020, 4:21 PMgetResource
works as you expect. However, it returns an Output, and it looks like you’re trying to use a normal string interpolation rather than pulumi.interpolate
to build the uri
string. I suspect this is the actual problem.faint-motherboard-95438
06/23/2020, 4:26 PMconst uri = `mongodb://${this.statefulSet.spec.serviceName}:27017`
const uri = pulumi.interpolate`mongodb://${this.statefulSet.spec.serviceName}:27017`
const uri = this.statefulSet.spec.apply(spec => `mongodb://${spec.serviceName}:27017`)
Always get something like unable to get serviceName from undefined
One thing I don’t understand is that I actually get the errors during the preview, while the resource does not actually exist yet, which makes sense, but pulumi should know that, right ?
I ensured the replicasetName
variable I use in getResource()
is the valid expected name of the resource, so we should be safe here.gorgeous-egg-16927
06/23/2020, 4:41 PMreplicasetName
an Output<string>
, or a string
?faint-motherboard-95438
06/23/2020, 4:50 PMstring
getResource()
does not find the resource, what’s its behavior ? fail silently with an undefined
value or something more definitive ? Again since the error is raised during preview, that’s not easy to guess what would have been the final state, services are not provisioned yet.gorgeous-egg-16927
06/23/2020, 4:57 PMundefined
faint-motherboard-95438
06/23/2020, 4:58 PM${namespace}/${replicasetName}
if I understand it right ?gorgeous-egg-16927
06/23/2020, 5:01 PMfaint-motherboard-95438
06/23/2020, 5:07 PMgorgeous-egg-16927
06/23/2020, 5:10 PMfaint-motherboard-95438
06/23/2020, 5:11 PM