import ( restclient "k8s.io/client-go/rest" ) config := &restclient.Config{ Host: "https://api.kubernetes.com", ... }
import ( "os" restclient "k8s.io/client-go/rest" ) config := &restclient.Config{ ... Username: os.Getenv("KUBE_USER"), Password: os.Getenv("KUBE_PASS"), }
import ( "crypto/tls" "crypto/x509" restclient "k8s.io/client-go/rest" ) cert, err := tls.LoadX509KeyPair("client.crt", "client.key") if err != nil { panic(err) } caCertPool := x509.NewCertPool() caCert, _ := ioutil.ReadFile("ca.crt") caCertPool.AppendCertsFromPEM(caCert) config := &restclient.Config{ ... CertFile: "client.crt", KeyFile: "client.key", CAFile: "ca.crt", TLSClientConfig: restclient.TLSClientConfig{ CertData: cert.Certificate[0], KeyData: cert.PrivateKey, CAData: caCertPool, }, }In the above examples, we have used the restclient package from the k8s.io/kubernetes/pkg/client/restclient library to set up and pass the configuration object to other API client libraries, such as the k8s.io/client-go package, to interact with the Kubernetes API.