Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Priorities in Pods in Kubernetes

I have some burstable pods running in cluster, which I do not want to be killed in case of memory/cpu pressure.

Is there any way to increase it's priority or something, so that we do not have to change it's namespace (kube-system for making it critical) and it can be saved?

I have found some issues regarding adding priority to pods. But couldn't figure out the solution. There should be some way to set priority, or am I missing something big here ?

like image 350
Manish Kumar Sinha Avatar asked Sep 18 '17 07:09

Manish Kumar Sinha


People also ask

Can 2 pods communicate in Kubernetes?

Kubernetes assumes that pods can communicate with other pods, regardless of which host they land on. Kubernetes gives every pod its own cluster-private IP address, so you do not need to explicitly create links between pods or map container ports to host ports.

What are the aspects apply to Kubernetes pod?

Pods also contain shared networking and storage resources for their containers: Network: Pods are automatically assigned unique IP addresses. Pod containers share the same network namespace, including IP address and network ports. Containers in a Pod communicate with each other inside the Pod on localhost .

What is a characteristic of pods in a Kubernetes cluster?

Pods represent the processes running on a cluster. By limiting pods to a single process, Kubernetes can report on the health of each process running in the cluster. Pods have: a unique IP address (which allows them to communicate with each other) persistent storage volumes (as required)


1 Answers

Pod priority feature is not available prior to Kubernetes v1.7

From v1.8+, you can add pod's priority in PodSpec. You need to create PriorityClass object with priority value and use that PriorityClass name in Pod.

But upto v1.9, PriorityClass is still in alpha phase.

apiVersion: scheduling.k8s.io/v1alpha1
kind: PriorityClass
metadata:
  name: high-priority
value: 1000000
globalDefault: false

Here,

  • value indicates priority. The higher the value, the higher the priority
  • globalDefault indicates that the value of this PriorityClass should be used for Pods without a PriorityClassName. Only one PriorityClass with globalDefault set to true can exist in the system.

Now, lets create a Pod with this Priority

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
  priorityClassName: high-priority

Preemption

When Pod is created, if no Node is found that satisfies all the specified requirements of that Pod, using preemption logic one or more lower priority Pods get deleted from the Node. After the Pods are gone, Pod with higher priority is scheduled on the Node.

See details about pod priority.

like image 90
Shahriar Avatar answered Oct 06 '22 07:10

Shahriar