jx-kube-client

command module
v3.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

jx-kube-client

Go Report Card

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.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL