ACloudGuru - Chapter 2: Kubernetes Fundamentals Flashcards

1
Q

What is a kubernetes resource?

A

An object of a certain type in the Kubernetes API.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the command to list all available resource types in a cluster?

A

kubectl api-resources

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What resource can be used to create your own custom resource?

A

CustomResourceDefinition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the command to get documentation for a resource type?

A

kubectl explain <resource_type></resource_type>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What can be used to run tasks before a pod’s main container starts?

A

init container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Define ReplicaSet resource?

A

A Kubernetes resource that ensures a given number of Pod replicas are running at any given time. Can be configured with min and max.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define Deployment resource?

Stateless or Stateful?

What is the default deployment strategy?

A

A Kubernetes resource that provides a declarative description of ReplicaSets and Pods.

Ideal for scaling stateless applications.

RollingUpdate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the imperative command to create a Deployment resource?

A

kubectl create deploy <name> --image=<image> --replicas=<replicas></replicas></image></name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Define StatefulSet resource?

What kind of identity do replica pods have?

What additional step is required for StatefulSet?

A

A Kubernetes resource, similar to the Deployment resource, that provides a declarative description of ReplicaSets and Pods, but for stateful applications.

Replica Pods have sticky identity.

Must manually create a headless Service to manage Pods’ network identity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define DaemonSet resource?

A

A Kubernetes resource that dynamically runs a replica Pod on each Node, or just some Nodes in a cluster.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define Job resource?

What subfield controls the retry logic and what is its default?

A

A Kubernetes resource that runs a containerized task to completion.

spec.backofflimit, default == 6

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Define CronJob resource?

A

A Kubernetes resource that runs Jobs repeatedly according to a schedule.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the 2 most abstract components of a kubernetes cluster and what are they responsible for?

A

Control Plan: Set of components responsible for managing the cluster.

Worker Node(s): Set of components responsible for running container workloads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the components of the Control Plan and what are they responsible for?

A

API Server: Center of the Control Plane, interface used by other components to communicate and interact with the cluster.

etcd: Distributed object storage used by the API Server.

Scheduler: Assigns new Pods to appropriate Worker Nodes.

Controller Manager: Bundles controllers, each of which provide cluster functionality.

Cloud Controller Manager: Bundles controllers that interact with the cloud provider APIs. (Optional)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the components of a Worker Node and what are they responsible for?

A

kube-proxy: Managed local routing rules on the Node to route network traffic to Pods.

kubelet: Kubernetes agent that works with the container runtime to run containers on the Node.

Container Runtime: Software that runs containers, such as containerd or CRI-O. Not part of core Kubernetes installation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is Kubernetes CRI?

A

Kubernetes Container Runtime Interface is the standard interface for container runtimes. Any runtime that implements CRI should work with Kubernetes.

17
Q

How did kubelet support Docker as a container runtime?

When was this deprecated/removed?

A

Kubelet used dockershim to support Docker as a runtime even though it doesn’t implement CRI.

This was deprecated in 1.20 and removed in 1.24.

18
Q

What is the Kubernetes API?

A

An HTTP REST interface exposed by the Control Plane API Server that allows Users, Kubernetes components, and external components to interact with the Kubernetes cluster.

19
Q

How is container isolation achieved?

A

Using Linux control groups (c groups).

20
Q

Can a Pod have more that one container?

What is the best practice for organizing containers in Pods?

A

Yes.

A single container should be in each pod unless there is an initialization process or coupled components that require multiple containers.

21
Q

What is a Dockerfile?

A

A text file containing instructions for building a Docker image.

22
Q

What is scheduling?

When does scheduling occur?

What does the Scheduler take into account when selecting a node?

A

The process of assigning a Pod to a Node.

When a new Pod is created and has not yet been scheduled.

Resource requirements, pod affinity, taints, and tolerations.

23
Q

Upgrade Control Plane Node

A
  1. Upgrade kubeadm (apt)
  2. Drain the control node (kubectl)
  3. Plan the cluster upgrade (kubeadm)
  4. Apply the cluster upgrade (kubeadm)
  5. Upgrade Kubelet and kubectl (apt)
  6. Reload daemon (systemctl)
  7. Restart kubelet (systemctl)
  8. Uncordon node (kubectl)
24
Q

Upgrade Worder Node

A
  1. Drain the worker node (kubectl)
  2. SSH into worker node (ssh)
  3. Upgrade kubeadm (apt)
  4. Upgrade worker node (kubeadm)
  5. Upgrade Kubelet and kubectl (apt)
  6. Reload daemon (systemctl)
  7. Restart kubelet (systemctl)
  8. Exit worker node (exit)
  9. Uncordon node (kubectl)
25
Q

Backup and Restore Etcd

A

Backup
1. Take snapshot (etcdctl)

Restore
1. Stop control plane services (mv /etc/kubernetes/manifests OR systemctl)
2. Stop kubelet (systemctl)
3. Rename etcd data directory (mv)
4. Restore snapshot to configured directory (etcdctl)
5. Start kubectl (systemctl)
6. Start control plane services (mv /etc/kubernetes/manifests OR systemctl)

26
Q

How to drain a node

A

kubectl drain <node> --ignore--daemonsets</node>

27
Q

Schedule a pod on a specific node

A
  1. spec.nodeSelector = key.value (list)
  2. spec.nodeName = value
28
Q

kubelet troubleshooting (status, logs, stop and start)

A

status: sudo systemctl status kubelet
logs: sudo journalctl -u kubelet
stop: sudo systemctl stop kubelet
start: sudo systemctl start kubelet

29
Q

StorageClass Yaml Specification

A

Required Fields
1. apiVersion: (Globally required)
2. kind: (Globally required)
3. metadata.name: (Globally required)
4. provisioner: (Ex: kubernetes.io/no-provisioner)

Important Optional Fields
1. reclaimPolicy: (Delete(d), Retain, Recycle)
2. allowVolumeExpansion: (False(d), True)
3. volumeBindingMode: (Immediate(d), WaitForFirstConsumer)

30
Q

PersistentVolume Yaml Specification

A

Required Fields
1. apiVersion: (Globally required)
2. kind: (Globally required)
3. metadata.name: (Globally required)
4. spec.capacity.storage: (Ex: 1Gi)
5. spec.accessModes: (ReadWriteOnce, ReadOnlyMany, ReadWriteMany, ReadWriteOncePod)
6. spec.<storage-type> (hostPath, nfs, awsElasticBlockStore)
- hostPath.path: (Ex: /mnt/data)</storage-type>

Important Optional Fields
1. spec.storageClassName
2. spec.persistentVolumeReclaimPolicy: (Delete(d), Retain, Recycle) (Should match storage class)

31
Q

PersistentVolumeClaim Yaml Specification

A

Required Fields
1. apiVersion: (Globally required)
2. kind: (Globally required)
3. metadata.name: (Globally required)
5. spec.accessModes: (ReadWriteOnce, ReadOnlyMany, ReadWriteMany, ReadWriteOncePod)
6. spec.resources.requests.storage (Ex: 1Gi)

Important Optional Fields
1. spec.storageClassName
2. spec.selector.matchLabels = key.value (list)
2. spec.volumeMode (Filesystem(d), Block)

32
Q

How to switch to context

A

kubectl config use-context <context></context>

33
Q

Resources that are not namespace specific

A
  1. ClusterRole
  2. ClusterRoleBinding
  3. StorageClass
  4. PersistentVolume
  5. Node
  6. Namespace
34
Q

A good doc reference for pv/pvc

A

Tasks > Configure Pods and Containers > Configure a Pod to Use a PersistentVolume for Storage

35
Q

How to expand pvc

A

kubectl edit pvc <pvc></pvc>

36
Q

Explain an empty selector {} in the following contexts:
1. NetworkPolicy
a. spec.podSelector
b. spec.ingress.from.podSelector
c. spec.ingress.from.namespaceSelector
3. Resource Definitions (Deployment, Service, etc.)

A

1a. Select all pods in namespace
1b. Allow traffic from all pods in namespace (same for egress)
1c. Allow traffic from all pods in all namespaces (same for egress)
2. Matches all pods regardless of labels

37
Q
A