Core Concepts Flashcards
What are the Master Node’s responsibilities?
Manage, plan, schedule, and monitor nodes
What are the Worker Node’s responsibilities?
Host application as containers
What are the Master Node’s components known as?
The control plane
What is the primary management component of Kubernetes?
kube-apiserver
What agent runs on each node of the cluster and listens for instructions the kube-apiserver?
kubelet
What service ensures rules are in place on the worker nodes to allow the containers running on them to reach each other?
kube-proxy
What is ETCD?
A distributed reliable key-value store that is simple, secure, and fast
What is the command to list all keys used by K8?
kubectl exec etcd-master –n kube-system etcdctl get / –prefix –keys-only
What are the 6 steps required for a change in K8?
- Authenticate User
- Validate Request
- Retrieve Data
- Update ETCD
- Scheduler
- Kubelet
What is the controller’s responsibilities?
Monitor the state of various components within the system and work towards bringing the whole system to the desired functioning state.
What is the node-monitor-grace-period default value?
40s
What is the node-eviction-rate default value?
5m
What is the node-monitor-period default value?
5s
How does the scheduler assign pods?
The scheduler looks at each pod and tries to find the best node for it in two steps:
1. Filter out the nodes that do not fit the profile for the pod. eg. resource limitations
2. The scheduler then ranks the pods to identify the best fit for the pod by using a priority function to rank the nodes on a scale of 0-10
What are the responsibilities of the Kubelet?
- Register Node
- Create Pods
- Monitor Node and Pods
What is kube-proxy and what is it’s job?
A process that runs on each node in the K8 Cluster. It’s job is to look for new services and every time a new service is created, it creates the appropriate rules on each node to forward traffic to those services to the backend pods.
What is a pod?
A single instance of an application. A pod is the smallest object you can create in K8.
What is the smallest object you can create in K8?
A pod
Can a single pod have multiple containers?
Yes
What is the command to run an image in a pod?
k run <name> --image <image_name></image_name></name>
What is the command to list pods?
k get pods
What are the top level properties that are required for a K8 YAML file?
apiVersion:
kind:
metadata:
spec:
What is the command to get information about a specific pod?
k describe pod <pod_name></pod_name>
What is the command to dry run and output a pod to yaml?
kubectl run <name> --image=<image> --dry-run=client -o yaml > pod.yaml</image></name>
What is the command to edit the YAML for an existing pod?
k edit pod <pod_name></pod_name>
What is the benefit of using a replication set with a single node?
If the pod fails, a new one will automatically be brought up. The replication set will also allow you to load balance and scale.
What is the command to list nodes?
kubectl get nodes
What is the command to get verbose information about a node?
kubectl describe node
What is the command to apply a pod.yaml file?
kubectl apply -f pod.yml
What is the command to delete a pod?
kubectl delete pod <pod_name></pod_name>
What is the command to create a replica set from a file?
kubectl create -f <filename>.yml</filename>
What is the command to list the replica set?
kubectl get replicaset
How does a replica set know what pods to monitor in a cluster with many other pods?
selector:
matchLabels:
tier: <label></label>
What command updates the replica set after updating the number of replicas in the yaml file?
kubectl replace -f <filename>.yml</filename>
What command updates the replica set using only a kubectl command?
kubectl scale –replicas=<number> -f <filename>.yml</filename></number>
What command updates the replica set using only a kubectl command without specifying the filename?
kubectl scale –replicas=<number> -f <metadata>
eg. kubectl scale --replicas=<number> -f myapp-replicaset</number></metadata></number>
What command allows you to edit the existing replicaset definition file?
kubectl edit replicaset <replicaset_name></replicaset_name>
What are the 3 fields required for the replicaset spec section?
spec:
replicas:
template:
selector:
What command returns all K8 obejcts
kubectl get all
What is the command to see the status of a rollout?
k rollout status deployment/<deployment_name></deployment_name>
What is the command to see the history of a rollout?
k rollout history deployment/<deployment_name></deployment_name>
What is the command to rollback a deployment?
k rollout undo deployment/<deployment_name></deployment_name>
What is the command to update an image in a deployment?
k set image deployment <deployment_name> <container_name>=<image_version></image_version></container_name></deployment_name>
What are the spec requirements for creating a NodePort service?
spec:
type: NodePort
ports:
- targetPort: <port_number>
port: <port_number>
nodePort: <30000 - 32767>
selector:
app: myapp
type: frontend</port_number></port_number>
What are the spec requirements for creating a ClusterIP service?
spec:
type: ClusterIP
ports:
- targetPort: <port_number>
port: <port_number>
selector:
app: myapp
type: frontend</port_number></port_number>
What are the spec requirements for creating a LoadBalancer service?
spec:
type: LoadBalancer
ports:
- targetPort: <port_number>
port: <port_number>
nodePort: <30000 - 32767>
selector:
app: myapp
type: frontend</port_number></port_number>
How do you link a pod to a service?
Pull the labels from the pod definition file and add them under selector
What is the command to create a service?
k create -f <service-file.yml></service-file.yml>
What is the command to see the services?
k get services
k get svc
What command would you use to get both pods and services?
k get pods,svc
What command would you use to get both pods and services?
k get pods,svc
What are the 4 types of K8 services?
- ClusterIP
- NodePort
- LoadBalancer
- ExternalName
What is the valid range for a nodePort?
30000 - 32767
What is the namespace for pods and services that are created for internal K8 purposes?
kube-system
What is the namespace for resources that should be made available to all users?
kube-public
What is the primary reasons for creating different namespaces?
Isolation, differing policies, resource allocation
How do you allow a pod in one namespace to reach a pod in another cluster?
Append the namespace to the service. eg. If you are trying to reach mysql in the dev namespace you would write the following:
mysql.connect(“db-service.dev.svc.cluster.local”)
What is the command to list pods in a different namespace?
k get pods –namespace=<namespace>
k get pods --n=<namespace></namespace></namespace>
What is the declaritive command to create a pod in a specific namespace?
k create -f <pod.yaml> --namespace=<namespace>
k create -f <pod.yaml> --n=<namespace></namespace></pod.yaml></namespace></pod.yaml>
How would you define a namespace in a pod definition file?
metadata:
name: <pod_name>
namespace: <namespace></namespace></pod_name>
How do you create a manifest for a namespace?
apiVersion: v1
kind: Namespace
metadata:
name: <namespace></namespace>
What is the imperative command to create a namespace?
k create namespace <namespace_name></namespace_name>
What is the command to change the default namespace you are working with?
k config set-context($kubectl config current-context) –namespace=<namespace></namespace>
What is the command to list pods in all namespaces?
k get pods –all-namespaces
How do you limit resources for a namespace in a manifest?
apiVersion: v1
kind: ResourceQuota
metadata:
name: computer-quota
namespace: dev
spec:
hard:
pods: “10”
requests.cpu: “4”
requests.memory: “5Gi”
limits.cpu: “10”
limits.memory: 10Gi
What is the command to list namespaces?
k get namespace
k get ns
Should you use an imperative or declarative approach to save time when the exam asks you to execute a simple task?
Imperative