Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inter pod topological affinity and anti-affinity implementation #22985

Merged
merged 1 commit into from
May 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an api-server expert, but can't you just block copy *annotations? Do we need deep full type-checking on every copy operation? Seems expensive.

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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe much of these repetitive cases can be done generically on objects vs. explicit invocation. But that's more of a "we can reduce this code significantly", perhaps as a TODO.

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
}