GoogleCloudPlatform / gke-managed-certs

Managed Certificates for Kubernetes clusters using GCLB
Apache License 2.0
246 stars 32 forks source link

the server could not find the requested resource (get managedcertificates.networking.gke.io aa-example-certificate) #46

Closed collbrain closed 4 years ago

collbrain commented 4 years ago

I am trying to automate our kubernetes deployments and trying to validate if things works. In that respect, create a managed certificate on gke using following yaml. The creation of cert is fine and it is active.

apiVersion: networking.gke.io/v1beta1
kind: ManagedCertificate
metadata:
  name: aa-example-certificate
spec:
  domains:
    - aa.xxx.io

Now, i am trying to access this using following code.

imported "github.com/GoogleCloudPlatform/gke-managed-certs/e2e/client"

Add following piece of code

        var clients *client.Clients
        clients, err := client.New("default")
        if err != nil {
            return err
        }
        mcrt, err := clients.ManagedCertificate.Get("aa-example-certificate")
        if err != nil {
            return err
        }
        fmt.Println(mcrt)

Getting following error the server could not find the requested resource (get managedcertificates.networking.gke.io aa-example-certificate)

How to get cert info ?

krzykwas commented 4 years ago

This package you try to use relies on several environment variables that need to be set for it to work. You could set them and make it work, however I'd rather discourage you from using this package, as - even though it's hosted next to the „production” code, it's actually test code and I won't guarantee this client will keep working in the same (or any compatible) way in the future.

The canonical way to interact with the CRD ManagedCertificate is to directly use the API: https://github.com/GoogleCloudPlatform/gke-managed-certs/tree/master/pkg/clientgen

You could however set everything up similarly to how it is done in the e2e tests. The entrypoint is here: https://github.com/GoogleCloudPlatform/gke-managed-certs/blob/master/hack/e2e.sh

Setting up a client to talk to API server is a generic problem, not a problem specific to this project, so sorry, but I won't be giving detailed instructions.