Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertUnstructuredSliceToMap(unstructuredSlice []unstructured.Unstructured) []map[string]interface{}
- func FilterOutOwneredResources(result []unstructured.Unstructured) []unstructured.Unstructured
- func GetClusterName() string
- func GetCurrentContext() *api.Context
- func GetDefaultNamespace() string
- func GetGroupVersionResource(resource string) (schema.GroupVersionResource, error)
- func GetK8sConfig() *restclient.Config
- func GetResourceTriplets(group, version, resource string) []string
- func IsAgentCompatibleAnnotation(annotations map[string]string) *bool
- func IsAgentCompatibleLabel(labels map[string]string) *bool
- func IsAttached(labels map[string]string) *bool
- func IsConnectedToCluster() bool
- func IsLabel(labels map[string]string, key string) *bool
- func IsNamespaceScope(apiGroup, resource string) bool
- func IsStringInSlice(slice []string, val string) bool
- func JoinResourceTriplets(group, version, resource string) string
- func LoadK8sConfig() error
- func ResourceGroupToSlice(group, version, resource string) []string
- func ResourceGroupToString(group, version, resource string) []string
- func SelectorToString(ls labels.Set) string
- func SetAgentCompatibleAnnotation(annotations map[string]string, val bool)
- func SetAgentCompatibleLabel(labels map[string]string, val bool)
- func SetLabel(labels map[string]string, key string, val bool)
- func StringInSlice(strSlice []string, str string) int
- func StringToResourceGroup(str string) (string, string, string)
- func V1AllClusterWithCompromisedRegistriesMock() *unstructured.UnstructuredList
- func V1KubeSystemNamespaceMock() *unstructured.UnstructuredList
- type IWorkload
- type KubernetesApi
- func (k8sAPI *KubernetesApi) CalculateWorkloadParentRecursive(workload IWorkload) (string, string, error)
- func (k8sAPI *KubernetesApi) CreateWorkload(workload IWorkload) (IWorkload, error)
- func (k8sAPI *KubernetesApi) DeleteWorkloadByWlid(wlid string) error
- func (k8sAPI *KubernetesApi) GetNamespace(ns string) (IWorkload, error)
- func (k8sAPI *KubernetesApi) GetWorkload(namespace, kind, name string) (IWorkload, error)
- func (k8sAPI *KubernetesApi) GetWorkloadByWlid(wlid string) (IWorkload, error)
- func (k8sAPI *KubernetesApi) ListAllWorkload() ([]IWorkload, error)
- func (k8sAPI *KubernetesApi) ListAttachedPods(namespace string) ([]corev1.Pod, error)
- func (k8sAPI *KubernetesApi) ListPods(namespace string, podLabels map[string]string) ([]corev1.Pod, error)
- func (k8sAPI *KubernetesApi) ListWorkloads(groupVersionResource *schema.GroupVersionResource, namespace string, ...) ([]IWorkload, error)
- func (k8sAPI *KubernetesApi) ListWorkloads2(namespace, kind string) ([]IWorkload, error)
- func (k8sAPI *KubernetesApi) ResourceInterface(resource *schema.GroupVersionResource, namespace string) dynamic.ResourceInterface
- func (k8sAPI *KubernetesApi) UpdateWorkload(workload IWorkload) (IWorkload, error)
Constants ¶
View Source
const ValueNotFound = -1
Variables ¶
View Source
var ConnectedToCluster = true
View Source
var GroupsClusterScope = []string{}
View Source
var K8SConfig *restclient.Config
K8SConfig pointer to k8s config
View Source
var ResourceClusterScope = []string{"nodes", "namespaces", "podsecuritypolicies", "clusterroles", "clusterrolebindings", "validatingwebhookconfigurations", "mutatingwebhookconfigurations"}
View Source
var ResourceGroupMapping = map[string]string{
"services": "/v1",
"pods": "/v1",
"replicationcontrollers": "/v1",
"podtemplates": "/v1",
"namespaces": "/v1",
"nodes": "/v1",
"configmaps": "/v1",
"secrets": "/v1",
"serviceaccounts": "/v1",
"persistentvolumeclaims": "/v1",
"limitranges": "/v1",
"resourcequotas": "/v1",
"daemonsets": "apps/v1",
"deployments": "apps/v1",
"replicasets": "apps/v1",
"statefulsets": "apps/v1",
"controllerrevisions": "apps/v1",
"jobs": "batch/v1",
"cronjobs": "batch/v1",
"horizontalpodautoscalers": "autoscaling/v1",
"ingresses": "extensions/v1beta1",
"podsecuritypolicies": "policy/v1beta1",
"poddisruptionbudgets": "policy/v1",
"networkpolicies": "networking.k8s.io/v1",
"clusterroles": "rbac.authorization.k8s.io/v1",
"clusterrolebindings": "rbac.authorization.k8s.io/v1",
"roles": "rbac.authorization.k8s.io/v1",
"rolebindings": "rbac.authorization.k8s.io/v1",
"mutatingwebhookconfigurations": "admissionregistration.k8s.io/v1",
"validatingwebhookconfigurations": "admissionregistration.k8s.io/v1",
}
https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#-strong-api-groups-strong-
View Source
var RunningIncluster bool
RunningIncluster whether running in cluster
Functions ¶
func ConvertUnstructuredSliceToMap ¶
func ConvertUnstructuredSliceToMap(unstructuredSlice []unstructured.Unstructured) []map[string]interface{}
func FilterOutOwneredResources ¶
func FilterOutOwneredResources(result []unstructured.Unstructured) []unstructured.Unstructured
func GetClusterName ¶
func GetClusterName() string
func GetCurrentContext ¶
func GetDefaultNamespace ¶
func GetDefaultNamespace() string
func GetGroupVersionResource ¶
func GetGroupVersionResource(resource string) (schema.GroupVersionResource, error)
func GetK8sConfig ¶
func GetK8sConfig() *restclient.Config
GetK8sConfig get config. load if not loaded yet
func GetResourceTriplets ¶
func IsAgentCompatibleLabel ¶
func IsAttached ¶
func IsConnectedToCluster ¶
func IsConnectedToCluster() bool
func IsNamespaceScope ¶
func IsStringInSlice ¶
func JoinResourceTriplets ¶
func LoadK8sConfig ¶
func LoadK8sConfig() error
LoadK8sConfig load config from local file or from cluster
func ResourceGroupToSlice ¶
func ResourceGroupToString ¶
DEPRECATED
func SelectorToString ¶
String returns all labels listed as a human readable string. Conveniently, exactly the format that ParseSelector takes.
func SetAgentCompatibleLabel ¶
func StringInSlice ¶
func V1AllClusterWithCompromisedRegistriesMock ¶
func V1AllClusterWithCompromisedRegistriesMock() *unstructured.UnstructuredList
func V1KubeSystemNamespaceMock ¶
func V1KubeSystemNamespaceMock() *unstructured.UnstructuredList
Types ¶
type IWorkload ¶
type IWorkload workloadinterface.IWorkload
type KubernetesApi ¶
type KubernetesApi struct {
KubernetesClient kubernetes.Interface
DynamicClient dynamic.Interface
Context context.Context
}
KubernetesApi -
func (*KubernetesApi) CalculateWorkloadParentRecursive ¶
func (k8sAPI *KubernetesApi) CalculateWorkloadParentRecursive(workload IWorkload) (string, string, error)
func (*KubernetesApi) CreateWorkload ¶
func (k8sAPI *KubernetesApi) CreateWorkload(workload IWorkload) (IWorkload, error)
func (*KubernetesApi) DeleteWorkloadByWlid ¶
func (k8sAPI *KubernetesApi) DeleteWorkloadByWlid(wlid string) error
func (*KubernetesApi) GetNamespace ¶
func (k8sAPI *KubernetesApi) GetNamespace(ns string) (IWorkload, error)
func (*KubernetesApi) GetWorkload ¶
func (k8sAPI *KubernetesApi) GetWorkload(namespace, kind, name string) (IWorkload, error)
func (*KubernetesApi) GetWorkloadByWlid ¶
func (k8sAPI *KubernetesApi) GetWorkloadByWlid(wlid string) (IWorkload, error)
func (*KubernetesApi) ListAllWorkload ¶
func (k8sAPI *KubernetesApi) ListAllWorkload() ([]IWorkload, error)
func (*KubernetesApi) ListAttachedPods ¶
func (k8sAPI *KubernetesApi) ListAttachedPods(namespace string) ([]corev1.Pod, error)
func (*KubernetesApi) ListWorkloads ¶
func (k8sAPI *KubernetesApi) ListWorkloads(groupVersionResource *schema.GroupVersionResource, namespace string, podLabels, fieldSelector map[string]string) ([]IWorkload, error)
func (*KubernetesApi) ListWorkloads2 ¶
func (k8sAPI *KubernetesApi) ListWorkloads2(namespace, kind string) ([]IWorkload, error)
func (*KubernetesApi) ResourceInterface ¶
func (k8sAPI *KubernetesApi) ResourceInterface(resource *schema.GroupVersionResource, namespace string) dynamic.ResourceInterface
func (*KubernetesApi) UpdateWorkload ¶
func (k8sAPI *KubernetesApi) UpdateWorkload(workload IWorkload) (IWorkload, error)
Click to show internal directories.
Click to hide internal directories.