Skip to content

Commit

Permalink
Merge pull request kubernetes#6897 from vainu-arto/set-priority-for-s…
Browse files Browse the repository at this point in the history
…tatic-pods

Set priority for static pods
  • Loading branch information
k8s-ci-robot authored and tariq1890 committed Jul 12, 2019
2 parents a8b0e1b + 238fdaf commit 2ade2e1
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions nodeup/pkg/model/kube_apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ func (b *KubeAPIServerBuilder) buildPod() (*v1.Pod, error) {
pod.Spec.Containers = append(pod.Spec.Containers, *container)

kubemanifest.MarkPodAsCritical(pod)
kubemanifest.MarkPodAsClusterCritical(pod)

return pod, nil
}
Expand Down
1 change: 1 addition & 0 deletions nodeup/pkg/model/kube_controller_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ func (b *KubeControllerManagerBuilder) buildPod() (*v1.Pod, error) {
pod.Spec.Containers = append(pod.Spec.Containers, *container)

kubemanifest.MarkPodAsCritical(pod)
kubemanifest.MarkPodAsClusterCritical(pod)

return pod, nil
}
4 changes: 4 additions & 0 deletions nodeup/pkg/model/kube_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ func (b *KubeProxyBuilder) buildPod() (*v1.Pod, error) {
// involved in scheduling kube-proxy).
kubemanifest.MarkPodAsCritical(pod)

// Also set priority so that kube-proxy does not get evicted in clusters where
// PodPriority is enabled.
kubemanifest.MarkPodAsNodeCritical(pod)

return pod, nil
}

Expand Down
1 change: 1 addition & 0 deletions nodeup/pkg/model/kube_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func (b *KubeSchedulerBuilder) buildPod() (*v1.Pod, error) {
pod.Spec.Containers = append(pod.Spec.Containers, *container)

kubemanifest.MarkPodAsCritical(pod)
kubemanifest.MarkPodAsClusterCritical(pod)

return pod, nil
}
1 change: 1 addition & 0 deletions pkg/kubemanifest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ go_library(
"critical.go",
"images.go",
"manifest.go",
"priority.go",
"visitor.go",
"volumes.go",
],
Expand Down
31 changes: 31 additions & 0 deletions pkg/kubemanifest/priority.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package kubemanifest

import (
v1 "k8s.io/api/core/v1"
)

// MarkPodAsNodeCritical sets the pod priority to system-node-critical
func MarkPodAsNodeCritical(pod *v1.Pod) {
pod.Spec.PriorityClassName = "system-node-critical"
}

// MarkPodAsClusterCritical sets the pod priority to system-cluster-critical
func MarkPodAsClusterCritical(pod *v1.Pod) {
pod.Spec.PriorityClassName = "system-cluster-critical"
}
1 change: 1 addition & 0 deletions pkg/model/components/etcdmanager/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ func (b *EtcdManagerBuilder) buildPod(etcdCluster *kops.EtcdClusterSpec) (*v1.Po
}

kubemanifest.MarkPodAsCritical(pod)
kubemanifest.MarkPodAsClusterCritical(pod)

return pod, nil
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/model/components/etcdmanager/tests/minimal/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Contents:
name: varlogetcd
hostNetwork: true
hostPID: true
priorityClassName: system-cluster-critical
tolerations:
- key: CriticalAddonsOnly
operator: Exists
Expand Down Expand Up @@ -178,6 +179,7 @@ Contents:
name: varlogetcd
hostNetwork: true
hostPID: true
priorityClassName: system-cluster-critical
tolerations:
- key: CriticalAddonsOnly
operator: Exists
Expand All @@ -201,4 +203,4 @@ Contents:
status: {}
Lifecycle: null
Location: manifests/etcd/main.yaml
Name: manifests-etcdmanager-main
Name: manifests-etcdmanager-main
1 change: 1 addition & 0 deletions protokube/pkg/protokube/etcd_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func BuildEtcdManifest(c *EtcdCluster) *v1.Pod {
}

kubemanifest.MarkPodAsCritical(pod)
kubemanifest.MarkPodAsClusterCritical(pod)

return pod
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ spec:
name: hosts
readOnly: true
hostNetwork: true
priorityClassName: system-cluster-critical
tolerations:
- key: CriticalAddonsOnly
operator: Exists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ spec:
name: hosts
readOnly: true
hostNetwork: true
priorityClassName: system-cluster-critical
tolerations:
- key: CriticalAddonsOnly
operator: Exists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ spec:
name: srvkubernetes
readOnly: true
hostNetwork: true
priorityClassName: system-cluster-critical
tolerations:
- key: CriticalAddonsOnly
operator: Exists
Expand Down

0 comments on commit 2ade2e1

Please sign in to comment.