CKA Reloading Flashcards
(81 cards)
What are the components of a control plane?
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 does kubernetes support other container run times e.g. rkt, containerd?
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 is the information stored in a key-value store
In form of documents/pages. Each individual entry gets a document. Changes to one file does not affect the others. Dataformats: json or yaml
What information is stored in etcd
Nodes
PODS
Configs
Secrets
Accounts
Roles
Bindings
Others
How does kubeadm deploy a kubernetes cluster control plane components?
As pods in kube-system namespace. you can check using
kubectl get pods -n kube-system
What happens when I type kubectl get nodes. Explain the workflow.
The kube-apiserver authenticates the request and validates it
The data is then retrieved from etcd cluster and responds back
Explain the workflow for a pod creation
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
- Authenticate User
- Validate Request
- Retrieve data
- Update ETCD
- Scheduler
- Kubelet
What does kube-controller manager do?
Watch status e.g. every 5 secs for nodes
Remediate Situation
e.g. Node controller, replication controller (ensures desired no. of pods are present)
Which folder has all the config files for control plane components deployed using kubeadm
cat /etc/kubernetes/manifests/kube-controller-manager.yaml
cat /etc/kubernetes/manifests/kube-scheduler.yaml
What does kubelet do?
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
When is a service created?
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
What does kubeproxy do?
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)
What is a POD?
A single instance of an application. Containers are encapsulated in PODs
How to deploy a POD using kubectl?
kubectl run pod_name –image image_name
This command deploys a docker container by creating a POD
How to see a list of pods available?
kubectl get pods
How to create a POD using POD definition file?
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
What is the apiVersion for POD, Service, ReplicaSet & Deployment?
POD: v1
Service: v1
ReplicaSet: apps/v1
Deployment: apps/v1
How to see detailed information of the POD
kubectl describe pod pod_name
How to create a replicaset using pod definition file
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
What is the purpose of selector in replicaset?
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
How to scale a replicaset?
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
If you have an object and want to extract the pod definition file of that object how to do that?
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>
What is the purpose of deployments?
For managing updates to the infrastructure e..g rollingupdates, or rollback
How to create a deployment?
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