Documentation ¶
Index ¶
- func CalculateTotalPodMilliResourceRequests(pods *corev1.PodList) (int64, int64)
- type ClusterResources
- type KubeClient
- func (kc *KubeClient) CreateFromFile(file ManifestFile) error
- func (kc *KubeClient) CreateFromFiles(files []ManifestFile) error
- func (kc *KubeClient) CreateNamespaceIfDoesNotExist(namespaceName string) (*corev1.Namespace, error)
- func (kc *KubeClient) CreateNamespacesIfDoesNotExist(namespaceNames []string) ([]*corev1.Namespace, error)
- func (kc *KubeClient) CreateOrUpdateSecret(namespace string, secret *corev1.Secret) (metav1.Object, error)
- func (kc *KubeClient) CreateSecret(namespaceName, secretName, secretKey, secretValue string) (*corev1.Secret, error)
- func (kc *KubeClient) DeleteNamespaces(namespaceNames []string) error
- func (kc *KubeClient) GetConfig() *rest.Config
- func (kc *KubeClient) GetNamespaces(namespaceNames []string) ([]*corev1.Namespace, 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) RemoteCommand(method string, url *url.URL) ([]byte, error)
- func (kc *KubeClient) WaitForPodRunning(ctx context.Context, namespace, podName string) (*corev1.Pod, error)
- type ManifestFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClusterResources ¶ added in v0.2.0
type ClusterResources struct { MilliTotalCPU int64 MilliUsedCPU int64 MilliTotalMemory int64 MilliUsedMemory int64 }
ClusterResources is a snapshot of a cluster's total and currently-used resources.
func (*ClusterResources) CalculateCPUPercentUsed ¶ added in v0.2.0
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 ¶ added in v0.2.0
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.
type KubeClient ¶
type KubeClient struct { Clientset kubernetes.Interface ApixClientset apixclient.Interface MattermostClientset mmclient.Interface // contains filtered or unexported fields }
KubeClient interfaces with a Kubernetes cluster in the same way kubectl would.
func New ¶
func New(configLocation string, logger log.FieldLogger) (*KubeClient, error)
New returns a new KubeClient for accessing the kubernetes API.
func (*KubeClient) CreateFromFile ¶
func (kc *KubeClient) CreateFromFile(file ManifestFile) 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) CreateNamespaceIfDoesNotExist ¶
func (kc *KubeClient) CreateNamespaceIfDoesNotExist(namespaceName string) (*corev1.Namespace, error)
CreateNamespaceIfDoesNotExist creates a kubernetes namespace if it doesn't exist already.
func (*KubeClient) CreateNamespacesIfDoesNotExist ¶
func (kc *KubeClient) CreateNamespacesIfDoesNotExist(namespaceNames []string) ([]*corev1.Namespace, error)
CreateNamespacesIfDoesNotExist creates kubernetes namespaces if they don't exist already.
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) CreateSecret ¶
func (kc *KubeClient) CreateSecret(namespaceName, secretName, secretKey, secretValue string) (*corev1.Secret, error)
CreateSecret creates kubernetes 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 ¶ added in v0.2.0
func (kc *KubeClient) GetConfig() *rest.Config
GetConfig exposes the rest.Config for use with other k8s packages.
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) GetPodsFromDeployment ¶
func (kc *KubeClient) GetPodsFromDeployment(namespace, deploymentName string) (*corev1.PodList, error)
GetPodsFromDeployment gets the pods that belong to a given deployment.
func (*KubeClient) GetPodsFromStatefulset ¶ added in v0.5.1
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) RemoteCommand ¶ added in v0.2.0
RemoteCommand executes a kubernetes command against a remote cluster.
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.