Running resource predicate on kubelet.

Added checking on kubelet if scheduled pods do not exceed resources. Related to #5207.
This commit is contained in:
Jerzy Szczepkowski
2015-03-16 13:50:00 +01:00
parent cbf57ee324
commit 5845f6ad48
8 changed files with 183 additions and 62 deletions

View File

@@ -17,10 +17,13 @@ limitations under the License.
package kubelet
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/golang/glog"
cadvisorApi "github.com/google/cadvisor/info/v1"
)
// TODO: move this into pkg/capabilities
@@ -40,3 +43,15 @@ func SetupEventSending(client *client.Client, hostname string) {
glog.Infof("Sending events to api server.")
record.StartRecording(client.Events(""))
}
func CapacityFromMachineInfo(info *cadvisorApi.MachineInfo) api.ResourceList {
c := api.ResourceList{
api.ResourceCPU: *resource.NewMilliQuantity(
int64(info.NumCores*1000),
resource.DecimalSI),
api.ResourceMemory: *resource.NewQuantity(
info.MemoryCapacity,
resource.BinarySI),
}
return c
}