Merge pull request #42 from jenkins-x/dependabot/go_modules/k8s.io/client-go-0.26.2 chore(deps): bump k8s.io/client-go from 0.23.14 to 0.26.2
Merge pull request #42 from jenkins-x/dependabot/go_modules/k8s.io/client-go-0.26.2
chore(deps): bump k8s.io/client-go from 0.23.14 to 0.26.2
Used to create a kubernetes client from within a Kubernetes cluster or outside using ~/.kube/config
Here’s an example which also uses Jenkins X logging
import ( "github.com/jenkins-x/jx-kube-client/v3/pkg/kubeclient" "github.com/jenkins-x/jx-logging/v3/pkg/log" "k8s.io/client-go/kubernetes" ) func main() { f := kubeclient.NewFactory() cfg, err := f.CreateKubeConfig() if err != nil { log.Logger().Fatalf("failed to get kubernetes config: %v", err) } kubeClient, err := kubernetes.NewForConfig(cfg) if err != nil { log.Logger().Fatalf("error building kubernetes clientset: %v", err) } }
To change the location of the kube config use the following instead:
cfg, err := f.CreateKubeConfigFromCustomLocation(kubeConfigPath, kubeConfigFile)
Part of Jenkins X shared libraries.
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
jx-kube-client
Used to create a kubernetes client from within a Kubernetes cluster or outside using ~/.kube/config
Here’s an example which also uses Jenkins X logging
To change the location of the kube config use the following instead:
Part of Jenkins X shared libraries.