Documentation
¶
Index ¶
- type ClusterStatus
- type K8sClient
- type MockK8sClient
- func (k *MockK8sClient) CreateConfigMap(namespace, configmap string, params map[string]string) (*v1.ConfigMap, error)
- func (k *MockK8sClient) FetchConfigMap(namespace, configmap string) (*v1.ConfigMap, error)
- func (k *MockK8sClient) GetClusterStatus() (*ClusterStatus, error)
- func (k *MockK8sClient) GetNamespace() string
- func (k *MockK8sClient) UpdateConfigMap(namespace, configmap string, params map[string]string) (*v1.ConfigMap, error)
- func (k *MockK8sClient) UpdateReplicas(expReplicas int32) (int32, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClusterStatus ¶
type ClusterStatus struct { TotalNodes int32 SchedulableNodes int32 TotalCores int32 SchedulableCores int32 }
ClusterStatus defines the cluster status
type K8sClient ¶
type K8sClient interface { // FetchConfigMap fetches the requested configmap from the Apiserver FetchConfigMap(namespace, configmap string) (*v1.ConfigMap, error) // CreateConfigMap creates a configmap with given namespace, name and params CreateConfigMap(namespace, configmap string, params map[string]string) (*v1.ConfigMap, error) // UpdateConfigMap updates a configmap with given namespace, name and params UpdateConfigMap(namespace, configmap string, params map[string]string) (*v1.ConfigMap, error) // GetClusterStatus counts schedulable nodes and cores in the cluster GetClusterStatus() (clusterStatus *ClusterStatus, err error) // GetNamespace returns the namespace of target resource. GetNamespace() (namespace string) // UpdateReplicas updates the number of replicas for the resource and return the previous replicas count UpdateReplicas(expReplicas int32) (prevReplicas int32, err error) }
K8sClient - Wraps all needed client functionalities for autoscaler
func NewK8sClient ¶
func NewK8sClient(clientset kubernetes.Interface, namespace, target string, nodelabels string) (K8sClient, error)
NewK8sClient gives a k8sClient with the given dependencies.
type MockK8sClient ¶
type MockK8sClient struct { NumOfNodes int NumOfCores int NumOfReplicas int ConfigMap *v1.ConfigMap FetchConfigMapFn func(namespace, configmap string) (*v1.ConfigMap, error) CreateConfigMapFn func(namespace, configmap string, params map[string]string) (*v1.ConfigMap, error) }
MockK8sClient implements K8sClientInterface
func (*MockK8sClient) CreateConfigMap ¶
func (k *MockK8sClient) CreateConfigMap(namespace, configmap string, params map[string]string) (*v1.ConfigMap, error)
CreateConfigMap mocks creating a configmap with given namespace, name and params
func (*MockK8sClient) FetchConfigMap ¶
func (k *MockK8sClient) FetchConfigMap(namespace, configmap string) (*v1.ConfigMap, error)
FetchConfigMap mocks fetching the requested configmap from the Apiserver
func (*MockK8sClient) GetClusterStatus ¶
func (k *MockK8sClient) GetClusterStatus() (*ClusterStatus, error)
GetClusterStatus mocks counting schedulable nodes and cores in the cluster
func (*MockK8sClient) GetNamespace ¶
func (k *MockK8sClient) GetNamespace() string
GetNamespace mocks returning the namespace of target resource.
func (*MockK8sClient) UpdateConfigMap ¶
func (k *MockK8sClient) UpdateConfigMap(namespace, configmap string, params map[string]string) (*v1.ConfigMap, error)
UpdateConfigMap mocks updating a configmap with given namespace, name and params
func (*MockK8sClient) UpdateReplicas ¶
func (k *MockK8sClient) UpdateReplicas(expReplicas int32) (int32, error)
UpdateReplicas mocks updating the number of replicas for the resource and return the previous replicas count