mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-05 19:21:37 +00:00
update PodSpec.Host to PodSpec.NodeName in /pkg/api/types.go and /pkg/api/v1beta3/types.go
This commit is contained in:
@@ -189,10 +189,10 @@ func (n *NodeSelector) PodSelectorMatches(pod *api.Pod, existingPods []*api.Pod,
|
||||
}
|
||||
|
||||
func PodFitsHost(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error) {
|
||||
if len(pod.Spec.Host) == 0 {
|
||||
if len(pod.Spec.NodeName) == 0 {
|
||||
return true, nil
|
||||
}
|
||||
return pod.Spec.Host == node, nil
|
||||
return pod.Spec.NodeName == node, nil
|
||||
}
|
||||
|
||||
type NodeLabelChecker struct {
|
||||
@@ -300,7 +300,7 @@ func (s *ServiceAffinity) CheckServiceAffinity(pod *api.Pod, existingPods []*api
|
||||
}
|
||||
if len(nsServicePods) > 0 {
|
||||
// consider any service pod and fetch the minion its hosted on
|
||||
otherMinion, err := s.nodeInfo.GetNodeInfo(nsServicePods[0].Spec.Host)
|
||||
otherMinion, err := s.nodeInfo.GetNodeInfo(nsServicePods[0].Spec.NodeName)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -369,7 +369,7 @@ func MapPodsToMachines(lister algorithm.PodLister) (map[string][]*api.Pod, error
|
||||
return map[string][]*api.Pod{}, err
|
||||
}
|
||||
for _, scheduledPod := range pods {
|
||||
host := scheduledPod.Spec.Host
|
||||
host := scheduledPod.Spec.NodeName
|
||||
machineToPods[host] = append(machineToPods[host], scheduledPod)
|
||||
}
|
||||
return machineToPods, nil
|
||||
|
@@ -197,7 +197,7 @@ func TestPodFitsHost(t *testing.T) {
|
||||
{
|
||||
pod: &api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Host: "foo",
|
||||
NodeName: "foo",
|
||||
},
|
||||
},
|
||||
node: "foo",
|
||||
@@ -207,7 +207,7 @@ func TestPodFitsHost(t *testing.T) {
|
||||
{
|
||||
pod: &api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Host: "bar",
|
||||
NodeName: "bar",
|
||||
},
|
||||
},
|
||||
node: "foo",
|
||||
@@ -234,7 +234,7 @@ func newPod(host string, hostPorts ...int) *api.Pod {
|
||||
}
|
||||
return &api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Host: host,
|
||||
NodeName: host,
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Ports: networkPorts,
|
||||
@@ -632,7 +632,7 @@ func TestServiceAffinity(t *testing.T) {
|
||||
},
|
||||
{
|
||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine1"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine1"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||
node: "machine1",
|
||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
||||
fits: true,
|
||||
@@ -641,7 +641,7 @@ func TestServiceAffinity(t *testing.T) {
|
||||
},
|
||||
{
|
||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine2"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine2"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||
node: "machine1",
|
||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
||||
fits: true,
|
||||
@@ -650,7 +650,7 @@ func TestServiceAffinity(t *testing.T) {
|
||||
},
|
||||
{
|
||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||
node: "machine1",
|
||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
||||
fits: false,
|
||||
@@ -659,7 +659,7 @@ func TestServiceAffinity(t *testing.T) {
|
||||
},
|
||||
{
|
||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}},
|
||||
node: "machine1",
|
||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns2"}}},
|
||||
fits: true,
|
||||
@@ -668,7 +668,7 @@ func TestServiceAffinity(t *testing.T) {
|
||||
},
|
||||
{
|
||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns2"}}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns2"}}},
|
||||
node: "machine1",
|
||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}},
|
||||
fits: true,
|
||||
@@ -677,7 +677,7 @@ func TestServiceAffinity(t *testing.T) {
|
||||
},
|
||||
{
|
||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}},
|
||||
node: "machine1",
|
||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}},
|
||||
fits: false,
|
||||
@@ -686,7 +686,7 @@ func TestServiceAffinity(t *testing.T) {
|
||||
},
|
||||
{
|
||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine2"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine2"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||
node: "machine1",
|
||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
||||
fits: false,
|
||||
@@ -695,7 +695,7 @@ func TestServiceAffinity(t *testing.T) {
|
||||
},
|
||||
{
|
||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine5"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine5"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||
node: "machine4",
|
||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
||||
fits: true,
|
||||
|
@@ -48,16 +48,16 @@ func TestLeastRequested(t *testing.T) {
|
||||
"baz": "blah",
|
||||
}
|
||||
machine1Spec := api.PodSpec{
|
||||
Host: "machine1",
|
||||
NodeName: "machine1",
|
||||
}
|
||||
machine2Spec := api.PodSpec{
|
||||
Host: "machine2",
|
||||
NodeName: "machine2",
|
||||
}
|
||||
noResources := api.PodSpec{
|
||||
Containers: []api.Container{},
|
||||
}
|
||||
cpuOnly := api.PodSpec{
|
||||
Host: "machine1",
|
||||
NodeName: "machine1",
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Resources: api.ResourceRequirements{
|
||||
@@ -76,9 +76,9 @@ func TestLeastRequested(t *testing.T) {
|
||||
},
|
||||
}
|
||||
cpuOnly2 := cpuOnly
|
||||
cpuOnly2.Host = "machine2"
|
||||
cpuOnly2.NodeName = "machine2"
|
||||
cpuAndMemory := api.PodSpec{
|
||||
Host: "machine2",
|
||||
NodeName: "machine2",
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Resources: api.ResourceRequirements{
|
||||
@@ -378,16 +378,16 @@ func TestBalancedResourceAllocation(t *testing.T) {
|
||||
"baz": "blah",
|
||||
}
|
||||
machine1Spec := api.PodSpec{
|
||||
Host: "machine1",
|
||||
NodeName: "machine1",
|
||||
}
|
||||
machine2Spec := api.PodSpec{
|
||||
Host: "machine2",
|
||||
NodeName: "machine2",
|
||||
}
|
||||
noResources := api.PodSpec{
|
||||
Containers: []api.Container{},
|
||||
}
|
||||
cpuOnly := api.PodSpec{
|
||||
Host: "machine1",
|
||||
NodeName: "machine1",
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Resources: api.ResourceRequirements{
|
||||
@@ -406,9 +406,9 @@ func TestBalancedResourceAllocation(t *testing.T) {
|
||||
},
|
||||
}
|
||||
cpuOnly2 := cpuOnly
|
||||
cpuOnly2.Host = "machine2"
|
||||
cpuOnly2.NodeName = "machine2"
|
||||
cpuAndMemory := api.PodSpec{
|
||||
Host: "machine2",
|
||||
NodeName: "machine2",
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Resources: api.ResourceRequirements{
|
||||
|
@@ -64,10 +64,10 @@ func (s *ServiceSpread) CalculateSpreadPriority(pod *api.Pod, podLister algorith
|
||||
counts := map[string]int{}
|
||||
if len(nsServicePods) > 0 {
|
||||
for _, pod := range nsServicePods {
|
||||
counts[pod.Spec.Host]++
|
||||
counts[pod.Spec.NodeName]++
|
||||
// Compute the maximum number of pods hosted on any minion
|
||||
if counts[pod.Spec.Host] > maxCount {
|
||||
maxCount = counts[pod.Spec.Host]
|
||||
if counts[pod.Spec.NodeName] > maxCount {
|
||||
maxCount = counts[pod.Spec.NodeName]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ func (s *ServiceAntiAffinity) CalculateAntiAffinityPriority(pod *api.Pod, podLis
|
||||
|
||||
podCounts := map[string]int{}
|
||||
for _, pod := range nsServicePods {
|
||||
label, exists := labeledMinions[pod.Spec.Host]
|
||||
label, exists := labeledMinions[pod.Spec.NodeName]
|
||||
if !exists {
|
||||
continue
|
||||
}
|
||||
|
@@ -35,10 +35,10 @@ func TestServiceSpreadPriority(t *testing.T) {
|
||||
"baz": "blah",
|
||||
}
|
||||
zone1Spec := api.PodSpec{
|
||||
Host: "machine1",
|
||||
NodeName: "machine1",
|
||||
}
|
||||
zone2Spec := api.PodSpec{
|
||||
Host: "machine2",
|
||||
NodeName: "machine2",
|
||||
}
|
||||
tests := []struct {
|
||||
pod *api.Pod
|
||||
@@ -191,13 +191,13 @@ func TestZoneSpreadPriority(t *testing.T) {
|
||||
"name": "value",
|
||||
}
|
||||
zone0Spec := api.PodSpec{
|
||||
Host: "machine01",
|
||||
NodeName: "machine01",
|
||||
}
|
||||
zone1Spec := api.PodSpec{
|
||||
Host: "machine11",
|
||||
NodeName: "machine11",
|
||||
}
|
||||
zone2Spec := api.PodSpec{
|
||||
Host: "machine21",
|
||||
NodeName: "machine21",
|
||||
}
|
||||
labeledNodes := map[string]map[string]string{
|
||||
"machine01": nozone, "machine02": nozone,
|
||||
|
@@ -267,7 +267,7 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue
|
||||
}
|
||||
return
|
||||
}
|
||||
if pod.Spec.Host == "" {
|
||||
if pod.Spec.NodeName == "" {
|
||||
podQueue.Add(pod)
|
||||
}
|
||||
}()
|
||||
|
@@ -142,7 +142,7 @@ func (s *Scheduler) scheduleOne() {
|
||||
s.config.Recorder.Eventf(pod, "scheduled", "Successfully assigned %v to %v", pod.Name, dest)
|
||||
// tell the model to assume that this binding took effect.
|
||||
assumed := *pod
|
||||
assumed.Spec.Host = dest
|
||||
assumed.Spec.NodeName = dest
|
||||
s.config.Modeler.AssumePod(&assumed)
|
||||
})
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ func podWithID(id, desiredHost string) *api.Pod {
|
||||
return &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: id, SelfLink: testapi.SelfLink("pods", id)},
|
||||
Spec: api.PodSpec{
|
||||
Host: desiredHost,
|
||||
NodeName: desiredHost,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user