Skip to content

Commit 82ba4f0

Browse files
implement inter pod topological affinity and anti-affinity
1 parent 28a8a23 commit 82ba4f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+8297
-809
lines changed

cmd/integration/integration.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string
183183
handler.delegate = m.Handler
184184

185185
// Scheduler
186-
schedulerConfigFactory := factory.NewConfigFactory(cl, api.DefaultSchedulerName)
186+
schedulerConfigFactory := factory.NewConfigFactory(cl, api.DefaultSchedulerName, api.DefaultHardPodAffinitySymmetricWeight, api.DefaultFailureDomains)
187187
schedulerConfig, err := schedulerConfigFactory.Create()
188188
if err != nil {
189189
glog.Fatalf("Couldn't create scheduler config: %v", err)

docs/admin/kube-scheduler.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ kube-scheduler
5656
```
5757
--address="0.0.0.0": The IP address to serve on (set to 0.0.0.0 for all interfaces)
5858
--algorithm-provider="DefaultProvider": The scheduling algorithm provider to use, one of: DefaultProvider
59+
--failure-domains="kubernetes.io/hostname,failure-domain.beta.kubernetes.io/zone,failure-domain.beta.kubernetes.io/region": Indicate the "all topologies" set for an empty topologyKey when it's used for PreferredDuringScheduling pod anti-affinity.
5960
--google-json-key="": The Google Cloud Platform Service Account JSON Key to use for authentication.
61+
--hard-pod-affinity-symmetric-weight=1: RequiredDuringScheduling affinity is not symmetric, but there is an implicit PreferredDuringScheduling affinity rule corresponding to every RequiredDuringScheduling affinity rule. --hard-pod-affinity-symmetric-weight represents the weight of implicit PreferredDuringScheduling affinity rule.
6062
--kube-api-burst=100: Burst to use while talking with kubernetes apiserver
6163
--kube-api-content-type="": ContentType of requests sent to apiserver. Passing application/vnd.kubernetes.protobuf is an experimental feature now.
6264
--kube-api-qps=50: QPS to use while talking with kubernetes apiserver
@@ -73,7 +75,7 @@ kube-scheduler
7375
--scheduler-name="default-scheduler": Name of the scheduler, used to select which pods will be processed by this scheduler, based on pod's annotation with key 'scheduler.alpha.kubernetes.io/name'
7476
```
7577

76-
###### Auto generated by spf13/cobra on 21-Apr-2016
78+
###### Auto generated by spf13/cobra on 5-May-2016
7779

7880

7981
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->

examples/examples_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ func TestExampleObjectSchemas(t *testing.T) {
333333
},
334334
"../docs/user-guide/node-selection": {
335335
"pod": &api.Pod{},
336-
"pod-with-node-affinity": &api.Pod{},
337336
},
338337
"../examples/openshift-origin": {
339338
"openshift-origin-namespace": &api.Namespace{},

hack/verify-flags/known-flags.txt

+2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ experimental-prefix
129129
external-hostname
130130
external-ip
131131
failover-timeout
132+
failure-domains
132133
fake-clientset
133134
file-check-frequency
134135
file-suffix
@@ -153,6 +154,7 @@ google-json-key
153154
grace-period
154155
ha-domain
155156
hairpin-mode
157+
hard-pod-affinity-symmetric-weight
156158
healthz-bind-address
157159
healthz-port
158160
horizontal-pod-autoscaler-sync-period

pkg/api/deep_copy_generated.go

+103
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ func init() {
129129
DeepCopy_api_PersistentVolumeSpec,
130130
DeepCopy_api_PersistentVolumeStatus,
131131
DeepCopy_api_Pod,
132+
DeepCopy_api_PodAffinity,
133+
DeepCopy_api_PodAffinityTerm,
134+
DeepCopy_api_PodAntiAffinity,
132135
DeepCopy_api_PodAttachOptions,
133136
DeepCopy_api_PodCondition,
134137
DeepCopy_api_PodExecOptions,
@@ -175,6 +178,7 @@ func init() {
175178
DeepCopy_api_Volume,
176179
DeepCopy_api_VolumeMount,
177180
DeepCopy_api_VolumeSource,
181+
DeepCopy_api_WeightedPodAffinityTerm,
178182
); err != nil {
179183
// if one of the deep copy functions is malformed, detect it immediately.
180184
panic(err)
@@ -199,6 +203,24 @@ func DeepCopy_api_Affinity(in Affinity, out *Affinity, c *conversion.Cloner) err
199203
} else {
200204
out.NodeAffinity = nil
201205
}
206+
if in.PodAffinity != nil {
207+
in, out := in.PodAffinity, &out.PodAffinity
208+
*out = new(PodAffinity)
209+
if err := DeepCopy_api_PodAffinity(*in, *out, c); err != nil {
210+
return err
211+
}
212+
} else {
213+
out.PodAffinity = nil
214+
}
215+
if in.PodAntiAffinity != nil {
216+
in, out := in.PodAntiAffinity, &out.PodAntiAffinity
217+
*out = new(PodAntiAffinity)
218+
if err := DeepCopy_api_PodAntiAffinity(*in, *out, c); err != nil {
219+
return err
220+
}
221+
} else {
222+
out.PodAntiAffinity = nil
223+
}
202224
return nil
203225
}
204226

@@ -1964,6 +1986,79 @@ func DeepCopy_api_Pod(in Pod, out *Pod, c *conversion.Cloner) error {
19641986
return nil
19651987
}
19661988

1989+
func DeepCopy_api_PodAffinity(in PodAffinity, out *PodAffinity, c *conversion.Cloner) error {
1990+
if in.RequiredDuringSchedulingIgnoredDuringExecution != nil {
1991+
in, out := in.RequiredDuringSchedulingIgnoredDuringExecution, &out.RequiredDuringSchedulingIgnoredDuringExecution
1992+
*out = make([]PodAffinityTerm, len(in))
1993+
for i := range in {
1994+
if err := DeepCopy_api_PodAffinityTerm(in[i], &(*out)[i], c); err != nil {
1995+
return err
1996+
}
1997+
}
1998+
} else {
1999+
out.RequiredDuringSchedulingIgnoredDuringExecution = nil
2000+
}
2001+
if in.PreferredDuringSchedulingIgnoredDuringExecution != nil {
2002+
in, out := in.PreferredDuringSchedulingIgnoredDuringExecution, &out.PreferredDuringSchedulingIgnoredDuringExecution
2003+
*out = make([]WeightedPodAffinityTerm, len(in))
2004+
for i := range in {
2005+
if err := DeepCopy_api_WeightedPodAffinityTerm(in[i], &(*out)[i], c); err != nil {
2006+
return err
2007+
}
2008+
}
2009+
} else {
2010+
out.PreferredDuringSchedulingIgnoredDuringExecution = nil
2011+
}
2012+
return nil
2013+
}
2014+
2015+
func DeepCopy_api_PodAffinityTerm(in PodAffinityTerm, out *PodAffinityTerm, c *conversion.Cloner) error {
2016+
if in.LabelSelector != nil {
2017+
in, out := in.LabelSelector, &out.LabelSelector
2018+
*out = new(unversioned.LabelSelector)
2019+
if err := unversioned.DeepCopy_unversioned_LabelSelector(*in, *out, c); err != nil {
2020+
return err
2021+
}
2022+
} else {
2023+
out.LabelSelector = nil
2024+
}
2025+
if in.Namespaces != nil {
2026+
in, out := in.Namespaces, &out.Namespaces
2027+
*out = make([]string, len(in))
2028+
copy(*out, in)
2029+
} else {
2030+
out.Namespaces = nil
2031+
}
2032+
out.TopologyKey = in.TopologyKey
2033+
return nil
2034+
}
2035+
2036+
func DeepCopy_api_PodAntiAffinity(in PodAntiAffinity, out *PodAntiAffinity, c *conversion.Cloner) error {
2037+
if in.RequiredDuringSchedulingIgnoredDuringExecution != nil {
2038+
in, out := in.RequiredDuringSchedulingIgnoredDuringExecution, &out.RequiredDuringSchedulingIgnoredDuringExecution
2039+
*out = make([]PodAffinityTerm, len(in))
2040+
for i := range in {
2041+
if err := DeepCopy_api_PodAffinityTerm(in[i], &(*out)[i], c); err != nil {
2042+
return err
2043+
}
2044+
}
2045+
} else {
2046+
out.RequiredDuringSchedulingIgnoredDuringExecution = nil
2047+
}
2048+
if in.PreferredDuringSchedulingIgnoredDuringExecution != nil {
2049+
in, out := in.PreferredDuringSchedulingIgnoredDuringExecution, &out.PreferredDuringSchedulingIgnoredDuringExecution
2050+
*out = make([]WeightedPodAffinityTerm, len(in))
2051+
for i := range in {
2052+
if err := DeepCopy_api_WeightedPodAffinityTerm(in[i], &(*out)[i], c); err != nil {
2053+
return err
2054+
}
2055+
}
2056+
} else {
2057+
out.PreferredDuringSchedulingIgnoredDuringExecution = nil
2058+
}
2059+
return nil
2060+
}
2061+
19672062
func DeepCopy_api_PodAttachOptions(in PodAttachOptions, out *PodAttachOptions, c *conversion.Cloner) error {
19682063
if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
19692064
return err
@@ -3037,3 +3132,11 @@ func DeepCopy_api_VolumeSource(in VolumeSource, out *VolumeSource, c *conversion
30373132
}
30383133
return nil
30393134
}
3135+
3136+
func DeepCopy_api_WeightedPodAffinityTerm(in WeightedPodAffinityTerm, out *WeightedPodAffinityTerm, c *conversion.Cloner) error {
3137+
out.Weight = in.Weight
3138+
if err := DeepCopy_api_PodAffinityTerm(in.PodAffinityTerm, &out.PodAffinityTerm, c); err != nil {
3139+
return err
3140+
}
3141+
return nil
3142+
}

0 commit comments

Comments
 (0)