kubectl
Commands change the cluster. Files describe it
Imperative commands act once. kubectl apply makes the cluster match a file: declarative.
Administration starts with kubectl, the command line client of the A P I server. There are two ways to use it. Imperative: you give each command. Create a deployment. Scale it. Delete it. It is quick, but only the cluster remembers what you did. Declarative: you keep the desired state in a file, and run kubectl apply. To change something, you edit the file and apply it again. The file is the record. You can review it, version it, and apply it to any cluster.
kubectl · Going deeper
The kubectl verbs
get, describe, logs, exec, apply, delete, explain and rollout.
Namespaces
A namespace divides the cluster, and a quota limits each part
A namespace scopes names, access and ResourceQuota. It does not isolate the network.
One cluster is usually shared, and namespaces are how it is divided. Kube-system holds the cluster's own pods, such as D N S. Team A has a namespace, with its pods. So does team B. Notice both teams have a pod called web. A name only has to be unique inside its namespace. And each namespace can carry a resource quota. Team A has used six of its eight C P Us. Team B, two of four.
Namespaces · Going deeper
Built-in namespaces, quota and limit range
default, kube-system, kube-public and kube-node-lease.
Check yourself
Two Deployments have the same name, as shown. Is this allowed?
Requests and limits
A request reserves room. A limit caps use
The scheduler counts requests. With 3.5 of 4 CPUs reserved, a pod asking for 1 stays Pending.
Every container can declare two numbers for each resource. Take a node with four C P Us. Three pods are placed on it. They request one, one and a half, and one. That reserves three and a half, leaving half a C P U. A new pod requests one. It does not fit, so it stays pending, even if the node is doing nothing. The scheduler counts requests, not real use. A limit is different. It is the most a running container may take. Over its memory limit, it is killed. Over its C P U limit, it is slowed.
Requests and limits · Going deeper
Quality of service classes
Guaranteed, Burstable and BestEffort, derived from requests and limits.
The scheduler
Filter, score, bind
The scheduler filters out nodes that cannot run the pod, scores the rest and binds to the best.
So how is a node chosen? A new pod requests two C P Us. There are four nodes. First, filter. Node one is too small. Node two has a taint the pod does not tolerate. Nodes three and four fit. Second, score. The remaining nodes are ranked. Node three scores forty. Node four scores eighty-five. Third, bind. The pod is assigned to node four, and that node's kubelet starts it. If no node passes the filter, the pod stays pending.
The scheduler · Going deeper
Six placement controls
Affinity attracts, a taint repels, spread evens out, priority decides who waits.
Check yourself
Which pod can the scheduler place on this node?
Placement
A taint pushes pods away. Affinity pulls them in
A taint is on the node and repels. Affinity is on the pod and attracts.
Two placement controls are easy to confuse, because they work in opposite directions. A taint is set on a node. It refuses pods. Pod A has no toleration, so it is kept off. Pod B tolerates the taint, so it may land there. Affinity is set on a pod. Pod C requires a node labelled disk equals S S D. So it goes to node X, never node Y. One more thing. A toleration only permits. It does not send pod B to the G P U node.
Placement · Going deeper · 1 of 2
Maintenance, and extending the API
Cordon stops new pods. Drain also moves the old ones. CRDs add new kinds.
Placement · Going deeper · 2 of 2
Clue words for administration and scheduling
Requests schedule. Limits enforce. Quota budgets.
Check yourself
The node looks as shown. Which command was run on it?
Lesson complete
You finished “Administration and scheduling”
Answer the questions along the way to see your score here.