k8s

package
v0.6.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	KindPod                   = "Pod"
	KindJob                   = "Job"
	KindCronJob               = "CronJob"
	KindReplicaSet            = "ReplicaSet"
	KindReplicationController = "ReplicationController"
	KindStatefulSet           = "StatefulSet"
	KindDaemonSet             = "DaemonSet"
	KindDeployment            = "Deployment"

	Deployments            = "deployments"
	ReplicaSets            = "replicasets"
	ReplicationControllers = "replicationcontrollers"
	StatefulSets           = "statefulsets"
	DaemonSets             = "daemonsets"
	CronJobs               = "cronjobs"
	Services               = "services"
	ServiceAccounts        = "serviceaccounts"
	Jobs                   = "jobs"
	Pods                   = "pods"
	ConfigMaps             = "configmaps"
	Roles                  = "roles"
	RoleBindings           = "rolebindings"
	NetworkPolicies        = "networkpolicies"
	Ingresses              = "ingresses"
	ResourceQuotas         = "resourcequotas"
	LimitRanges            = "limitranges"
	ClusterRoles           = "clusterroles"
	ClusterRoleBindings    = "clusterrolebindings"
	Nodes                  = "nodes"
)

Variables

View Source
var (
	UpstreamOrgName = map[string]string{
		"k8s.io":      "controller-manager,kubelet,apiserver,kubectl,kubernetes,kube-scheduler,kube-proxy,cloud-provider",
		"sigs.k8s.io": "secrets-store-csi-driver",
		"go.etcd.io":  "etcd/v3",
	}

	UpstreamRepoName = map[string]string{
		"kube-controller-manager":  "controller-manager",
		"kubelet":                  "kubelet",
		"kube-apiserver":           "apiserver",
		"kubectl":                  "kubectl",
		"kubernetes":               "kubernetes",
		"kube-scheduler":           "kube-scheduler",
		"kube-proxy":               "kube-proxy",
		"api server":               "apiserver",
		"etcd":                     "etcd/v3",
		"cloud-controller-manager": "cloud-provider",
		"secrets-store-csi-driver": "secrets-store-csi-driver",
	}
	CoreComponentPropertyType = map[string]string{
		"controller-manager": "controlPlane",
		"apiserver":          "controlPlane",
		"kube-scheduler":     "controlPlane",
		"etcd/v3":            "controlPlane",
		"cloud-provider":     "controlPlane",
		"kube-proxy":         "node",
	}
)

Functions

func GetContainer added in v0.6.0

func GetContainer(imageRef containerimage.Reference, imageName containerimage.Reference) (bom.Container, error)

func GetWildcardServers added in v0.5.7

func GetWildcardServers(auths map[string]docker.Auth) []string

func IsBuiltInWorkload added in v0.4.0

func IsBuiltInWorkload(resource *metav1.OwnerReference) bool

IsBuiltInWorkload returns true if the specified v1.OwnerReference is a built-in Kubernetes workload, false otherwise.

func IsClusterResource added in v0.2.2

func IsClusterResource(gvr schema.GroupVersionResource) bool

IsClusterResource returns if a GVR is a cluster resource

func MapContainerNamesToDockerAuths added in v0.5.7

func MapContainerNamesToDockerAuths(imageRef string, auths map[string]docker.Auth) (*docker.Auth, error)

func NodeInfo added in v0.6.0

func NodeInfo(node v1.Node) bom.NodeInfo

func PodInfo added in v0.6.0

func PodInfo(pod corev1.Pod, labelSelector string) (*bom.Component, error)

Types

type Cluster

type Cluster interface {
	// GetCurrentContext returns local kubernetes current-context
	GetCurrentContext() string
	// GetCurrentNamespace returns local kubernetes current namespace
	GetCurrentNamespace() string
	// GetDynamicClient returns a dynamic k8s client
	GetDynamicClient() dynamic.Interface
	// GetK8sClientSet returns a k8s client set
	GetK8sClientSet() *kubernetes.Clientset
	// GetGVRs returns cluster GroupVersionResource to query kubernetes, receives
	// a boolean to determine if returns namespaced GVRs only or all GVRs, unless
	// resources is passed to filter
	GetGVRs(bool, []string) ([]schema.GroupVersionResource, error)
	// GetGVR returns resource GroupVersionResource to query kubernetes, receives
	// a string with the resource kind
	GetGVR(string) (schema.GroupVersionResource, error)
	// CreatePkgBom returns a k8s client set
	CreateClusterBom(ctx context.Context) (*bom.Result, error)
	// GetClusterVersion return cluster git version
	GetClusterVersion() string
	// AuthByResource return image pull secrets by resource pod spec
	AuthByResource(resource unstructured.Unstructured) (map[string]docker.Auth, error)
}

Cluster interface represents the operations needed to scan a cluster

func GetCluster

func GetCluster(opts ...ClusterOption) (Cluster, error)

GetCluster returns a current configured cluster,

type ClusterOption added in v0.4.0

type ClusterOption func(*genericclioptions.ConfigFlags)

func WithBurst added in v0.6.1

func WithBurst(burst int) ClusterOption

func WithContext added in v0.4.0

func WithContext(context string) ClusterOption

Specify the context to use, if empty uses default

func WithKubeConfig added in v0.4.0

func WithKubeConfig(kubeConfig string) ClusterOption

kubeconfig can be used to specify the config file path (overrides KUBECONFIG env)

func WithQPS added in v0.6.1

func WithQPS(qps float32) ClusterOption

type ContainerImages added in v0.5.7

type ContainerImages map[string]string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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