CKA Reloading Flashcards

1
Q

What are the components of a control plane?

A

MASTER:
ETCD (Key-Value store)
kube-scheduler (identify the right node to place the pod on), controllers (node-controller, replication-controller, controller-manager)
kube-apiserver (primary management component - orchestrates all operations within the cluster)

WORKER:
container run-time engine (e.g. docker, rkt, containerd)
kubelet (captain - runs on each node, listens for instructions from kube-apiserver, creates the pod on the node)
kubeproxy (communication between worker nodes are enabled by this service)

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

How does kubernetes support other container run times e.g. rkt, containerd?

A

CRI (Container Runtime Interface) and should follow OCI standards (Open Container Initiative) - imagespec, runtimespec

dockershim (to still support docker) - REMOVED as containerd (deamon) supports CRI

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

How is the information stored in a key-value store

A

In form of documents/pages. Each individual entry gets a document. Changes to one file does not affect the others. Dataformats: json or yaml

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

What information is stored in etcd

A

Nodes
PODS
Configs
Secrets
Accounts
Roles
Bindings
Others

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

How does kubeadm deploy a kubernetes cluster control plane components?

A

As pods in kube-system namespace. you can check using

kubectl get pods -n kube-system

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

What happens when I type kubectl get nodes. Explain the workflow.

A

The kube-apiserver authenticates the request and validates it
The data is then retrieved from etcd cluster and responds back

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

Explain the workflow for a pod creation

A

The kube-apiserver updates the information in etcd cluster
updates user that a pod is created
kube-scheduler continuously monitors the apiserver and realizes there is a pod with no node assigned
scheduler identifies the right node to put the pod on and communicates back to the kube-apiserver
kube-apiserver then updates the information in etcd cluster
apiserver then passes the information to kubelet in the appropriate worker node
kubelet then creates the pod and instructs the container-engine to deploy the application image
Once done, kubelet updates the status back to the apiserver which in turn updates the data back in etcd cluster

kube-apiserver is the only component that interacts directly with the etcd data store

  1. Authenticate User
  2. Validate Request
  3. Retrieve data
  4. Update ETCD
  5. Scheduler
  6. Kubelet
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does kube-controller manager do?

A

Watch status e.g. every 5 secs for nodes
Remediate Situation

e.g. Node controller, replication controller (ensures desired no. of pods are present)

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

Which folder has all the config files for control plane components deployed using kubeadm

A

cat /etc/kubernetes/manifests/kube-controller-manager.yaml

cat /etc/kubernetes/manifests/kube-scheduler.yaml

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

What does kubelet do?

A

Registers the node with the kubernetes cluster
Create PODs
Requests container-engine to deploy the application in the POD
Monitor Mode & PODs and reports to kube-apiserver

KUBEADM does not deploy kubelet.. It should be manually installed

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

When is a service created?

A

To expose an application to other PODs. The other PODs can access the application using the name of the service. The service also gets an IP.

Service does not join the POD network.

Enable loose coupling between microservices application

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

What does kubeproxy do?

A

Runs on each node in the kubernetes cluster. It looks for new services and creates appropriate rules on each node to forward traffic to the POD using iptables rules

Single POD is always deployed on each node in the cluster (deployed as deamonset - e.g. logging)

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

What is a POD?

A

A single instance of an application. Containers are encapsulated in PODs

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

How to deploy a POD using kubectl?

A

kubectl run pod_name –image image_name

This command deploys a docker container by creating a POD

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

How to see a list of pods available?

A

kubectl get pods

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

How to create a POD using POD definition file?

A

apiVersion: v1
kind: Pod
metadata:
name: mypod
labels:
type: front_end
spec:
containers:
- name: mycontainer
image: nginx

kubectl create -f 1.yaml or kubectl apply -f 1.yaml

create and apply works the same way if you are creating a new object

17
Q

What is the apiVersion for POD, Service, ReplicaSet & Deployment?

A

POD: v1
Service: v1
ReplicaSet: apps/v1
Deployment: apps/v1

18
Q

How to see detailed information of the POD

A

kubectl describe pod pod_name

19
Q

How to create a replicaset using pod definition file

A

apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myreplicaset
labels:
type: front_end
spec:
replicas: 2
selector:
matchLabels:
type: front_end
template:
metadata:
labels:
type: front_end
spec:
containers:
- name: mycontainer
image: nginx

20
Q

What is the purpose of selector in replicaset?

A

It helps identify what pods fall under it. Replicaset can also manage pods that are not created as part of replicaset creation.

selector:
matchLabels:
type: front_end

21
Q

How to scale a replicaset?

A

Option 1: Update the definition file and then run k replace -f replicaset-definition.yaml

Option 2: k scale –replicas=6 -f replicaset-definition.yaml (DOES NOT CHANGE THE FILE)

OR

k scale –replicas=6 replicaset replicaset_name

22
Q

If you have an object and want to extract the pod definition file of that object how to do that?

A

e.g. k get replicaset replica_set_name -o yaml > definition_file.yaml

If the object does not pre-exist
kubectl create replicaset <replicaset-name> --image=<image-name> --dry-run=client -o yaml > replicaset-definition.yaml</image-name></replicaset-name>

23
Q

What is the purpose of deployments?

A

For managing updates to the infrastructure e..g rollingupdates, or rollback

24
Q

How to create a deployment?

A

apiVersion: apps/v1
kind: Deployment
metadata:
name: mydeployment
labels:
type: front_end
spec:
replicas: 2
selector:
matchLabels:
type: front_end
template:
metadata:
labels:
type: front_end
spec:
containers:
- name: mycontainer
image: nginx

25
Q

Types of deployment strategies

A

RollingUpdate (default)
Recreate

26
Q

How to see the status of rollout for a deployment?

A

k rollout status deployment/deployment_name

27
Q

How to see the revisions of rollout for a deployment?

A

k rollout history deployment/deployment_name

28
Q

How to apply any definition file changes?

A

k apply -f deployment-definition.yaml

If you are changing image then you can do it by using set image command

k set image deployment/deployment_name container_name=image_name (FILE NOT CHANGED)

29
Q

How to undo a rollout?

A

k rollout undo deployment/deployment_name

30
Q

How to record the cause of change in a deployment

A

k create -f deployment_file.yaml –record

31
Q

What does k edit command do

A

It will open the definition file and you can make edits to it. Once changes are done, the updates will take place

32
Q

What are the types of services

A

NodePort (external access) - maps a port on the node to a port on the pod
ClusterIP (within the cluster)
LoadBalancer

33
Q

What are the different ports in nodePort

A

TargetPort (pod)
Port (service) - mandatory
nodePort (node’s port) - 30000 - 32767

34
Q

How to create a service?

A

apiVersion: v1
kind: Service
metadata:
name: myservice
labels:
type: front_end
spec:
ports:
- port: 80
targetPort: 80
nodePort: 30008
selector:
type: front_end (selects all pods that match this label as endpoints to forward the traffic)
type: NodePort

35
Q

What are the 3 namespaces created by default in kubernetes

A

Default
kube-system
kube-public