kube

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	KubeClient kubernetes.Interface
}

Client encapsulates a client for a Kubernetes cluster.

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient builds a kubernetes client to interact with the live cluster. The kube config file path or the kubeconfig yaml must be specified If not specified, defaults are assumed - configPath: ~/.kube/config, configContext: current context

func (*Client) FetchObjects

func (c *Client) FetchObjects(ctx context.Context, filter ObjectFilter) (*Objects, error)

FetchObjects returns the objects from a Kubernetes cluster. ctx is currently unused during API calls. More info: https://github.com/kubernetes/community/pull/1166

type Identifier

type Identifier struct {
	Name      string
	Namespace string
}

Identifier is used to identify a specific namspace scoped object.

type ObjectFilter added in v0.1.4

type ObjectFilter struct {
	IncludeNamespace string
	ExcludeNamespace string
}

ObjectFilter stores k8s object's fields that needs to be included or excluded while running checks

func NewObjectFilter added in v0.1.4

func NewObjectFilter(includeNamespace, excludeNamespace string) (ObjectFilter, error)

NewObjectFilter is a constructor to initialize an instance of ObjectFilter

func (ObjectFilter) NamespaceOptions added in v0.1.4

func (f ObjectFilter) NamespaceOptions(opts metav1.ListOptions) metav1.ListOptions

NamespaceOptions returns ListOptions for filtering by namespace

type Objects

type Objects struct {
	Nodes                           *corev1.NodeList
	PersistentVolumes               *corev1.PersistentVolumeList
	ComponentStatuses               *corev1.ComponentStatusList
	SystemNamespace                 *corev1.Namespace
	Pods                            *corev1.PodList
	PodTemplates                    *corev1.PodTemplateList
	PersistentVolumeClaims          *corev1.PersistentVolumeClaimList
	ConfigMaps                      *corev1.ConfigMapList
	Services                        *corev1.ServiceList
	Secrets                         *corev1.SecretList
	ServiceAccounts                 *corev1.ServiceAccountList
	ResourceQuotas                  *corev1.ResourceQuotaList
	LimitRanges                     *corev1.LimitRangeList
	MutatingWebhookConfigurations   *ar.MutatingWebhookConfigurationList
	ValidatingWebhookConfigurations *ar.ValidatingWebhookConfigurationList
	Namespaces                      *corev1.NamespaceList
}

Objects encapsulates all the objects from a Kubernetes cluster.

type Option

type Option func(*options) error

Option function that allows injecting options while building kube.Client.

func WithConfigFile

func WithConfigFile(path string) Option

WithConfigFile returns an Option injected with a config file path.

func WithKubeContext

func WithKubeContext(kubeContext string) Option

WithKubeContext returns an Option injected with a kubernetes context.

func WithMergedConfigFiles added in v0.1.1

func WithMergedConfigFiles(paths []string) Option

WithMergedConfigFiles returns an Option injected with value of $KUBECONFIG

func WithTimeout

func WithTimeout(t time.Duration) Option

WithTimeout returns an Option injected with a timeout option while building client.

func WithTransportWrapper added in v0.1.3

func WithTransportWrapper(f TransportWrapper) Option

WithTransportWrapper allows wrapping the underlying http.RoundTripper

func WithYaml

func WithYaml(yaml []byte) Option

WithYaml returns an Option injected with a kubeconfig yaml.

type TransportWrapper added in v0.1.3

type TransportWrapper = func(http.RoundTripper) http.RoundTripper

TransportWrapper wraps an http.RoundTripper

Jump to

Keyboard shortcuts

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