Skip to content

Commit

Permalink
implement inter pod topological affinity and anti-affinity
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-wangzefeng committed May 6, 2016
1 parent 28a8a23 commit 82ba4f0
Show file tree
Hide file tree
Showing 46 changed files with 8,297 additions and 809 deletions.
2 changes: 1 addition & 1 deletion cmd/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string
handler.delegate = m.Handler

// Scheduler
schedulerConfigFactory := factory.NewConfigFactory(cl, api.DefaultSchedulerName)
schedulerConfigFactory := factory.NewConfigFactory(cl, api.DefaultSchedulerName, api.DefaultHardPodAffinitySymmetricWeight, api.DefaultFailureDomains)
schedulerConfig, err := schedulerConfigFactory.Create()
if err != nil {
glog.Fatalf("Couldn't create scheduler config: %v", err)
Expand Down
4 changes: 3 additions & 1 deletion docs/admin/kube-scheduler.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ kube-scheduler
```
--address="0.0.0.0": The IP address to serve on (set to 0.0.0.0 for all interfaces)
--algorithm-provider="DefaultProvider": The scheduling algorithm provider to use, one of: DefaultProvider
--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.
--google-json-key="": The Google Cloud Platform Service Account JSON Key to use for authentication.
--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.
--kube-api-burst=100: Burst to use while talking with kubernetes apiserver
--kube-api-content-type="": ContentType of requests sent to apiserver. Passing application/vnd.kubernetes.protobuf is an experimental feature now.
--kube-api-qps=50: QPS to use while talking with kubernetes apiserver
Expand All @@ -73,7 +75,7 @@ kube-scheduler
--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'
```

###### Auto generated by spf13/cobra on 21-Apr-2016
###### Auto generated by spf13/cobra on 5-May-2016


<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
Expand Down
1 change: 0 additions & 1 deletion examples/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ func TestExampleObjectSchemas(t *testing.T) {
},
"../docs/user-guide/node-selection": {
"pod": &api.Pod{},
"pod-with-node-affinity": &api.Pod{},
},
"../examples/openshift-origin": {
"openshift-origin-namespace": &api.Namespace{},
Expand Down
2 changes: 2 additions & 0 deletions hack/verify-flags/known-flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ experimental-prefix
external-hostname
external-ip
failover-timeout
failure-domains
fake-clientset
file-check-frequency
file-suffix
Expand All @@ -153,6 +154,7 @@ google-json-key
grace-period
ha-domain
hairpin-mode
hard-pod-affinity-symmetric-weight
healthz-bind-address
healthz-port
horizontal-pod-autoscaler-sync-period
Expand Down
103 changes: 103 additions & 0 deletions pkg/api/deep_copy_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func init() {
DeepCopy_api_PersistentVolumeSpec,
DeepCopy_api_PersistentVolumeStatus,
DeepCopy_api_Pod,
DeepCopy_api_PodAffinity,
DeepCopy_api_PodAffinityTerm,
DeepCopy_api_PodAntiAffinity,
DeepCopy_api_PodAttachOptions,
DeepCopy_api_PodCondition,
DeepCopy_api_PodExecOptions,
Expand Down Expand Up @@ -175,6 +178,7 @@ func init() {
DeepCopy_api_Volume,
DeepCopy_api_VolumeMount,
DeepCopy_api_VolumeSource,
DeepCopy_api_WeightedPodAffinityTerm,
); err != nil {
// if one of the deep copy functions is malformed, detect it immediately.
panic(err)
Expand All @@ -199,6 +203,24 @@ func DeepCopy_api_Affinity(in Affinity, out *Affinity, c *conversion.Cloner) err
} else {
out.NodeAffinity = nil
}
if in.PodAffinity != nil {
in, out := in.PodAffinity, &out.PodAffinity
*out = new(PodAffinity)
if err := DeepCopy_api_PodAffinity(*in, *out, c); err != nil {
return err
}
} else {
out.PodAffinity = nil
}
if in.PodAntiAffinity != nil {
in, out := in.PodAntiAffinity, &out.PodAntiAffinity
*out = new(PodAntiAffinity)
if err := DeepCopy_api_PodAntiAffinity(*in, *out, c); err != nil {
return err
}
} else {
out.PodAntiAffinity = nil
}
return nil
}

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

func DeepCopy_api_PodAffinity(in PodAffinity, out *PodAffinity, c *conversion.Cloner) error {
if in.RequiredDuringSchedulingIgnoredDuringExecution != nil {
in, out := in.RequiredDuringSchedulingIgnoredDuringExecution, &out.RequiredDuringSchedulingIgnoredDuringExecution
*out = make([]PodAffinityTerm, len(in))
for i := range in {
if err := DeepCopy_api_PodAffinityTerm(in[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.RequiredDuringSchedulingIgnoredDuringExecution = nil
}
if in.PreferredDuringSchedulingIgnoredDuringExecution != nil {
in, out := in.PreferredDuringSchedulingIgnoredDuringExecution, &out.PreferredDuringSchedulingIgnoredDuringExecution
*out = make([]WeightedPodAffinityTerm, len(in))
for i := range in {
if err := DeepCopy_api_WeightedPodAffinityTerm(in[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.PreferredDuringSchedulingIgnoredDuringExecution = nil
}
return nil
}

func DeepCopy_api_PodAffinityTerm(in PodAffinityTerm, out *PodAffinityTerm, c *conversion.Cloner) error {
if in.LabelSelector != nil {
in, out := in.LabelSelector, &out.LabelSelector
*out = new(unversioned.LabelSelector)
if err := unversioned.DeepCopy_unversioned_LabelSelector(*in, *out, c); err != nil {
return err
}
} else {
out.LabelSelector = nil
}
if in.Namespaces != nil {
in, out := in.Namespaces, &out.Namespaces
*out = make([]string, len(in))
copy(*out, in)
} else {
out.Namespaces = nil
}
out.TopologyKey = in.TopologyKey
return nil
}

func DeepCopy_api_PodAntiAffinity(in PodAntiAffinity, out *PodAntiAffinity, c *conversion.Cloner) error {
if in.RequiredDuringSchedulingIgnoredDuringExecution != nil {
in, out := in.RequiredDuringSchedulingIgnoredDuringExecution, &out.RequiredDuringSchedulingIgnoredDuringExecution
*out = make([]PodAffinityTerm, len(in))
for i := range in {
if err := DeepCopy_api_PodAffinityTerm(in[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.RequiredDuringSchedulingIgnoredDuringExecution = nil
}
if in.PreferredDuringSchedulingIgnoredDuringExecution != nil {
in, out := in.PreferredDuringSchedulingIgnoredDuringExecution, &out.PreferredDuringSchedulingIgnoredDuringExecution
*out = make([]WeightedPodAffinityTerm, len(in))
for i := range in {
if err := DeepCopy_api_WeightedPodAffinityTerm(in[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.PreferredDuringSchedulingIgnoredDuringExecution = nil
}
return nil
}

func DeepCopy_api_PodAttachOptions(in PodAttachOptions, out *PodAttachOptions, c *conversion.Cloner) error {
if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
Expand Down Expand Up @@ -3037,3 +3132,11 @@ func DeepCopy_api_VolumeSource(in VolumeSource, out *VolumeSource, c *conversion
}
return nil
}

func DeepCopy_api_WeightedPodAffinityTerm(in WeightedPodAffinityTerm, out *WeightedPodAffinityTerm, c *conversion.Cloner) error {
out.Weight = in.Weight
if err := DeepCopy_api_PodAffinityTerm(in.PodAffinityTerm, &out.PodAffinityTerm, c); err != nil {
return err
}
return nil
}
Loading

0 comments on commit 82ba4f0

Please sign in to comment.