Due to Pulumi <not playing well with GKE> in Pytho...
# getting-started
h
Due to Pulumi not playing well with GKE in Python I'm trying to do some workaround by directly calling
gcloud
but I'm lost and can't find much examples. With the code below I get
error: unrecognized resource type (Check): gcp:myaccount:Cluster
Copy code
class MyCluster(pulumi.CustomResource):
    def __init__(self, name, opts=None):
        super().__init__("gcp:myaccount:Cluster", name, {}, opts)

    def create(self):
        # TODO: Call gcloud directly to create cluster
        super().create()

    def delete(self):
        # TODO: Call gcloud directly to kill cluster
        super().delete()


cluster = MyCluster("mycluster")
What is
*:**:**
supposed to be?
e
You should in general not be creating your own
CustomResource
, they are specific to providers. "gpcmyaccountCluster" tells the engine this is a resource from the "gcp" provider called "myaccount:Cluster". The gcp provider doesn't define that resource so you get an unrecognized resource type error.
h
Well I need a workaround, to call directly
gcloud
. So what is the suggested approach? I'm on a GKE trial period so can't be waiting for Pulumi to maybe or maybe not implement the missing gcloud flag
e
The normal workaround would be to use dynamic providers: https://www.pulumi.com/docs/intro/concepts/resources/dynamic-providers/
h
Thanks. Unfortunately it's very hard to develop with Python since breakpoints don't work and the examples go from too simple to too complex Any ideas how to just get the
cluster.name
below without adding GkeClusterArgs and a bunch of unnecessary boilerplate?
Copy code
class GkeClusterProvider(ResourceProvider):
    def create(self, inputs):
        cluster_name = inputs["name"] + "-" + str(uuid.uuid4())[:8]
        return CreateResult(id_=cluster_name, outs={
            "name": cluster_name,
        })

class GkeCluster(Resource):
    name: pulumi.Output[str]
    def __init__(self, name, props=None, opts=None):
        props = props or {}
        super().__init__(GkeClusterProvider(), name, {}, opts)

cluster = GkeCluster("cluster-staging")
pulumi.export("myresource", cluster.name)
e
Add "name"=None to props in the GkeCluster init method, and pass props to the super init