You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 周之前
123456789101112131415161718
  1. package k8sutil
  2. import (
  3. "k8s.io/client-go/kubernetes"
  4. "k8s.io/client-go/rest"
  5. )
  6. func GetK8sClient() (*kubernetes.Clientset, error) {
  7. config, err := rest.InClusterConfig()
  8. if err != nil {
  9. return nil, err
  10. }
  11. k8sClient, err := kubernetes.NewForConfig(config)
  12. if err != nil {
  13. return nil, err
  14. }
  15. return k8sClient, nil
  16. }