Hello there! I’d like to retrieve the clusterIP o...
# kubernetes
r
Hello there! I’d like to retrieve the clusterIP of the docker-registry I deployed on a local Kubernetes (deployment + service + ingress) to use it in the same stack, with another component. I’m trying to do so by storing it in a variable as such:
Copy code
variables:
  registry-ip: ${resource-name.status.loadBalancer.ingress[0].ip}
  push: true
But I get the following error, and I don’t know what to try. Any hint, anyone? 🙇‍♂️
h
can you please include more of your program? from the error it sounds like something to do with how
push
is being consumed. total shot in the dark - try
push: "true"
, i wouldn’t be surprised if yaml isn’t expecting a bool there.
r
Here is my current project’s state: There is a bit of a mess. I can whip up a minimal example to reproduce my issue a bit later. I don’t think that other variables are at fault here. It worked fine until I added that single line. I set up a minimal example to reproduce: https://github.com/Pittinic/pulumi-k8s-issue
h
other shot in the dark - i’m not actually sure if
${resource-name}
parses with the hyphen, you might try
${resourceName}
r
Worth the try, but it didn’t work!
(The marshaling property raised in the error differ from try to try, but I don’t think that it’s relevant since replacing or removing the line with resource.status.etc is enough for everything else to work)
I set up a minimal example to reproduce here: https://github.com/Pittinic/pulumi-k8s-issue I’ll upload the error messages a bit later, but as I just said, the error is always “waiting for RPCs: marshaling properties” and the property itself differ from try to try.
h
thanks for the repro! in cases like this i try to rule out whether the issue is with pulumi-yaml specifically. to do that i usually convert the program to ts (
pulumi convert --from yaml --language nodejs --out ts
) and then check if that has the same problem. if it does, that tells me the issue is likely with the provider. if it doesn’t, that tells me it’s probably pulumi-yaml. i suspect the issue in this case is with yaml. i made some small tweaks to get your repro working locally.
Copy code
diff --git a/Pulumi.yaml b/Pulumi.yaml
index cb964db..1f9cbcd 100644
--- a/Pulumi.yaml
+++ b/Pulumi.yaml
@@ -1,7 +1,6 @@
 name: pulumi-k8s-issue
 description: Replicate an issue when retrieving status from k8s.
 runtime: yaml
-config: {'pulumi:tags': {value: {'pulumi:template': yaml}}}

 variables:
   namespace: dev
@@ -87,6 +86,6 @@ resources:
       push: ${docker.push}
       registries: ${docker.registries}
       tags:
-      - ${docker.build.registry}/namespace/repository:tag
+      - ${docker.registries[0].address}/namespace/repository:tag

 outputs: {}
diff --git a/ts/index.ts b/ts/index.ts
index 6dc6e9b..1a3b9cf 100644
--- a/ts/index.ts
+++ b/ts/index.ts
@@ -95,7 +95,7 @@ const dockerImageBuilder = new docker_build.Image("docker-image-builder", {
 RUN echo "buildingbuildingbuilding"
 `,
     },
-    platforms: docker.platforms,
+    platforms: docker.platforms as docker_build.Platform[],
     push: docker.push,
     registries: docker.registries,
     tags: [docker.registries[0].address.apply(address => `${address}/namespace/repository:tag`)],
yaml and ts both fail for me but in different ways. i don’t have a load balancer setup right now, and i think ts is getting further and dying due to a lack of an ip. (you should probably give the service
type: LoadBalancer
so pulumi will wait for it to get an ip) anyway let me know if ts works for your lb. yaml
Copy code
error: receiver must be a list or object, not nil

      on Pulumi.yaml line 13:
      13:     - address: ${docker-registry-service.status.loadBalancer.ingress[0].ip}
    error: an unhandled error occurred: waiting for RPCs: marshaling properties: awaiting input property "push": runtime error
ts
Copy code
docker-build:index:Image (docker-image-builder):
    error: docker-build:index:Image resource 'docker-image-builder': property registries[0] value {<nil>} has a problem: An error occurred decoding 'ImageArgs.registries[0]': 1 failures decoding:
    	address: Missing required field 'address' on 'internal.Registry'
r
Sounds good! I’ll try that as soon as possible, hopefully tonight (19:13 here), and touch base. Once again (that’s becoming a thing), many thanks for your help, @hallowed-photographer-31251! 🙇‍♂️
Damn it you’re right. I made a quick try before leaving work, and that’s it. Making the Service a LoadBalancer works just right.
Can’t I retrieve the clusterIP of a service which isn’t a LoadBalancer, though? IP which is allocated anyways, as shown in
kubectl get services
. I do have some trouble finding the documentation on that, to be honest. I guess I should be able to from here (https://www.pulumi.com/registry/packages/kubernetes/api-docs/core/v1/service/#servicestatus), but I fail to do so, at least so far.
h
r
And you are absolutely right.
${docker-registry-service.spec.clusterIP}
works just fine. Many, many thanks. I was at a total loss about what to do, and thanks to your help, I’m back in the saddle, and I feel like I get the documentation better as well. I owe you one more!
The error messages are quite nicely verbose, and would have helped me even without the documentation had I made some blind attempts, too. Well, at least after that first
unhandled error occured: waiting for RPCs: etc.
anyways 😄.