implement inter pod topological affinity and anti-affinity

This commit is contained in:
Kevin
2016-05-04 06:50:31 +00:00
parent 28a8a23471
commit 82ba4f077e
46 changed files with 8302 additions and 814 deletions

View File

@@ -56,7 +56,7 @@ func ValidatePodTemplateSpecForPetSet(template *api.PodTemplateSpec, selector la
// fail. We should really check that the union of the given volumes and volumeClaims match
// volume mounts in the containers.
// allErrs = append(allErrs, apivalidation.ValidatePodTemplateSpec(template, fldPath)...)
allErrs = append(allErrs, apivalidation.ValidateLabels(template.Labels, fldPath.Child("labels"))...)
allErrs = append(allErrs, unversionedvalidation.ValidateLabels(template.Labels, fldPath.Child("labels"))...)
allErrs = append(allErrs, apivalidation.ValidateAnnotations(template.Annotations, fldPath.Child("annotations"))...)
allErrs = append(allErrs, apivalidation.ValidatePodSpecificAnnotations(template.Annotations, fldPath.Child("annotations"))...)
}

View File

@@ -189,6 +189,8 @@ func DeepCopy_componentconfig_KubeSchedulerConfiguration(in KubeSchedulerConfigu
out.KubeAPIQPS = in.KubeAPIQPS
out.KubeAPIBurst = in.KubeAPIBurst
out.SchedulerName = in.SchedulerName
out.HardPodAffinitySymmetricWeight = in.HardPodAffinitySymmetricWeight
out.FailureDomains = in.FailureDomains
if err := DeepCopy_componentconfig_LeaderElectionConfiguration(in.LeaderElection, &out.LeaderElection, c); err != nil {
return err
}

View File

@@ -5051,16 +5051,16 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) {
} else {
yysep2 := !z.EncBinary()
yy2arr2 := z.EncBasicHandle().StructToArray
var yyq2 [12]bool
var yyq2 [14]bool
_, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false
yyq2[10] = x.Kind != ""
yyq2[11] = x.APIVersion != ""
yyq2[12] = x.Kind != ""
yyq2[13] = x.APIVersion != ""
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(12)
r.EncodeArrayStart(14)
} else {
yynn2 = 10
yynn2 = 12
for _, b := range yyq2 {
if b {
yynn2++
@@ -5242,20 +5242,58 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) {
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
yy31 := &x.LeaderElection
yy31.CodecEncodeSelf(e)
yym31 := z.EncBinary()
_ = yym31
if false {
} else {
r.EncodeInt(int64(x.HardPodAffinitySymmetricWeight))
}
} else {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("hardPodAffinitySymmetricWeight"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym32 := z.EncBinary()
_ = yym32
if false {
} else {
r.EncodeInt(int64(x.HardPodAffinitySymmetricWeight))
}
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
yym34 := z.EncBinary()
_ = yym34
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.FailureDomains))
}
} else {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("failureDomains"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym35 := z.EncBinary()
_ = yym35
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.FailureDomains))
}
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
yy37 := &x.LeaderElection
yy37.CodecEncodeSelf(e)
} else {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("leaderElection"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
yy33 := &x.LeaderElection
yy33.CodecEncodeSelf(e)
yy39 := &x.LeaderElection
yy39.CodecEncodeSelf(e)
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[10] {
yym36 := z.EncBinary()
_ = yym36
if yyq2[12] {
yym42 := z.EncBinary()
_ = yym42
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.Kind))
@@ -5264,12 +5302,12 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) {
r.EncodeString(codecSelferC_UTF81234, "")
}
} else {
if yyq2[10] {
if yyq2[12] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("kind"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym37 := z.EncBinary()
_ = yym37
yym43 := z.EncBinary()
_ = yym43
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.Kind))
@@ -5278,9 +5316,9 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) {
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[11] {
yym39 := z.EncBinary()
_ = yym39
if yyq2[13] {
yym45 := z.EncBinary()
_ = yym45
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion))
@@ -5289,12 +5327,12 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) {
r.EncodeString(codecSelferC_UTF81234, "")
}
} else {
if yyq2[11] {
if yyq2[13] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("apiVersion"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym40 := z.EncBinary()
_ = yym40
yym46 := z.EncBinary()
_ = yym46
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion))
@@ -5416,12 +5454,24 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.
} else {
x.SchedulerName = string(r.DecodeString())
}
case "hardPodAffinitySymmetricWeight":
if r.TryDecodeAsNil() {
x.HardPodAffinitySymmetricWeight = 0
} else {
x.HardPodAffinitySymmetricWeight = int(r.DecodeInt(codecSelferBitsize1234))
}
case "failureDomains":
if r.TryDecodeAsNil() {
x.FailureDomains = ""
} else {
x.FailureDomains = string(r.DecodeString())
}
case "leaderElection":
if r.TryDecodeAsNil() {
x.LeaderElection = LeaderElectionConfiguration{}
} else {
yyv13 := &x.LeaderElection
yyv13.CodecDecodeSelf(d)
yyv15 := &x.LeaderElection
yyv15.CodecDecodeSelf(d)
}
case "kind":
if r.TryDecodeAsNil() {
@@ -5446,16 +5496,16 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r
var yyj16 int
var yyb16 bool
var yyhl16 bool = l >= 0
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
var yyj18 int
var yyb18 bool
var yyhl18 bool = l >= 0
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@@ -5465,13 +5515,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
} else {
x.Port = int32(r.DecodeInt(32))
}
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@@ -5481,13 +5531,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
} else {
x.Address = string(r.DecodeString())
}
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@@ -5497,13 +5547,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
} else {
x.AlgorithmProvider = string(r.DecodeString())
}
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@@ -5513,13 +5563,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
} else {
x.PolicyConfigFile = string(r.DecodeString())
}
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@@ -5529,13 +5579,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
} else {
x.EnableProfiling = bool(r.DecodeBool())
}
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@@ -5545,13 +5595,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
} else {
x.ContentType = string(r.DecodeString())
}
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@@ -5561,13 +5611,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
} else {
x.KubeAPIQPS = float32(r.DecodeFloat(true))
}
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@@ -5577,13 +5627,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
} else {
x.KubeAPIBurst = int32(r.DecodeInt(32))
}
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@@ -5593,13 +5643,45 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
} else {
x.SchedulerName = string(r.DecodeString())
}
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.HardPodAffinitySymmetricWeight = 0
} else {
x.HardPodAffinitySymmetricWeight = int(r.DecodeInt(codecSelferBitsize1234))
}
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb18 = r.CheckBreak()
}
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.FailureDomains = ""
} else {
x.FailureDomains = string(r.DecodeString())
}
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb18 = r.CheckBreak()
}
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@@ -5607,16 +5689,16 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
if r.TryDecodeAsNil() {
x.LeaderElection = LeaderElectionConfiguration{}
} else {
yyv26 := &x.LeaderElection
yyv26.CodecDecodeSelf(d)
yyv30 := &x.LeaderElection
yyv30.CodecDecodeSelf(d)
}
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@@ -5626,13 +5708,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
} else {
x.Kind = string(r.DecodeString())
}
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
@@ -5643,17 +5725,17 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197
x.APIVersion = string(r.DecodeString())
}
for {
yyj16++
if yyhl16 {
yyb16 = yyj16 > l
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb16 = r.CheckBreak()
yyb18 = r.CheckBreak()
}
if yyb16 {
if yyb18 {
break
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
z.DecStructFieldNotFound(yyj16-1, "")
z.DecStructFieldNotFound(yyj18-1, "")
}
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
}

View File

@@ -372,6 +372,12 @@ type KubeSchedulerConfiguration struct {
// will be processed by this scheduler, based on pod's annotation with
// key 'scheduler.alpha.kubernetes.io/name'.
SchedulerName string `json:"schedulerName"`
// RequiredDuringScheduling affinity is not symmetric, but there is an implicit PreferredDuringScheduling affinity rule
// corresponding to every RequiredDuringScheduling affinity rule.
// HardPodAffinitySymmetricWeight represents the weight of implicit PreferredDuringScheduling affinity rule, in the range 0-100.
HardPodAffinitySymmetricWeight int `json:"hardPodAffinitySymmetricWeight"`
// Indicate the "all topologies" set for empty topologyKey when it's used for PreferredDuringScheduling pod anti-affinity.
FailureDomains string `json:"failureDomains"`
// leaderElection defines the configuration of leader election client.
LeaderElection LeaderElectionConfiguration `json:"leaderElection"`
}

View File

@@ -163,6 +163,8 @@ func autoConvert_v1alpha1_KubeSchedulerConfiguration_To_componentconfig_KubeSche
out.KubeAPIQPS = in.KubeAPIQPS
out.KubeAPIBurst = int32(in.KubeAPIBurst)
out.SchedulerName = in.SchedulerName
out.HardPodAffinitySymmetricWeight = in.HardPodAffinitySymmetricWeight
out.FailureDomains = in.FailureDomains
if err := Convert_v1alpha1_LeaderElectionConfiguration_To_componentconfig_LeaderElectionConfiguration(&in.LeaderElection, &out.LeaderElection, s); err != nil {
return err
}
@@ -191,6 +193,8 @@ func autoConvert_componentconfig_KubeSchedulerConfiguration_To_v1alpha1_KubeSche
out.KubeAPIQPS = in.KubeAPIQPS
out.KubeAPIBurst = int(in.KubeAPIBurst)
out.SchedulerName = in.SchedulerName
out.HardPodAffinitySymmetricWeight = in.HardPodAffinitySymmetricWeight
out.FailureDomains = in.FailureDomains
if err := Convert_componentconfig_LeaderElectionConfiguration_To_v1alpha1_LeaderElectionConfiguration(&in.LeaderElection, &out.LeaderElection, s); err != nil {
return err
}

View File

@@ -98,6 +98,8 @@ func DeepCopy_v1alpha1_KubeSchedulerConfiguration(in KubeSchedulerConfiguration,
out.KubeAPIQPS = in.KubeAPIQPS
out.KubeAPIBurst = in.KubeAPIBurst
out.SchedulerName = in.SchedulerName
out.HardPodAffinitySymmetricWeight = in.HardPodAffinitySymmetricWeight
out.FailureDomains = in.FailureDomains
if err := DeepCopy_v1alpha1_LeaderElectionConfiguration(in.LeaderElection, &out.LeaderElection, c); err != nil {
return err
}

View File

@@ -89,6 +89,12 @@ func SetDefaults_KubeSchedulerConfiguration(obj *KubeSchedulerConfiguration) {
if obj.SchedulerName == "" {
obj.SchedulerName = api.DefaultSchedulerName
}
if obj.HardPodAffinitySymmetricWeight == 0 {
obj.HardPodAffinitySymmetricWeight = api.DefaultHardPodAffinitySymmetricWeight
}
if obj.FailureDomains == "" {
obj.FailureDomains = api.DefaultFailureDomains
}
}
func SetDefaults_LeaderElectionConfiguration(obj *LeaderElectionConfiguration) {

View File

@@ -105,6 +105,12 @@ type KubeSchedulerConfiguration struct {
// will be processed by this scheduler, based on pod's annotation with
// key 'scheduler.alpha.kubernetes.io/name'.
SchedulerName string `json:"schedulerName"`
// RequiredDuringScheduling affinity is not symmetric, but there is an implicit PreferredDuringScheduling affinity rule
// corresponding to every RequiredDuringScheduling affinity rule.
// HardPodAffinitySymmetricWeight represents the weight of implicit PreferredDuringScheduling affinity rule, in the range 0-100.
HardPodAffinitySymmetricWeight int `json:"hardPodAffinitySymmetricWeight"`
// Indicate the "all topologies" set for empty topologyKey when it's used for PreferredDuringScheduling pod anti-affinity.
FailureDomains string `json:"failureDomains"`
// leaderElection defines the configuration of leader election client.
LeaderElection LeaderElectionConfiguration `json:"leaderElection"`
}