k8s

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 19 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"
	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",
	}
)

Functions

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)

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 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)

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