lbrlabs / pulumi-ovh

Pulumi provider for OVH
Apache License 2.0
10 stars 1 forks source link

[Go] Can't deploy a kubernetes cluster #62

Open scraly opened 1 year ago

scraly commented 1 year ago

Hi,

i've tried to find how to create a kubernetes cluster but without any chance :(

My go.mod file:

require (
    github.com/lbrlabs/pulumi-ovh/sdk v0.2.0
    github.com/pulumi/pulumi/sdk/v3 v3.55.0
)

My main.go file:

package main

import (
    ovh "github.com/lbrlabs/pulumi-ovh/sdk/go/ovh"
    "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        cfg := config.New(ctx, "")
        serviceName := "xxx"
        if param := cfg.Get("serviceName"); param != "" {
            serviceName = param
        }
        mykube, err := ovh.CloudProject.NewKube(ctx, "mykube", &ovh.CloudProject.KubeArgs{
            ServiceName: pulumi.String(serviceName),
            Name:        pulumi.String("my_desired_cluster"),
            Region:      pulumi.String("GRA5"),
        })
        if err != nil {
            return err
        }

        return nil
    })
}

If I don't follow the documentation and what the IDE tells me, here the new code but even not working code:

package main

import (
    "log"

    ovh "github.com/lbrlabs/pulumi-ovh/sdk/go/ovh"
    "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        cfg := config.New(ctx, "")
        serviceName := "xxx"
        if param := cfg.Get("serviceName"); param != "" {
            serviceName = param
        }

        //project := ovh.CloudProject.

        // Deploy a new Kubernetes cluster
        mykube, err := ovh.NewCloudProjectKube(ctx, "mykube", &ovh.CloudProjectKubeArgs{
            ServiceName: pulumi.String(serviceName),
            Name:        pulumi.String("my_desired_cluster"),
            Region:      pulumi.String("GRA5"),
        })
        if err != nil {
            return err
        }

        log.Println(mykube.Name)

        return nil
    })
}

FYI I want to do the same thing like with the cloud_project_kube resource in Terraform OVH provider: https://registry.terraform.io/providers/ovh/ovh/latest/docs/resources/cloud_project_kube

What am I missing?

Moreover, is it possible to add in this provider several useful and working examples, it can help a lot :).

Thanks