Hello all! So here is yet another question about `...
# getting-started
a
Hello all! So here is yet another question about
Output<string>
from a n00b. :) I have tried reading the q/a given in this Slack, the doc and other blogs but still can't really wrap my head around it. I don't get how to apply (pun) this to my situation. The solution I have today works, but feels wrong. Could somebody give some pointers on how to do this "for real"? The problem: I'm creating a Kubernetes Service "LoadBalancer" and need to get hold of the created IP-adr. I then need to use this IP-adr when creating a ConfigMap using it as data to create a file of it used by a Deployment. (please see code below for what I'm trying to do) The code (simplified, a lot more going on but it is the gist of it):
Copy code
// TypeScript & Azure
myService.status.loadBalancer.ingress[0].ip.apply(hostname => {
      const yamlConfigGroup = new kubernetes.yaml.ConfigGroup(
           "deploymentconfigmap-yml",
           {
             yaml: `
             apiVersion: v1
             kind: ConfigMap
             metadata:
               name: deployment-config
               namespace: kube-system
               labels:
                 k8s-app: theapp
             data:
               thedata.yml: |-
                 thesettings.monitors:
                 - type: mydata
                   hosts: ["${hostname}"]
             `
           }
         );
});
This works but "feels" wrong because it doesn't show the creation in Preview.
b
@able-bird-91336 if you use the configmap resource: https://www.pulumi.com/registry/packages/kubernetes/api-docs/core/v1/configmap/ you wouldn't need to use an apply
a
Thanks for the tip @billowy-army-68599! I did start that way but the example I gave is very simplified, a lot more settings going on. So I gave that up and did it this "easy" way instead. Tried also https://www.pulumi.com/kube2pulumi/ but it gives up on this kind of yaml. But I might give it another try if that is "the way".
b
happy to provide an example later, is it the ya l anchor you're struggling with?
a
That would be very appreciated, thank! Yes, I guess that is basically the biggest challenge ( the data YAML-anchor-file-stuff "|-" and getting the data into it from other resources)
b
@able-bird-91336 the trick is to take advantage of the fact that you can use JSON here because JSON is a superset of yaml, try something like this: https://github.com/jaxxstorm/pulumi-examples/blob/2519023cd4f22acd564783f6f4445a44dd82df65/typescript/aws/eks-platform/metricbeat/index.ts#L43
a
Ah, interesting, I have not thought about it like that. Will try and play with that, thanks! I don't see in your example how data from another resource is put into it but I will have a closer look at all of the code. And I'll read the ReadMe a bit more detailed. 🙂