Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
bfe41927
Commit
bfe41927
authored
Jan 19, 2017
by
Timothy St. Clair
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaup Affinity post conversion from annotations to fields
parent
6873d2a5
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
75 additions
and
156 deletions
+75
-156
addons.go
cmd/kubeadm/app/master/addons.go
+35
-2
apiclient.go
cmd/kubeadm/app/master/apiclient.go
+0
-32
discovery.go
cmd/kubeadm/app/master/discovery.go
+18
-1
helpers.go
pkg/api/helpers.go
+0
-4
helpers.go
pkg/api/v1/helpers.go
+0
-18
helpers_test.go
pkg/api/v1/helpers_test.go
+0
-56
helpers.go
staging/src/k8s.io/client-go/pkg/api/helpers.go
+0
-4
helpers.go
staging/src/k8s.io/client-go/pkg/api/v1/helpers.go
+0
-18
BUILD
test/integration/scheduler_perf/BUILD
+0
-1
scheduler_test.go
test/integration/scheduler_perf/scheduler_test.go
+22
-20
No files found.
cmd/kubeadm/app/master/addons.go
View file @
bfe41927
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"fmt"
"fmt"
"net"
"net"
"path"
"path"
"runtime"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
...
@@ -81,6 +82,23 @@ func createKubeProxyPodSpec(cfg *kubeadmapi.MasterConfiguration) v1.PodSpec {
...
@@ -81,6 +82,23 @@ func createKubeProxyPodSpec(cfg *kubeadmapi.MasterConfiguration) v1.PodSpec {
},
},
},
},
},
},
Affinity
:
&
v1
.
Affinity
{
NodeAffinity
:
&
v1
.
NodeAffinity
{
RequiredDuringSchedulingIgnoredDuringExecution
:
&
v1
.
NodeSelector
{
NodeSelectorTerms
:
[]
v1
.
NodeSelectorTerm
{
{
MatchExpressions
:
[]
v1
.
NodeSelectorRequirement
{
{
Key
:
"beta.kubernetes.io/arch"
,
Operator
:
v1
.
NodeSelectorOpIn
,
Values
:
[]
string
{
runtime
.
GOARCH
},
},
},
},
},
},
},
},
}
}
}
}
...
@@ -240,6 +258,23 @@ func createKubeDNSPodSpec(cfg *kubeadmapi.MasterConfiguration) v1.PodSpec {
...
@@ -240,6 +258,23 @@ func createKubeDNSPodSpec(cfg *kubeadmapi.MasterConfiguration) v1.PodSpec {
},
},
},
},
DNSPolicy
:
v1
.
DNSDefault
,
DNSPolicy
:
v1
.
DNSDefault
,
Affinity
:
&
v1
.
Affinity
{
NodeAffinity
:
&
v1
.
NodeAffinity
{
RequiredDuringSchedulingIgnoredDuringExecution
:
&
v1
.
NodeSelector
{
NodeSelectorTerms
:
[]
v1
.
NodeSelectorTerm
{
{
MatchExpressions
:
[]
v1
.
NodeSelectorRequirement
{
{
Key
:
"beta.kubernetes.io/arch"
,
Operator
:
v1
.
NodeSelectorOpIn
,
Values
:
[]
string
{
runtime
.
GOARCH
},
},
},
},
},
},
},
},
}
}
}
}
...
@@ -266,7 +301,6 @@ func createKubeDNSServiceSpec(cfg *kubeadmapi.MasterConfiguration) (*v1.ServiceS
...
@@ -266,7 +301,6 @@ func createKubeDNSServiceSpec(cfg *kubeadmapi.MasterConfiguration) (*v1.ServiceS
func
CreateEssentialAddons
(
cfg
*
kubeadmapi
.
MasterConfiguration
,
client
*
clientset
.
Clientset
)
error
{
func
CreateEssentialAddons
(
cfg
*
kubeadmapi
.
MasterConfiguration
,
client
*
clientset
.
Clientset
)
error
{
kubeProxyDaemonSet
:=
NewDaemonSet
(
kubeProxy
,
createKubeProxyPodSpec
(
cfg
))
kubeProxyDaemonSet
:=
NewDaemonSet
(
kubeProxy
,
createKubeProxyPodSpec
(
cfg
))
SetMasterTaintTolerations
(
&
kubeProxyDaemonSet
.
Spec
.
Template
.
ObjectMeta
)
SetMasterTaintTolerations
(
&
kubeProxyDaemonSet
.
Spec
.
Template
.
ObjectMeta
)
SetNodeAffinity
(
&
kubeProxyDaemonSet
.
Spec
.
Template
.
ObjectMeta
,
NativeArchitectureNodeAffinity
())
if
_
,
err
:=
client
.
Extensions
()
.
DaemonSets
(
metav1
.
NamespaceSystem
)
.
Create
(
kubeProxyDaemonSet
);
err
!=
nil
{
if
_
,
err
:=
client
.
Extensions
()
.
DaemonSets
(
metav1
.
NamespaceSystem
)
.
Create
(
kubeProxyDaemonSet
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed creating essential kube-proxy addon [%v]"
,
err
)
return
fmt
.
Errorf
(
"failed creating essential kube-proxy addon [%v]"
,
err
)
...
@@ -276,7 +310,6 @@ func CreateEssentialAddons(cfg *kubeadmapi.MasterConfiguration, client *clientse
...
@@ -276,7 +310,6 @@ func CreateEssentialAddons(cfg *kubeadmapi.MasterConfiguration, client *clientse
kubeDNSDeployment
:=
NewDeployment
(
KubeDNS
,
1
,
createKubeDNSPodSpec
(
cfg
))
kubeDNSDeployment
:=
NewDeployment
(
KubeDNS
,
1
,
createKubeDNSPodSpec
(
cfg
))
SetMasterTaintTolerations
(
&
kubeDNSDeployment
.
Spec
.
Template
.
ObjectMeta
)
SetMasterTaintTolerations
(
&
kubeDNSDeployment
.
Spec
.
Template
.
ObjectMeta
)
SetNodeAffinity
(
&
kubeDNSDeployment
.
Spec
.
Template
.
ObjectMeta
,
NativeArchitectureNodeAffinity
())
kubeDNSServiceAccount
:=
&
v1
.
ServiceAccount
{}
kubeDNSServiceAccount
:=
&
v1
.
ServiceAccount
{}
kubeDNSServiceAccount
.
ObjectMeta
.
Name
=
KubeDNS
kubeDNSServiceAccount
.
ObjectMeta
.
Name
=
KubeDNS
if
_
,
err
:=
client
.
ServiceAccounts
(
metav1
.
NamespaceSystem
)
.
Create
(
kubeDNSServiceAccount
);
err
!=
nil
{
if
_
,
err
:=
client
.
ServiceAccounts
(
metav1
.
NamespaceSystem
)
.
Create
(
kubeDNSServiceAccount
);
err
!=
nil
{
...
...
cmd/kubeadm/app/master/apiclient.go
View file @
bfe41927
...
@@ -19,7 +19,6 @@ package master
...
@@ -19,7 +19,6 @@ package master
import
(
import
(
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"runtime"
"time"
"time"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
...
@@ -229,37 +228,6 @@ func SetMasterTaintTolerations(meta *metav1.ObjectMeta) {
...
@@ -229,37 +228,6 @@ func SetMasterTaintTolerations(meta *metav1.ObjectMeta) {
meta
.
Annotations
[
v1
.
TolerationsAnnotationKey
]
=
string
(
tolerationsAnnotation
)
meta
.
Annotations
[
v1
.
TolerationsAnnotationKey
]
=
string
(
tolerationsAnnotation
)
}
}
// SetNodeAffinity is a basic helper to set meta.Annotations[v1.AffinityAnnotationKey] for one or more v1.NodeSelectorRequirement(s)
func
SetNodeAffinity
(
meta
*
metav1
.
ObjectMeta
,
expr
...
v1
.
NodeSelectorRequirement
)
{
nodeAffinity
:=
&
v1
.
NodeAffinity
{
RequiredDuringSchedulingIgnoredDuringExecution
:
&
v1
.
NodeSelector
{
NodeSelectorTerms
:
[]
v1
.
NodeSelectorTerm
{{
MatchExpressions
:
expr
}},
},
}
affinityAnnotation
,
_
:=
json
.
Marshal
(
v1
.
Affinity
{
NodeAffinity
:
nodeAffinity
})
if
meta
.
Annotations
==
nil
{
meta
.
Annotations
=
map
[
string
]
string
{}
}
meta
.
Annotations
[
v1
.
AffinityAnnotationKey
]
=
string
(
affinityAnnotation
)
}
// MasterNodeAffinity returns v1.NodeSelectorRequirement to be used with SetNodeAffinity to set affinity to master node
func
MasterNodeAffinity
()
v1
.
NodeSelectorRequirement
{
return
v1
.
NodeSelectorRequirement
{
Key
:
metav1
.
NodeLabelKubeadmAlphaRole
,
Operator
:
v1
.
NodeSelectorOpIn
,
Values
:
[]
string
{
metav1
.
NodeLabelRoleMaster
},
}
}
// NativeArchitectureNodeAffinity returns v1.NodeSelectorRequirement to be used with SetNodeAffinity to nodes with CPU architecture
// the same as master node
func
NativeArchitectureNodeAffinity
()
v1
.
NodeSelectorRequirement
{
return
v1
.
NodeSelectorRequirement
{
Key
:
"beta.kubernetes.io/arch"
,
Operator
:
v1
.
NodeSelectorOpIn
,
Values
:
[]
string
{
runtime
.
GOARCH
},
}
}
func
createDummyDeployment
(
client
*
clientset
.
Clientset
)
{
func
createDummyDeployment
(
client
*
clientset
.
Clientset
)
{
fmt
.
Println
(
"[apiclient] Creating a test deployment"
)
fmt
.
Println
(
"[apiclient] Creating a test deployment"
)
dummyDeployment
:=
NewDeployment
(
"dummy"
,
1
,
v1
.
PodSpec
{
dummyDeployment
:=
NewDeployment
(
"dummy"
,
1
,
v1
.
PodSpec
{
...
...
cmd/kubeadm/app/master/discovery.go
View file @
bfe41927
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"path"
"path"
"runtime"
"time"
"time"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -103,6 +104,23 @@ func newKubeDiscoveryPodSpec(cfg *kubeadmapi.MasterConfiguration) v1.PodSpec {
...
@@ -103,6 +104,23 @@ func newKubeDiscoveryPodSpec(cfg *kubeadmapi.MasterConfiguration) v1.PodSpec {
Secret
:
&
v1
.
SecretVolumeSource
{
SecretName
:
kubeDiscoverySecretName
},
Secret
:
&
v1
.
SecretVolumeSource
{
SecretName
:
kubeDiscoverySecretName
},
}},
}},
},
},
Affinity
:
&
v1
.
Affinity
{
NodeAffinity
:
&
v1
.
NodeAffinity
{
RequiredDuringSchedulingIgnoredDuringExecution
:
&
v1
.
NodeSelector
{
NodeSelectorTerms
:
[]
v1
.
NodeSelectorTerm
{
{
MatchExpressions
:
[]
v1
.
NodeSelectorRequirement
{
{
Key
:
"beta.kubernetes.io/arch"
,
Operator
:
v1
.
NodeSelectorOpIn
,
Values
:
[]
string
{
runtime
.
GOARCH
},
},
},
},
},
},
},
},
}
}
}
}
...
@@ -117,7 +135,6 @@ func newKubeDiscovery(cfg *kubeadmapi.MasterConfiguration, caCert *x509.Certific
...
@@ -117,7 +135,6 @@ func newKubeDiscovery(cfg *kubeadmapi.MasterConfiguration, caCert *x509.Certific
}
}
SetMasterTaintTolerations
(
&
kd
.
Deployment
.
Spec
.
Template
.
ObjectMeta
)
SetMasterTaintTolerations
(
&
kd
.
Deployment
.
Spec
.
Template
.
ObjectMeta
)
SetNodeAffinity
(
&
kd
.
Deployment
.
Spec
.
Template
.
ObjectMeta
,
MasterNodeAffinity
(),
NativeArchitectureNodeAffinity
())
return
kd
return
kd
}
}
...
...
pkg/api/helpers.go
View file @
bfe41927
...
@@ -429,10 +429,6 @@ func NodeSelectorRequirementsAsSelector(nsm []NodeSelectorRequirement) (labels.S
...
@@ -429,10 +429,6 @@ func NodeSelectorRequirementsAsSelector(nsm []NodeSelectorRequirement) (labels.S
}
}
const
(
const
(
// AffinityAnnotationKey represents the key of affinity data (json serialized)
// in the Annotations of a Pod.
AffinityAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/affinity"
// TolerationsAnnotationKey represents the key of tolerations data (json serialized)
// TolerationsAnnotationKey represents the key of tolerations data (json serialized)
// in the Annotations of a Pod.
// in the Annotations of a Pod.
TolerationsAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/tolerations"
TolerationsAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/tolerations"
...
...
pkg/api/v1/helpers.go
View file @
bfe41927
...
@@ -233,10 +233,6 @@ func NodeSelectorRequirementsAsSelector(nsm []NodeSelectorRequirement) (labels.S
...
@@ -233,10 +233,6 @@ func NodeSelectorRequirementsAsSelector(nsm []NodeSelectorRequirement) (labels.S
}
}
const
(
const
(
// AffinityAnnotationKey represents the key of affinity data (json serialized)
// in the Annotations of a Pod.
AffinityAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/affinity"
// TolerationsAnnotationKey represents the key of tolerations data (json serialized)
// TolerationsAnnotationKey represents the key of tolerations data (json serialized)
// in the Annotations of a Pod.
// in the Annotations of a Pod.
TolerationsAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/tolerations"
TolerationsAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/tolerations"
...
@@ -276,20 +272,6 @@ const (
...
@@ -276,20 +272,6 @@ const (
UnsafeSysctlsPodAnnotationKey
string
=
"security.alpha.kubernetes.io/unsafe-sysctls"
UnsafeSysctlsPodAnnotationKey
string
=
"security.alpha.kubernetes.io/unsafe-sysctls"
)
)
// GetAffinityFromPod gets the json serialized affinity data from Pod.Annotations
// and converts it to the Affinity type in api.
func
GetAffinityFromPodAnnotations
(
annotations
map
[
string
]
string
)
(
*
Affinity
,
error
)
{
if
len
(
annotations
)
>
0
&&
annotations
[
AffinityAnnotationKey
]
!=
""
{
var
affinity
Affinity
err
:=
json
.
Unmarshal
([]
byte
(
annotations
[
AffinityAnnotationKey
]),
&
affinity
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
affinity
,
nil
}
return
nil
,
nil
}
// GetTolerationsFromPodAnnotations gets the json serialized tolerations data from Pod.Annotations
// GetTolerationsFromPodAnnotations gets the json serialized tolerations data from Pod.Annotations
// and converts it to the []Toleration type in api.
// and converts it to the []Toleration type in api.
func
GetTolerationsFromPodAnnotations
(
annotations
map
[
string
]
string
)
([]
Toleration
,
error
)
{
func
GetTolerationsFromPodAnnotations
(
annotations
map
[
string
]
string
)
([]
Toleration
,
error
)
{
...
...
pkg/api/v1/helpers_test.go
View file @
bfe41927
...
@@ -179,62 +179,6 @@ func TestNodeSelectorRequirementsAsSelector(t *testing.T) {
...
@@ -179,62 +179,6 @@ func TestNodeSelectorRequirementsAsSelector(t *testing.T) {
}
}
}
}
func
TestGetAffinityFromPod
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
pod
*
Pod
expectErr
bool
}{
{
pod
:
&
Pod
{},
expectErr
:
false
,
},
{
pod
:
&
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
AffinityAnnotationKey
:
`
{"nodeAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [{
"matchExpressions": [{
"key": "foo",
"operator": "In",
"values": ["value1", "value2"]
}]
}]
}}}`
,
},
},
},
expectErr
:
false
,
},
{
pod
:
&
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
AffinityAnnotationKey
:
`
{"nodeAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [{
"matchExpressions": [{
"key": "foo",
`
,
},
},
},
expectErr
:
true
,
},
}
for
i
,
tc
:=
range
testCases
{
_
,
err
:=
GetAffinityFromPodAnnotations
(
tc
.
pod
.
Annotations
)
if
err
==
nil
&&
tc
.
expectErr
{
t
.
Errorf
(
"[%v]expected error but got none."
,
i
)
}
if
err
!=
nil
&&
!
tc
.
expectErr
{
t
.
Errorf
(
"[%v]did not expect error but got: %v"
,
i
,
err
)
}
}
}
func
TestTaintToString
(
t
*
testing
.
T
)
{
func
TestTaintToString
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
taint
*
Taint
taint
*
Taint
...
...
staging/src/k8s.io/client-go/pkg/api/helpers.go
View file @
bfe41927
...
@@ -451,10 +451,6 @@ func NodeSelectorRequirementsAsSelector(nsm []NodeSelectorRequirement) (labels.S
...
@@ -451,10 +451,6 @@ func NodeSelectorRequirementsAsSelector(nsm []NodeSelectorRequirement) (labels.S
}
}
const
(
const
(
// AffinityAnnotationKey represents the key of affinity data (json serialized)
// in the Annotations of a Pod.
AffinityAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/affinity"
// TolerationsAnnotationKey represents the key of tolerations data (json serialized)
// TolerationsAnnotationKey represents the key of tolerations data (json serialized)
// in the Annotations of a Pod.
// in the Annotations of a Pod.
TolerationsAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/tolerations"
TolerationsAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/tolerations"
...
...
staging/src/k8s.io/client-go/pkg/api/v1/helpers.go
View file @
bfe41927
...
@@ -233,10 +233,6 @@ func NodeSelectorRequirementsAsSelector(nsm []NodeSelectorRequirement) (labels.S
...
@@ -233,10 +233,6 @@ func NodeSelectorRequirementsAsSelector(nsm []NodeSelectorRequirement) (labels.S
}
}
const
(
const
(
// AffinityAnnotationKey represents the key of affinity data (json serialized)
// in the Annotations of a Pod.
AffinityAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/affinity"
// TolerationsAnnotationKey represents the key of tolerations data (json serialized)
// TolerationsAnnotationKey represents the key of tolerations data (json serialized)
// in the Annotations of a Pod.
// in the Annotations of a Pod.
TolerationsAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/tolerations"
TolerationsAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/tolerations"
...
@@ -276,20 +272,6 @@ const (
...
@@ -276,20 +272,6 @@ const (
UnsafeSysctlsPodAnnotationKey
string
=
"security.alpha.kubernetes.io/unsafe-sysctls"
UnsafeSysctlsPodAnnotationKey
string
=
"security.alpha.kubernetes.io/unsafe-sysctls"
)
)
// GetAffinityFromPod gets the json serialized affinity data from Pod.Annotations
// and converts it to the Affinity type in api.
func
GetAffinityFromPodAnnotations
(
annotations
map
[
string
]
string
)
(
*
Affinity
,
error
)
{
if
len
(
annotations
)
>
0
&&
annotations
[
AffinityAnnotationKey
]
!=
""
{
var
affinity
Affinity
err
:=
json
.
Unmarshal
([]
byte
(
annotations
[
AffinityAnnotationKey
]),
&
affinity
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
affinity
,
nil
}
return
nil
,
nil
}
// GetTolerationsFromPodAnnotations gets the json serialized tolerations data from Pod.Annotations
// GetTolerationsFromPodAnnotations gets the json serialized tolerations data from Pod.Annotations
// and converts it to the []Toleration type in api.
// and converts it to the []Toleration type in api.
func
GetTolerationsFromPodAnnotations
(
annotations
map
[
string
]
string
)
([]
Toleration
,
error
)
{
func
GetTolerationsFromPodAnnotations
(
annotations
map
[
string
]
string
)
([]
Toleration
,
error
)
{
...
...
test/integration/scheduler_perf/BUILD
View file @
bfe41927
...
@@ -41,7 +41,6 @@ go_test(
...
@@ -41,7 +41,6 @@ go_test(
"//test/integration/framework:go_default_library",
"//test/integration/framework:go_default_library",
"//test/utils:go_default_library",
"//test/utils:go_default_library",
"//vendor:github.com/golang/glog",
"//vendor:github.com/golang/glog",
"//vendor:github.com/renstrom/dedent",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
],
],
)
)
...
...
test/integration/scheduler_perf/scheduler_test.go
View file @
bfe41927
...
@@ -28,7 +28,6 @@ import (
...
@@ -28,7 +28,6 @@ import (
testutils
"k8s.io/kubernetes/test/utils"
testutils
"k8s.io/kubernetes/test/utils"
"github.com/golang/glog"
"github.com/golang/glog"
"github.com/renstrom/dedent"
"k8s.io/kubernetes/plugin/pkg/scheduler"
"k8s.io/kubernetes/plugin/pkg/scheduler"
)
)
...
@@ -79,31 +78,34 @@ func TestSchedule100Node3KNodeAffinityPods(t *testing.T) {
...
@@ -79,31 +78,34 @@ func TestSchedule100Node3KNodeAffinityPods(t *testing.T) {
"scheduler-perf-"
,
"scheduler-perf-"
,
)
)
affinityTemplate
:=
dedent
.
Dedent
(
`
{
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [{
"matchExpressions": [{
"key": "`
+
nodeAffinityKey
+
`",
"operator": "In",
"values": ["%v"]
}]
}]
}
}
}`
)
podCreatorConfig
:=
testutils
.
NewTestPodCreatorConfig
()
podCreatorConfig
:=
testutils
.
NewTestPodCreatorConfig
()
for
i
:=
0
;
i
<
numGroups
;
i
++
{
for
i
:=
0
;
i
<
numGroups
;
i
++
{
podCreatorConfig
.
AddStrategy
(
"sched-perf-node-affinity"
,
config
.
numPods
/
numGroups
,
pod
:=
&
v1
.
Pod
{
testutils
.
NewCustomCreatePodStrategy
(
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
GenerateName
:
"sched-perf-node-affinity-pod-"
,
GenerateName
:
"sched-perf-node-affinity-pod-"
,
Annotations
:
map
[
string
]
string
{
v1
.
AffinityAnnotationKey
:
fmt
.
Sprintf
(
affinityTemplate
,
i
)},
},
},
Spec
:
testutils
.
MakePodSpec
(),
Spec
:
testutils
.
MakePodSpec
(),
}),
}
pod
.
Spec
.
Affinity
=
&
v1
.
Affinity
{
NodeAffinity
:
&
v1
.
NodeAffinity
{
RequiredDuringSchedulingIgnoredDuringExecution
:
&
v1
.
NodeSelector
{
NodeSelectorTerms
:
[]
v1
.
NodeSelectorTerm
{
{
MatchExpressions
:
[]
v1
.
NodeSelectorRequirement
{
{
Key
:
nodeAffinityKey
,
Operator
:
v1
.
NodeSelectorOpIn
,
Values
:
[]
string
{
string
(
i
)},
},
},
},
},
},
},
}
podCreatorConfig
.
AddStrategy
(
"sched-perf-node-affinity"
,
config
.
numPods
/
numGroups
,
testutils
.
NewCustomCreatePodStrategy
(
pod
),
)
)
}
}
config
.
podCreator
=
testutils
.
NewTestPodCreator
(
config
.
schedulerSupportFunctions
.
GetClient
(),
podCreatorConfig
)
config
.
podCreator
=
testutils
.
NewTestPodCreator
(
config
.
schedulerSupportFunctions
.
GetClient
(),
podCreatorConfig
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment