I am trying to use the kubernetes go-client with cloud.google.com/go/container. I create the cluster using the google cloud go container package, then I want to deploy on that cluster using go-client. The out of cluster example given by the go-client uses the kube config file to get the credentials for the cluster. But since I just created this cluster within my application I don’t have that config file.
How can I setup a “k8s.io/client-go/rest” config with a "google.golang.org/genproto/googleapis/container/v1" Cluster? What are the required fields? The code below is what I currently have (without showing the actual CA certificate).
func getConfig(cluster *containerproto.Cluster) *rest.Config {
return &rest.Config{
Host: "https://" + cluster.GetEndpoint(),
TLSClientConfig: rest.TLSClientConfig{
Insecure: false,
CAData: []byte(`-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----`),
},
}
It results in this error: x509: certificate signed by unknown authority. So there is obviously something missing. Any other approach is more than welcome! Thanks in advance