Documentation ¶
Overview ¶
Package kubectl provides a kubectl-like interface for Kubernetes. Functions defined here should not make use of os/exec.
Index ¶
- type Kubectl
- func (k *Kubectl) AddNodeSelectorsToDeployment(ctx context.Context, selectors map[string]string, name string, ...) error
- func (k *Kubectl) AnnotateNode(ctx context.Context, nodeName, annotationKey, annotationValue string) error
- func (k *Kubectl) ApplyCRD(ctx context.Context, rawCRD []byte) error
- func (k *Kubectl) CreateConfigMap(ctx context.Context, configMap *corev1.ConfigMap) error
- func (k *Kubectl) EnforceCoreDNSSpread(ctx context.Context) error
- func (k *Kubectl) GetCR(ctx context.Context, gvr schema.GroupVersionResource, name string) (*unstructured.Unstructured, error)
- func (k *Kubectl) GetConfigMap(ctx context.Context, namespace, name string) (*corev1.ConfigMap, error)
- func (k *Kubectl) GetNodes(ctx context.Context) ([]corev1.Node, error)
- func (k *Kubectl) Initialize(kubeconfig []byte) error
- func (k *Kubectl) KubernetesVersion() (string, error)
- func (k *Kubectl) ListAllNamespaces(ctx context.Context) (*corev1.NamespaceList, error)
- func (k *Kubectl) ListCRDs(ctx context.Context) ([]apiextensionsv1.CustomResourceDefinition, error)
- func (k *Kubectl) ListCRs(ctx context.Context, gvr schema.GroupVersionResource) ([]unstructured.Unstructured, error)
- func (k *Kubectl) PatchFirstNodePodCIDR(ctx context.Context, firstNodePodCIDR string) error
- func (k *Kubectl) UpdateCR(ctx context.Context, gvr schema.GroupVersionResource, ...) (*unstructured.Unstructured, error)
- func (k *Kubectl) UpdateConfigMap(ctx context.Context, configMap *corev1.ConfigMap) (*corev1.ConfigMap, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kubectl ¶
type Kubectl struct { kubernetes.Interface // contains filtered or unexported fields }
Kubectl implements functionality of the Kubernetes "kubectl" tool.
func NewFromConfig ¶ added in v2.11.0
NewFromConfig returns a Kubectl client using the given kubeconfig.
func NewUninitialized ¶ added in v2.11.0
func NewUninitialized() *Kubectl
NewUninitialized returns an empty Kubectl client. Initialize needs to be called before the client is usable.
func (*Kubectl) AddNodeSelectorsToDeployment ¶
func (k *Kubectl) AddNodeSelectorsToDeployment(ctx context.Context, selectors map[string]string, name string, namespace string) error
AddNodeSelectorsToDeployment adds K8s selectors to the deployment, identified by name and namespace.
func (*Kubectl) AnnotateNode ¶
func (k *Kubectl) AnnotateNode(ctx context.Context, nodeName, annotationKey, annotationValue string) error
AnnotateNode adds the provided annotations to the node, identified by name.
func (*Kubectl) ApplyCRD ¶
ApplyCRD updates the given CRD by parsing it, querying it's version from the cluster and finally updating it.
func (*Kubectl) CreateConfigMap ¶
CreateConfigMap creates the provided configmap.
func (*Kubectl) EnforceCoreDNSSpread ¶ added in v2.9.0
EnforceCoreDNSSpread adds a pod anti-affinity to the CoreDNS deployment to ensure that CoreDNS pods are spread across nodes.
func (*Kubectl) GetCR ¶ added in v2.11.0
func (k *Kubectl) GetCR(ctx context.Context, gvr schema.GroupVersionResource, name string) (*unstructured.Unstructured, error)
GetCR retrieves a Custom Resource given it's name and group version resource.
func (*Kubectl) GetConfigMap ¶ added in v2.11.0
func (k *Kubectl) GetConfigMap(ctx context.Context, namespace, name string) (*corev1.ConfigMap, error)
GetConfigMap returns a ConfigMap given it's name and namespace.
func (*Kubectl) Initialize ¶
Initialize sets sets all required fields so the Kubectl client can be used.
func (*Kubectl) KubernetesVersion ¶ added in v2.11.0
KubernetesVersion returns the Kubernetes version of the cluster.
func (*Kubectl) ListAllNamespaces ¶
ListAllNamespaces returns all namespaces in the cluster.
func (*Kubectl) ListCRDs ¶ added in v2.11.0
func (k *Kubectl) ListCRDs(ctx context.Context) ([]apiextensionsv1.CustomResourceDefinition, error)
ListCRDs retrieves all custom resource definitions currently installed in the cluster.
func (*Kubectl) ListCRs ¶ added in v2.11.0
func (k *Kubectl) ListCRs(ctx context.Context, gvr schema.GroupVersionResource) ([]unstructured.Unstructured, error)
ListCRs retrieves all objects for a given CRD.
func (*Kubectl) PatchFirstNodePodCIDR ¶ added in v2.10.0
PatchFirstNodePodCIDR patches the firstNodePodCIDR of the first control-plane node for Cilium.
func (*Kubectl) UpdateCR ¶ added in v2.11.0
func (k *Kubectl) UpdateCR(ctx context.Context, gvr schema.GroupVersionResource, obj *unstructured.Unstructured) (*unstructured.Unstructured, error)
UpdateCR updates a Custom Resource given it's and group version resource.