https://pulumi.com logo
#yaml
Title
# yaml
s

straight-fireman-55591

08/04/2023, 11:14 AM
Hi, can someone help me create a namespace on a specific gke cluster? I understand I have to create a gke-cluster-provider first but I'm not sure how to do it. Not sure if https://www.pulumi.com/registry/packages/gcp/api-docs/provider/ is missing something. # I create gke cluster:
Copy code
gke-cluster:
    type: gcp:container:Cluster
    .
    .
    .
# Now crating a namespace:
Copy code
ray-system:
    type: kubernetes:core/v1:Namespace
    properties:
      metadata:
        name: ray-system
    options:
      provider: ${gke-cluster}
      dependsOn:
      - ${gke-cluster}
# This gets me an error:
Copy code
error: resource passed as Provider was not a provider resource '&{{{{{%!s(int32=0) %!s(uint32=0)} %!s(uint32=0) %!s(uint32=0) %!s(int32=0) %!s(int32=0)} {%!s(*pulumi.OutputState=&{0x140005a46c0 0x140004083f0 0 <nil> <nil> false false 0x101cc4480 [0x140006c02a0]})} {%!s(*pulumi.OutputState=&{0x140005a4680 0x140004083f0 0 <nil> <nil> false false 0x101bd6980 [0x140006c02a0]})} map[] map[] <nil>   [] gke-cluster [] %!s(bool=false)} {%!s(*pulumi.OutputState=&{0x140005a4640 0x140004083f0 0 <nil> <nil> false false 0x101cc42c0 [0x140006c02a0]})}} gke-cluster {%!s(*pulumi.OutputState=&{0x140005a4600 0x140004083f0 0 <nil> <nil> false false 0x101bf6dc0 [0x140006c02a0]})}}'
# If I try:
provider: ${gke-cluster.name}
or
provider: ${gke-cluster.id}
I get an error:
return: error: resource cannot be an output
I'n not sure how to create a provider for above gke cluster using:
type: pulumi:providers:gcp
s

salmon-account-74572

08/04/2023, 3:14 PM
Hi @straight-fireman-55591! I’d recommend taking a look at the GKE YAML template (found at https://github.com/pulumi/templates/tree/master/kubernetes-gcp-yaml) to see how the Kubeconfig is built. You can then create a new provider and pass that Kubeconfig to the provider; this enables the provider to interact with the cluster that was just created. From there, you can use the Kubernetes resources via the new provider to create whatever you need. While not in YAML (it’s in TypeScript), this code shows creating an EKS cluster and then creating resources on that cluster: https://github.com/pulumi/zephyr-app/tree/blog/original/infra
Between these two examples, hopefully that provides enough information to get you going! Also, I’d encourage you to take advantage of Pulumi AI (https://pulumi.com/ai) to help with this sort of thing. It’s not perfect, but it typically can provide enough information to point users in the right direction.