kube

package
v0.0.0-...-a81bd29 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 27 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPodSpec

func GetPodSpec(yaml map[string]interface{}) interface{}

GetPodSpec looks inside arbitrary YAML for a PodSpec

func GetPodTemplate

func GetPodTemplate(yaml map[string]interface{}) (podTemplate interface{}, err error)

GetPodTemplate looks inside arbitrary YAML for a Pod template, containing fields `spec.containers`. For example, it returns the `spec.template` level of a Kubernetes Deployment yaml.

func SerializeContainer

func SerializeContainer(container *corev1.Container) (map[string]interface{}, error)

SerializeContainer converts a typed Container into a map[string]interface{}

func SerializePod

func SerializePod(pod *corev1.Pod) (map[string]interface{}, error)

SerializePod converts a typed Pod into a map[string]interface{}

func SerializePodSpec

func SerializePodSpec(pod *corev1.PodSpec) (map[string]interface{}, error)

SerializePodSpec converts a typed PodSpec into a map[string]interface{}

Types

type GenericResource

type GenericResource struct {
	Kind               string
	ObjectMeta         kubeAPIMetaV1.Object
	Resource           unstructured.Unstructured
	PodSpec            *kubeAPICoreV1.PodSpec
	PodTemplate        interface{}
	OriginalObjectJSON []byte
	OriginalObjectYAML []byte
}

GenericResource is a base implementation with some free methods for inherited structs

func NewGenericResourceFromBytes

func NewGenericResourceFromBytes(contentBytes []byte) (GenericResource, error)

NewGenericResourceFromBytes parses a generic kubernetes resource

func NewGenericResourceFromPod

func NewGenericResourceFromPod(podResource kubeAPICoreV1.Pod, originalObject interface{}) (GenericResource, error)

NewGenericResourceFromPod builds a new workload for a given Pod without looking at parents

func NewGenericResourceFromUnstructured

func NewGenericResourceFromUnstructured(unst unstructured.Unstructured, podSpecMap interface{}) (GenericResource, error)

NewGenericResourceFromUnstructured creates a workload from an unstructured.Unstructured

func ResolveControllerFromPod

func ResolveControllerFromPod(ctx context.Context, podResource kubeAPICoreV1.Pod, dynamicClient dynamic.Interface, restMapper meta.RESTMapper, objectCache map[string]unstructured.Unstructured) (GenericResource, error)

ResolveControllerFromPod builds a new workload for a given Pod

type ResourceProvider

type ResourceProvider struct {
	ServerVersion string
	CreationTime  time.Time
	SourceName    string
	SourceType    string
	Nodes         []corev1.Node
	Namespaces    []corev1.Namespace
	Resources     resourceKindMap
}

ResourceProvider contains k8s resources to be audited

func CreateResourceProvider

func CreateResourceProvider(ctx context.Context, directory, workload string, c conf.Configuration) (*ResourceProvider, error)

CreateResourceProvider returns a new ResourceProvider object to interact with k8s resources

func CreateResourceProviderFromAPI

func CreateResourceProviderFromAPI(ctx context.Context, kube kubernetes.Interface, clusterName string, dynamic dynamic.Interface, c conf.Configuration) (*ResourceProvider, error)

CreateResourceProviderFromAPI creates a new ResourceProvider from an existing k8s interface

func CreateResourceProviderFromCluster

func CreateResourceProviderFromCluster(ctx context.Context, c conf.Configuration) (*ResourceProvider, error)

CreateResourceProviderFromCluster creates a new ResourceProvider using live data from a cluster

func CreateResourceProviderFromPath

func CreateResourceProviderFromPath(directory string) (*ResourceProvider, error)

CreateResourceProviderFromPath returns a new ResourceProvider using the YAML files in a directory

func CreateResourceProviderFromResource

func CreateResourceProviderFromResource(ctx context.Context, workload string) (*ResourceProvider, error)

CreateResourceProviderFromResource creates a new ResourceProvider that just contains one workload

func CreateResourceProviderFromYaml

func CreateResourceProviderFromYaml(yamlContent string) (*ResourceProvider, error)

CreateResourceProviderFromYaml returns a new ResourceProvider using the yaml

Jump to

Keyboard shortcuts

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