Hi, We are just getting started using Pulumi in ou...
# kubernetes
r
Hi, We are just getting started using Pulumi in our organisation. We are using Python as we are a Python shop for our main applications. We have got Pulumi creating an eks cluser using pulumi-eks, now we are trying to get it to actually deploy something to the cluster. We are following https://www.pulumi.com/registry/packages/kubernetes/how-to-guides/eks/ modifying the code as that is in JavaScript/TypeScript, however it I'm having problems when specifying the cluster The example has:
Copy code
{
        provider: cluster.provider,
}
as the third parameter(opts), I tried converting this to Python as:
Copy code
opts=pulumi.ResourceOptions(provider=cluster.provider),
However my IDE complains about it being the wrong type (Output[Provider] instead of ProviderResource) and when running
pulumi up
, I get:
Copy code
ValueError: Attempted to register resource kubernetes:apps/v1:Deployment with a provider for '<pulumi.output.Output object at 0x7f695f68c5d0>'
    error: an unhandled error occurred: Program exited with non-zero exit code: 1
Any idea of what I am doing wrong or how I can fix this?
b
You need to map the
Output
to an
Input
. I'm not sure how to do this in Python, but in TypeScript there's an
apply
method.
r
I tried that, but it caused the same error. According to https://www.pulumi.com/docs/intro/concepts/inputs-outputs/#apply "The result of the call to
apply
is a new Output", so it is still the wrong type
b
What does your code look like? You should be doing very roughly:
Copy code
def build_cluster(provider):
    # Big hand-wave here.
    return k8s.Pod(
        provider=provider
    )

pod = cluster.provider.apply(build_cluster)
The function you pass in to
apply
should take the provider as an argument, and return the transformed object. It's using standard monadic patterns (which, sadly, don't have a good analog in Python to draw from). If you've ever used a
promise
API, it's like that.
r
thanks for your help, I did a whole load of experimentation and it turns out it is a open issue in Pulumi: https://github.com/pulumi/pulumi-eks/issues/662 There's a workaround that worked for me
🤔 1
🎉 1