kube

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientConfigFromKubeConfig added in v0.2.10

func NewClientConfigFromKubeConfig(opts *options) (*rest.Config, error)

Types

type Client

type Client struct {
	KubeClient kubernetes.Interface
	CSIClient  csi.Interface
	// contains filtered or unexported fields
}

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) Close added in v0.2.11

func (c *Client) Close()

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
	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
	VolumeSnapshotsV1               *csitypes.VolumeSnapshotList
	VolumeSnapshotsV1Content        *csitypes.VolumeSnapshotContentList
	VolumeSnapshotsBeta             *csitypesbeta.VolumeSnapshotList
	VolumeSnapshotsBetaContent      *csitypesbeta.VolumeSnapshotContentList
	StorageClasses                  *st.StorageClassList
	DefaultStorageClass             *st.StorageClass
	MutatingWebhookConfigurations   *arv1.MutatingWebhookConfigurationList
	ValidatingWebhookConfigurations *arv1.ValidatingWebhookConfigurationList
	Namespaces                      *corev1.NamespaceList
	CronJobs                        *batchv1.CronJobList
}

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 InCluster added in v0.2.10

func InCluster() Option

InCluster indicates that we are accessing the Kubernetes API from a Pod

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