Pricing model for CA

This commit is contained in:
Marcin Wielgus 2017-05-25 10:31:51 +02:00
parent 670b5b4b78
commit bc86bb2676
5 changed files with 35 additions and 0 deletions

View File

@ -136,6 +136,11 @@ func (aws *awsCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.N
return asg, err
}
// Pricing returns pricing model for this cloud provider or error if not available.
func (aws *awsCloudProvider) Pricing() (cloudprovider.PricingModel, error) {
return nil, cloudprovider.ErrNotImplemented
}
// AwsRef contains a reference to some entity in AWS/GKE world.
type AwsRef struct {
Name string

View File

@ -84,6 +84,11 @@ func (azure *AzureCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovid
return scaleSet, err
}
// Pricing returns pricing model for this cloud provider or error if not available.
func (azure *AzureCloudProvider) Pricing() (cloudprovider.PricingModel, error) {
return nil, cloudprovider.ErrNotImplemented
}
// AzureRef contains a reference to some entity in Azure world.
type AzureRef struct {
Name string

View File

@ -18,6 +18,7 @@ package cloudprovider
import (
"fmt"
"time"
apiv1 "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
@ -36,6 +37,9 @@ type CloudProvider interface {
// should not be processed by cluster autoscaler, or non-nil error if such
// occurred.
NodeGroupForNode(*apiv1.Node) (NodeGroup, error)
// Pricing returns pricing model for this cloud provider or error if not available.
Pricing() (PricingModel, error)
}
// ErrNotImplemented is returned if a method is not implemented.
@ -90,3 +94,14 @@ type NodeGroup interface {
// the node by default, using manifest (most likely only kube-proxy).
TemplateNodeInfo() (*schedulercache.NodeInfo, error)
}
// PricingModel contains information about the node price and how it changes in time.
type PricingModel interface {
// NodePrice returns a price of running the given node for a given period of time.
// All prices returned by the structure should be in the same currency.
NodePrice(node *apiv1.Node, startTime time.Time, endTime time.Time) (float64, error)
// PodePrice returns a theoretical minimum priece of running a pod for a given
// period of time on a perfectly matching machine.
PodPrice(pod *apiv1.Pod, startTime time.Time, endTime time.Time) (float64, error)
}

View File

@ -92,6 +92,11 @@ func (gce *GceCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.N
return mig, err
}
// Pricing returns pricing model for this cloud provider or error if not available.
func (gce *GceCloudProvider) Pricing() (cloudprovider.PricingModel, error) {
return nil, cloudprovider.ErrNotImplemented
}
// GceRef contains s reference to some entity in GCE/GKE world.
type GceRef struct {
Project string

View File

@ -86,6 +86,11 @@ func (tcp *TestCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.
return group, nil
}
// Pricing returns pricing model for this cloud provider or error if not available.
func (tcp *TestCloudProvider) Pricing() (cloudprovider.PricingModel, error) {
return nil, cloudprovider.ErrNotImplemented
}
// AddNodeGroup adds node group to test cloud provider.
func (tcp *TestCloudProvider) AddNodeGroup(id string, min int, max int, size int) {
tcp.Lock()