is there a way to use a kubernetes service's load ...
# general
b
is there a way to use a kubernetes service's load balancer ip for creating a dns record? i'm using typescript and i'm getting an
Output<string>
is not an
Input<string>
error.
w
I'm getting an
Output<string>
is not an
Input<string>
error.
That would be surprising - an
Output
is definitely a legal value of an
Input
. Do you have the error message?
is there a way to use a kubernetes service's load balancer ip for creating a dns record
Definitely should be possible. Something like https://github.com/pulumi/examples/blob/master/aws-ts-eks-hello-world/index.ts#L85 passed into the
A
record resource should work.
b
yes, that's generally what i'm trying to do. Error is:
Copy code
Type 'Output<string> | undefined' is not assignable to type 'Input<string>'
and it's triggering on the line for the
value
of the
digitalocean.DnsRecord
resource
i've extended the
ServiceDeployment
class from https://github.com/pulumi/examples/blob/master/kubernetes-ts-guestbook/components/k8sjs.ts to fit my need, but i'm using the same
ipAddress
output to provide the
DnsRecord
w
The key part of the error is the
| undefined
. That is telling you that the value may not be available, so you either need to write an
if (something.ip) { ... }
and handle the case it is unavailable, or else use
something.ip!
in TypeScript to ignore the possibility it is undefined if you are really sure it will not be
undefined
in practice for you use-case.
b
i've more or less done the
if
. right now, i'm just doing a check on the ingress hostname, and if it's part of our DO domain, then add the records. when it's not part of that DO domain, then it's probably an internal/testing cluster where there's wildcard DNS set up. do you think there is a better way to handle that? if i gate to
something.ip
will typescript know it can't be undefined? i'm not very well-versed in typescript
w
Yes - TypeScript does data-flow-based typechecking, so if you have code checking for it being undefined, any other branch will remove the
| undefined
from the observed type. It's generally very good at this - and this type check actually frequently catches real bugs.
👍 1