Documentation ¶
Index ¶
- func CalculateTotalPodMilliResourceRequests(pods []corev1.Pod) (int64, int64)
- type ClusterResources
- type KubeClient
- func (kc *KubeClient) CreateFromFile(file ManifestFile, installationName string) error
- func (kc *KubeClient) CreateFromFiles(files []ManifestFile) error
- func (kc *KubeClient) CreateOrUpdateNamespace(namespaceName string) (*corev1.Namespace, error)
- func (kc *KubeClient) CreateOrUpdateNamespaces(namespaceNames []string) ([]*corev1.Namespace, error)
- func (kc *KubeClient) CreateOrUpdateSecret(namespace string, secret *corev1.Secret) (metav1.Object, error)
- func (kc *KubeClient) DeleteNamespaces(namespaceNames []string) error
- func (kc *KubeClient) GetConfig() *rest.Config
- func (kc *KubeClient) GetNamespace(namespaceName string) (*corev1.Namespace, error)
- func (kc *KubeClient) GetNamespaces(namespaceNames []string) ([]*corev1.Namespace, error)
- func (kc *KubeClient) GetPodsFromDaemonSet(namespace, daemonSetName string) (*corev1.PodList, error)
- func (kc *KubeClient) GetPodsFromDeployment(namespace, deploymentName string) (*corev1.PodList, error)
- func (kc *KubeClient) GetPodsFromStatefulset(namespace, statefulSetName string) (*corev1.PodList, error)
- func (kc *KubeClient) GetSecrets(nameSpace string, secretsNames []string) ([]*corev1.Secret, error)
- func (kc *KubeClient) PatchPodsDaemonSet(namespace, daemonSetName string, payload []PatchStringValue) error
- func (kc *KubeClient) RemoteCommand(method string, url *url.URL) ([]byte, error)
- func (kc *KubeClient) UpdateStorageClassVolumeBindingMode(class string) (metav1.Object, error)
- func (kc *KubeClient) WaitForPodRunning(ctx context.Context, namespace, podName string) (*corev1.Pod, error)
- type ManifestFile
- type PatchStringValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClusterResources ¶
type ClusterResources struct { TotalNodeCount int64 SkippedNodeCount int64 WorkerNodeCount int64 MilliTotalCPU int64 MilliUsedCPU int64 MilliTotalMemory int64 MilliUsedMemory int64 TotalPodCount int64 UsedPodCount int64 }
ClusterResources is a snapshot of a cluster's total and currently-used resources.
func (*ClusterResources) CalculateCPUPercentUsed ¶
func (r *ClusterResources) CalculateCPUPercentUsed(additional int64) int
CalculateCPUPercentUsed calculates the CPU usage percentage of a cluster with an optional additional load. Pass in 0 to calculate the current CPU usage of the cluster.
func (*ClusterResources) CalculateMemoryPercentUsed ¶
func (r *ClusterResources) CalculateMemoryPercentUsed(additional int64) int
CalculateMemoryPercentUsed calculates the memory usage percentage of a cluster with an optional additional load. Pass in 0 to calculate the current memory usage of the cluster.
func (*ClusterResources) CalculatePodCountPercentUsed ¶ added in v0.58.0
func (r *ClusterResources) CalculatePodCountPercentUsed(additional int64) int
CalculatePodCountPercentUsed calculates the pod count usage percentage of a cluster with an optional additional load. Pass in 0 to calculate the current pod count usage of the cluster.
type KubeClient ¶
type KubeClient struct { Clientset kubernetes.Interface ApixClientset apixclient.Interface MattermostClientsetV1Alpha mmclientv1alpha1.Interface MattermostClientsetV1Beta mmclientv1beta1.Interface MonitoringClientsetV1 monitoringclientV1.Interface SlothClientsetV1 slothclientV1.Interface KubeagClientSet kubeagclient.Interface // contains filtered or unexported fields }
KubeClient interfaces with a Kubernetes cluster in the same way kubectl would.
func NewFromConfig ¶
func NewFromConfig(config *rest.Config, logger log.FieldLogger) (*KubeClient, error)
NewFromConfig takes in an already created Kubernetes config object, and returns a KubeClient for accessing the kubernetes API
func NewFromFile ¶
func NewFromFile(configLocation string, logger log.FieldLogger) (*KubeClient, error)
NewFromFile returns a new KubeClient for accessing the kubernetes API. (previously named 'New')
func (*KubeClient) CreateFromFile ¶
func (kc *KubeClient) CreateFromFile(file ManifestFile, installationName string) error
CreateFromFile will create the Kubernetes resources in the provided file.
The current behavior leads to the create being attempted on all resources in the provided file. An error is returned if any of the create actions failed. This process equates to running `kubectl create -f FILENAME`.
func (*KubeClient) CreateFromFiles ¶
func (kc *KubeClient) CreateFromFiles(files []ManifestFile) error
CreateFromFiles will create Kubernetes resources from the provided manifest files.
func (*KubeClient) CreateOrUpdateNamespace ¶
func (kc *KubeClient) CreateOrUpdateNamespace(namespaceName string) (*corev1.Namespace, error)
CreateOrUpdateNamespace creates or update a namespace
func (*KubeClient) CreateOrUpdateNamespaces ¶
func (kc *KubeClient) CreateOrUpdateNamespaces(namespaceNames []string) ([]*corev1.Namespace, error)
CreateOrUpdateNamespaces creates or update kubernetes namespaces
Any errors will be returned immediately and the remaining namespaces will be skipped.
func (*KubeClient) CreateOrUpdateSecret ¶
func (kc *KubeClient) CreateOrUpdateSecret(namespace string, secret *corev1.Secret) (metav1.Object, error)
CreateOrUpdateSecret creates or update a secret
func (*KubeClient) DeleteNamespaces ¶
func (kc *KubeClient) DeleteNamespaces(namespaceNames []string) error
DeleteNamespaces deletes kubernetes namespaces.
Any errors will be returned immediately and the remaining namespaces will be skipped.
func (*KubeClient) GetConfig ¶
func (kc *KubeClient) GetConfig() *rest.Config
GetConfig exposes the rest.Config for use with other k8s packages.
func (*KubeClient) GetNamespace ¶ added in v0.47.0
func (kc *KubeClient) GetNamespace(namespaceName string) (*corev1.Namespace, error)
GetNamespace returns a kubernetes namespace object if it exists.
func (*KubeClient) GetNamespaces ¶
func (kc *KubeClient) GetNamespaces(namespaceNames []string) ([]*corev1.Namespace, error)
GetNamespaces returns a list of kubernetes namespace objects if they exist.
Any errors will be returned immediately and the remaining namespaces will be skipped.
func (*KubeClient) GetPodsFromDaemonSet ¶
func (kc *KubeClient) GetPodsFromDaemonSet(namespace, daemonSetName string) (*corev1.PodList, error)
GetPodsFromDaemonSet gets the pods that belong to a given daemonset.
func (*KubeClient) GetPodsFromDeployment ¶
func (kc *KubeClient) GetPodsFromDeployment(namespace, deploymentName string) (*corev1.PodList, error)
GetPodsFromDeployment gets the pods that belong to a given deployment.
func (*KubeClient) GetPodsFromStatefulset ¶
func (kc *KubeClient) GetPodsFromStatefulset(namespace, statefulSetName string) (*corev1.PodList, error)
GetPodsFromStatefulset gets the pods that belong to a given stateful set.
func (*KubeClient) GetSecrets ¶
GetSecrets returns a list of kubernetes secret objects if they exist.
Any errors will be returned immediately and the remaining secrets will be skipped.
func (*KubeClient) PatchPodsDaemonSet ¶ added in v0.46.1
func (kc *KubeClient) PatchPodsDaemonSet(namespace, daemonSetName string, payload []PatchStringValue) error
PatchPodsDaemonSet patches the pods that belong to a given daemonset with a given payload.
func (*KubeClient) RemoteCommand ¶
RemoteCommand executes a kubernetes command against a remote cluster.
func (*KubeClient) UpdateStorageClassVolumeBindingMode ¶
func (kc *KubeClient) UpdateStorageClassVolumeBindingMode(class string) (metav1.Object, error)
UpdateStorageClassVolumeBindingMode updates the storage class volume binding mode from immediate to WaitForFirstConsumer.
func (*KubeClient) WaitForPodRunning ¶
func (kc *KubeClient) WaitForPodRunning(ctx context.Context, namespace, podName string) (*corev1.Pod, error)
WaitForPodRunning will poll a given kubernetes pod at a regular interval for it to enter the 'Running' state. If the pod fails to become ready before the provided timeout then an error will be returned.
type ManifestFile ¶
ManifestFile is a file containing kubernetes resources.
func (*ManifestFile) Basename ¶
func (f *ManifestFile) Basename() string
Basename returns the base filename of the manifest file.
type PatchStringValue ¶ added in v0.46.1
type PatchStringValue struct { Op string `json:"op"` Path string `json:"path"` Value string `json:"value"` }
PatchStringValue is a helper struct for patch operations