k8s

package
v0.0.0-...-8540621 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyResources

func ApplyResources(clientset kubernetes.Interface, config *rest.Config, resources []*Resource, namespace string, allowedResources []string, allowUpdate bool) error

ApplyResources applies the following resources to the give namespace/cluster.

func ApplyYAML

func ApplyYAML(clientset kubernetes.Interface, config *rest.Config, namespace string, yamlFile io.Reader, allowUpdate bool) error

ApplyYAML does the equivalent of a kubectl apply for the given yaml. If allowUpdate is true, then we update the resource if it already exists.

func ApplyYAMLForResourceTypes

func ApplyYAMLForResourceTypes(clientset kubernetes.Interface, config *rest.Config, namespace string, yamlFile io.Reader, allowedResources []string, allowUpdate bool) error

ApplyYAMLForResourceTypes only applies the specified types in the given YAML file.

func ConvertResourceToYAML

func ConvertResourceToYAML(obj runtime.Object) (string, error)

ConvertResourceToYAML converts the given object to a YAML which can be applied.

func CreateConfigMapFromLiterals

func CreateConfigMapFromLiterals(namespace, name string, fromLiterals map[string]string) (*v1.ConfigMap, error)

CreateConfigMapFromLiterals creates a configmap in kubernetes using literals.

func CreateDockerConfigJSONSecret

func CreateDockerConfigJSONSecret(namespace, name, credsData string) (*v1.Secret, error)

CreateDockerConfigJSONSecret creates a secret in the docker config format. Currently the golang v1.Secret API doesn't perform the massaging of the credentials file that invoking kubectl with a docker-registry secret (like below) does.

func CreateGenericSecret

func CreateGenericSecret(namespace, name string, fromFiles map[string]string) (*v1.Secret, error)

CreateGenericSecret creates a generic secret in kubernetes.

func CreateGenericSecretFromLiterals

func CreateGenericSecretFromLiterals(namespace, name string, fromLiterals map[string]string) (*v1.Secret, error)

CreateGenericSecretFromLiterals creates a generic secret in kubernetes using literals.

func CreateTLSSecret

func CreateTLSSecret(namespace, name string, key string, cert string) (*v1.Secret, error)

CreateTLSSecret creates a TLS secret in kubernetes.

func DeleteAllResources

func DeleteAllResources(clientset kubernetes.Interface, ns string, selectors string) error

DeleteAllResources deletes all resources in the given namespace with the given selector.

func DeleteClusterRole

func DeleteClusterRole(clientset kubernetes.Interface, name string) error

DeleteClusterRole deletes the clusterrole with the given name.

func DeleteClusterRoleBinding

func DeleteClusterRoleBinding(clientset kubernetes.Interface, name string) error

DeleteClusterRoleBinding deletes the clusterrolebinding with the given name.

func DeleteConfigMap

func DeleteConfigMap(clientset kubernetes.Interface, name string, namespace string) error

DeleteConfigMap deletes the config map in the namespace with the given name.

func DeleteDaemonSets

func DeleteDaemonSets(clientset kubernetes.Interface, namespace string, selectors string) error

DeleteDaemonSets deletes all daemonsets in the namespace with the given selector.

func DeleteDeployments

func DeleteDeployments(clientset kubernetes.Interface, namespace string, selectors string) error

DeleteDeployments deletes all deployments in the namespace with the given selector.

func DeletePods

func DeletePods(clientset kubernetes.Interface, namespace string, selectors string) error

DeletePods deletes all pods in the namespace with the given selector.

func DeleteSecret

func DeleteSecret(clientset kubernetes.Interface, namespace, name string)

DeleteSecret deletes the given secret in kubernetes.

func DeleteServices

func DeleteServices(clientset kubernetes.Interface, namespace string, selectors string) error

DeleteServices deletes all services in the namespace with the given selector.

func GetClientAPIConfig

func GetClientAPIConfig() *clientcmdapi.Config

GetClientAPIConfig gets the config used for reading the current kube contexts.

func GetClientset

func GetClientset(config *rest.Config) *kubernetes.Clientset

GetClientset gets the clientset for the current kubernetes cluster.

func GetConfig

func GetConfig() *rest.Config

GetConfig gets the kubernetes rest config.

func GetDiscoveryClient

func GetDiscoveryClient(config *rest.Config) *discovery.DiscoveryClient

GetDiscoveryClient gets the discovery client for the current kubernetes cluster.

func GetKubeconfigPath

func GetKubeconfigPath() string

func GetPodAddr

func GetPodAddr(pod v1.Pod) string

func GetSecret

func GetSecret(clientset kubernetes.Interface, namespace, name string) *v1.Secret

GetSecret gets the secret in kubernetes.

func KeyValueStringToMap

func KeyValueStringToMap(labels string) (map[string]string, error)

KeyValueStringToMap converts a user-inputted label string (label1=value,label2=value2) into a string map. Supports values that contain commas, as long as they are surrounded by quotes. eg. (label1="valuea,valueb",label2=value2)

func KubectlCmd

func KubectlCmd(args ...string) *exec.Cmd

func OperatorLabelSelector

func OperatorLabelSelector() metav1.LabelSelector

OperatorLabelSelector returns a K8s selector that matches the label of the Pixie Operator.

func VizierLabelSelector

func VizierLabelSelector() metav1.LabelSelector

VizierLabelSelector returns a K8s selector that matches labels of all Pixie managed resources.

Types

type LogCollector

type LogCollector struct {
	// contains filtered or unexported fields
}

LogCollector collect logs for Pixie and cluster setup information.

func NewLogCollector

func NewLogCollector() *LogCollector

NewLogCollector creates a new log collector.

func (*LogCollector) CollectPixieLogs

func (c *LogCollector) CollectPixieLogs(fName string) error

CollectPixieLogs collects logs for all Pixie pods and write them to the zip file fName.

type ObjectDeleter

type ObjectDeleter struct {
	Namespace  string
	Clientset  *kubernetes.Clientset
	RestConfig *rest.Config
	Timeout    time.Duration
	// contains filtered or unexported fields
}

ObjectDeleter has methods to delete K8s objects and wait for them. This code is adopted from `kubectl delete`.

func (*ObjectDeleter) DeleteByLabel

func (o *ObjectDeleter) DeleteByLabel(selector string, resourceKinds ...string) (int, error)

DeleteByLabel delete objects that match the labels and specified by resourceKinds. Waits for deletion.

func (*ObjectDeleter) DeleteCustomObject

func (o *ObjectDeleter) DeleteCustomObject(resourceName, resourceValue string) error

DeleteCustomObject is used to delete a custom object (instantiation of CRD).

func (*ObjectDeleter) DeleteNamespace

func (o *ObjectDeleter) DeleteNamespace() error

DeleteNamespace removes the namespace and all objects within it. Waits for deletion to complete.

type Resource

type Resource struct {
	Object *unstructured.Unstructured
	GVK    *schema.GroupVersionKind
}

Resource is an unstructured resource object with a group kind mapping.

func GetResourcesFromYAML

func GetResourcesFromYAML(yamlFile io.Reader) ([]*Resource, error)

GetResourcesFromYAML parses the YAMLs into K8s resource objects that can be passed to the API.

Jump to

Keyboard shortcuts

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