k8s

package
v0.0.0-...-71727d8 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 20 Imported by: 1

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"
	NetworkPolicys         = "networkpolicies"
	Ingresss               = "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",
		"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",
		"secrets-store-csi-driver": "secrets-store-csi-driver",
	}
	CoreComponentPropertyType = map[string]string{
		"controller-manager": "controlPlane",
		"apiserver":          "controlPlane",
		"kube-scheduler":     "controlPlane",
		"etcd/v3":            "controlPlane",
		"kube-proxy":         "node",
	}
)

Functions

func GetContainer

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

func GetWildcardServers

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

func IsBuiltInWorkload

func IsBuiltInWorkload(resource *metav1.OwnerReference) bool

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

func IsClusterResource

func IsClusterResource(gvr schema.GroupVersionResource) bool

IsClusterResource returns if a GVR is a cluster resource

func MapContainerNamesToDockerAuths

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

func NodeInfo

func NodeInfo(node v1.Node) bom.NodeInfo

func PodInfo

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

type ClusterOption func(*genericclioptions.ConfigFlags)

func WithContext

func WithContext(context string) ClusterOption

Specify the context to use, if empty uses default

func WithKubeConfig

func WithKubeConfig(kubeConfig string) ClusterOption

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

type ContainerImages

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