k8s

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: MIT Imports: 58 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = k8sClient{}
View Source
var ErrNoReadableKubeConfig = errors.New("unable to open kubeconfig file")

ErrNoReadableKubeConfig represents any error that prevents the client from opening a kubeconfig file.

Functions

func DecodeResource

func DecodeResource(b []byte) (k8stypes.Resource, error)

func EncodeResource

func EncodeResource(resource k8stypes.Resource) ([]byte, error)

func GetAllResources

func GetAllResources(clientset kubernetes.Interface, options ClientOptions) []k8stypes.Resource

GetAllResources gets all supported resources from the cluster

func GetAnnotations

func GetAnnotations(resource k8stypes.Resource) map[string]string

GetAnnotations returns the annotations at the pod level. If the resource does not have pods, then it returns the least-nested annotations

func GetContainers

func GetContainers(resource k8stypes.Resource) []*k8stypes.ContainerV1

func GetCronJobs

func GetCronJobs(clientset kubernetes.Interface, options ClientOptions) []k8stypes.Resource

GetCronJobs gets all CronJob resources from the cluster

func GetDaemonSets

func GetDaemonSets(clientset kubernetes.Interface, options ClientOptions) []k8stypes.Resource

GetDaemonSets gets all DaemonSet resources from the cluster

func GetDeployments

func GetDeployments(clientset kubernetes.Interface, options ClientOptions) []k8stypes.Resource

GetDeployments gets all Deployment resources from the cluster

func GetKubernetesVersion

func GetKubernetesVersion(clientset kubernetes.Interface) (*version.Info, error)

GetKubernetesVersion returns the kubernetes client version

func GetLabels

func GetLabels(resource k8stypes.Resource) map[string]string

GetLabels returns the labels at the pod level. If the resource does not have pods, then it returns the least-nested labels

func GetNamespaces

func GetNamespaces(clientset kubernetes.Interface, options ClientOptions) []k8stypes.Resource

GetNamespaces gets all Namespace resources from the cluster

func GetNetworkPolicies

func GetNetworkPolicies(clientset kubernetes.Interface, options ClientOptions) []k8stypes.Resource

GetNetworkPolicies gets all NetworkPolicy resources from the cluster

func GetObjectMeta

func GetObjectMeta(resource k8stypes.Resource) *metav1.ObjectMeta

GetObjectMeta returns the highest-level ObjectMeta

func GetPodObjectMeta

func GetPodObjectMeta(resource k8stypes.Resource) *metav1.ObjectMeta

GetPodObjectMeta returns the ObjectMeta at the pod level. If the resource does not have pods, then it returns the highest-level ObjectMeta

func GetPodSpec

func GetPodSpec(resource k8stypes.Resource) *k8stypes.PodSpecV1

GetPodSpec gets the PodSpec for a resource. Avoid using this function if you need support for Namespace or ServiceAccount resources, and write a helper functions in this package instead

func GetPodTemplateSpec

func GetPodTemplateSpec(resource k8stypes.Resource) *v1.PodTemplateSpec

GetPodTemplateSpec gets the PodTemplateSpec for a resource. Avoid using this function if you need support for Pod, Namespace, or ServiceAccount resources, and write a helper functions in this package instead

func GetPodTemplates

func GetPodTemplates(clientset kubernetes.Interface, options ClientOptions) []k8stypes.Resource

GetPodTemplates gets all PodTemplate resources from the cluster

func GetPods

func GetPods(clientset kubernetes.Interface, options ClientOptions) []k8stypes.Resource

GetPods gets all Pod resources from the cluster

func GetReplicationControllers

func GetReplicationControllers(clientset kubernetes.Interface, options ClientOptions) []k8stypes.Resource

GetReplicationControllers gets all ReplicationController resources from the cluster

func GetServiceAccounts added in v0.11.2

func GetServiceAccounts(clientset kubernetes.Interface, options ClientOptions) []k8stypes.Resource

GetServiceAccounts gets all ServiceAccount resources from the cluster

func GetStatefulSets

func GetStatefulSets(clientset kubernetes.Interface, options ClientOptions) []k8stypes.Resource

GetStatefulSets gets all StatefulSet resources from the cluster

func IsRunningInCluster

func IsRunningInCluster(client Client) bool

IsRunningInCluster returns true if kubeaudit is running inside a cluster

func NewFalse

func NewFalse() *bool

NewFalse returns a pointer to a boolean variable set to false

func NewKubeClientCluster

func NewKubeClientCluster(client Client) (*kubernetes.Clientset, error)

NewKubeClientCluster creates a new kube client for cluster mode

func NewKubeClientLocal

func NewKubeClientLocal(configPath string) (*kubernetes.Clientset, error)

NewKubeClientLocal creates a new kube client for local mode

func NewTrue

func NewTrue() *bool

NewTrue returns a pointer to a boolean variable set to true

Types

type Client

type Client interface {
	InClusterConfig() (*rest.Config, error)
}

Client abstracts the API to allow testing.

type ClientOptions

type ClientOptions struct {
	// Namespace filters resources by namespace. Defaults to all namespaces.
	Namespace string
}

Jump to

Keyboard shortcuts

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