Kubernetes Flashcards

1
Q

What is the “imperative” command to create a config map?

A

kubectl create configmap {configmap name} –from-literal={key}={value}

ex: kubectl create configmap app-config –from-literal=APP_COLOR=blue
ex: kubectl create configmap app-config –from-file=app_config.properties

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

What is the “declarative” command to create a config map?

A

kubectl create -f config-map.yaml

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

What is the “imperative” command to create a secret with key-value pairs?

A

kubectl create secret generic {secriet-name} –from-literal={key}={value}

ex: kubectl create secret generic app-secrect –from-literal=DB_Host=mysql –from-literal=DB_user=root –from-literal=DB_Password=paswr

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

What is the “imperative” command to create a secret in usage with a file?

A

kubectl create secret generic app-secret –from-file=app_secret.properties

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

What command can be used to view logs on a pod?

A

kubectl exec -it {pod-name} -n {namespace} cat /log/app.log

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

What are the steps in upgrading the master components to exact version v1.18.0?

A

1 - Drain the control plane node: kubectl drain {node-name} –ignore daemonsets
2 - apt install kubeadm=1.18.0-00
3 - kubeadm upgrade apply v1.18.0
4 - apt install kubelet=1.18.0-00

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

What is the command used to know what the latest stable version?

A

kubectl upgrade plan

kubectl upgrade plan | grep -i stable

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

What is the command used to create a snapshot of the etcd database?

A

ETCDCTL_API=3 etcdctl snapshot save –cacert=/etc/kubernetes/pki/etcd/ca.crt –cert=/etc/kubernetes/pki/etcd/server.crt –key=/etc/kubernetes/pki/etcd/server.key –endpoints=127.0.0.1:2379

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

What is the command used to check the members of the cluster?

A

ETCDCTL_API=3 etcdctl member list –cacert=/etc/kubernetes/pki/etcd/ca.crt –cert=/etc/kubernetes/pki/etcd/server.crt –key=/etc/kubernetes/pki/etcd/server.key –endpoints=127.0.0.1:2379

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

What are the 4 options needed to take a snapshot of the etcd datastore?

A

(1) –cacert
(2) –cert
(3) –endpoints
(4) –key

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

When performing a restore of the etcd database what are the options that are needed for the restore?

A

(1) –cacert
(2) –cert
(3) –endpoints
(4) –key
(5) –data-dir
(6) –initial-cluster
(7) –name
(8) –initial-advertise-peer-urls
(9) –initial-cluster-token

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

What is the CNI plugin configured to be used on this kubernetes cluster?

A

ls /etc/cni/net.d/

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

What binary executable file will be run by kubelet after a container and its associated namespace are created.

A

Look at the type field in file /etc/cni/net.d/10-weave.conf

cat /etc/cni/net.d/10-weave.conflist | grep -i type

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

Deploy weave-net networking solution to the cluster

A

kubectl apply -f “https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d ‘\n’)”

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

What is the Networking Solution used by this cluster?

A

ls /etc/cni/net.d/

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

What is the POD IP address range configured by weave?

A

Run the command ‘ip addr show weave’

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

What is the POD IP address range configured by weave?

A

Run the command ‘ip addr show weave’

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

What is the range of IP addresses configured for PODs on this cluster?

A

kubectl logs weave -n kube-system
and look for ipalloc-range

kc logs weave-net-brpnv weave -n kube-system | grep -i ipallo

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

What is the IP Range configured for the services within the cluster?

A

Inspect the setting on kube-api server by running on command cat /etc/kubernetes/manifests/kube-apiserver.yaml | grep cluster-ip-range

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

What type of proxy is the kube-proxy configured to use?

A

Check the logs of the kube-proxy pods. Command: kubectl logs kube-proxy-ft6n7 -n kube-system

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

Where does CoreDnS store its file?

A

/etc/coredns/Corefile

./Coredns

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

Identify the DNS solution implemented in this cluster.

A

Run the command kubectl get pods -n kube-system and look for the DNS pods

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

What is the IP of the CoreDNS server that should be configured on PODs to resolve services?

A

Run the command kubectl get service -n kube-system and look for cluster IP value.

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

Where is the configuration file located for configuring the CoreDNS service?

A

Inspect the Args of the coredns deployment and check the file used, example: kubectl -n kube-system describe deployments.apps coredns | grep -A2 Args | grep Corefile

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

What is the name of the ConfigMap object created for Corefile?

A

Run the command kubectl get configmap -n kube-system

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

What is the root domain/zone configured for this kubernetes cluster?

A

Run the command kubectl describe configmap coredns -n kube-system and look for the entry after kubernetes

cluster.local

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

From the hr pod nslookup the mysql service and redirect the output to a file /root/nslookup.out

A

Run the command kubectl exec -it hr nslookup mysql.payroll > /root/nslookup.out

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

What is the Host configured on the ingress-resource?

A

Run the command ‘kubectl describe ingress –namespace app-space’ and look at Host under the Rules section.

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

What is the command to create a namespace?

A

kubectl create namespace ingress-space

30
Q

The NGINX Ingress Controller requires a ConfigMap object. Create a ConfigMap object in the ingress-space.

A

Run the command ‘kubectl create configmap nginx-configuration –namespace ingress-space’

31
Q

The NGINX Ingress Controller requires a ServiceAccount. Create a ServiceAccount in the ingress-space.

A

Run the command ‘kubectl create serviceaccount ingress-serviceaccount –namespace ingress-space’

kc create serviceaccount ingress-serviceaccount -n ingress-space

32
Q

We have created the Roles and RoleBindings for the ServiceAccount. Check it out!

A

Run the command ‘kubectl get roles,rolebindings –namespace ingress-space’

33
Q

Let us now create a service to make Ingress available to external users.

A

Use the command kubectl expose deployment -n ingress-space ingress-controller –type=NodePort –port=80 –name=ingress –dry-run -o yaml >ingress.yaml

34
Q

(Install a 3 node cluster)

In all three terminal, run the following command to get the Docker gpg key:

A

(In all three terminals)

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

35
Q

(Install a 3 node cluster)

How would you add the docker gpg key to your repository?

A

(In all three terminals)

sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”

36
Q

(Install a 3 node cluster)

How would you download the Kubernetes gpg key?

A

(In all three terminals)

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

37
Q

(Install a 3 node cluster)

How would you add the Kubernetes gpg key to your repository?

A

cat &laquo_space;EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

sudo apt update

38
Q

Install Docker, Kubelet, kuceadm, kubectl on all three terminals

A

sudo apt install -y docker-ce=5:19.03.10~3-0~ubuntu-focal kubelet=1.18.5-00 kubeadm=1.18.5-00 kubectl=1.18.5-00

39
Q

How do you initialize the Kubernetes cluster?

A

In the Controller server terminal, run the following command to initialize the cluster using kubeadm:

sudo kubeadm init –pod-network-cidr=10.244.0.0/16

40
Q

In what way do you set up local kubeconfig?

A

In the Controller server terminal, run the following commands to set up local kubeconfig:

sudo mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown $(id -u):$(id -g) $HOME/.kube/config

41
Q

In what way do you apply the flannel CNI plugin as a network overlay?

A

In the Controller server terminal, run the following command to apply flannel:

kubectl apply -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml

42
Q

How would you Join the worker nodes to the cluster, and verify they have joined successfully?

A

When we ran sudo kubeadm init on the Controller node, there was a kubeadmin join command in the output. You’ll see it right under this text:

You can now join any number of machines by running the following on each node as root:

To join worker nodes to the cluster, we need to run that command, as root (we’ll just preface it with sudo) on each of them. It should look something like this:

sudo kubeadm join

43
Q

How would you create a deployment?

A

In the Controller server terminal, run the following command to run a deployment of ngnix:

kubectl create deployment nginx –image=nginx

44
Q

What is the command to check the release version of the OS in linux?

A

cat /etc/os-release

45
Q

What ways are there to check to see if there is a container runtime installed on the linux machine?

A

check /var/run/ directory

ex: /var/run/docker.sock
/var/run/crio/crio.sock

46
Q

What is the command to check the version of kubeadm on the master node?

A

kubeadm version -o short

47
Q

How do you get to another node prompt from the master or other nodes?

A

ssh

48
Q

What is the command to see the version of the kubelet?

A

kubelet –version

49
Q

if you have lost the kubeadmin join command you can have another one created by using the following command?

A

kubeadmin token create –print-join-command

50
Q

What is the command to show all components within a namespace?

A

kubectl -n alpha get all

51
Q

When a pod is appened by the node that it is running on what does this mean?

Ex: kube-scheduler-master

A

That it is a static pod. Because it is appended by the name of where it is running. In the example in the question you see that it is running on the master node becuase of the -master. It is a control pane component.

Another way to confirm this is to check to see if there is a directory created for a static pod in the kubelet service.

cat /etc/systemd/system/kubelet.service.d/

52
Q

What is the directly where the static pods are located?

A

/etc/kubernetes/manifests/

53
Q

What is the component responsible for managing deployments and replicasets?

A

Check the kube-controller-manager configuratin at /etc/kubernetes/manifests/kube-controller-manager.yaml

54
Q

Create a new pod with the name ‘redis’ and with the image ‘redis123’

A

kubectl run redis –image=redis123

55
Q

What does kubeadm do?

A

Simplifies the process of building Kubernetes clusters.

56
Q

Which Kubernetes component manages containers on an individual node?

A

kubelet is the agent that manages containers on each node

57
Q

What is a Namespace?

A

Namespaces are virtual clusters running on the same physical cluster.

58
Q

What is the Kubernetes control plane?

A

The control plane consists of multiple components that manage the cluster itself

59
Q

What is the primary feature of Kubernetes?

A

Kubernetes provides tools and functionality around orchestrating container workloads.

60
Q

Which flag can you use with kubeadm to supply a custom configuration file?

A

–config This flag allows you to pass in your own config file

61
Q

What is Draining?

A

When performing maintenance, you may sometimes need to remove a Kubernetes node from service.

Containers running on the node will be gracefully terminated (and potentially rescheduled on another node).

62
Q

What is the official etcd ports?

A

The official etcd ports are 2379 for client requests and 2380 for peer communication.

63
Q

What software does Kubernetes use to store data about the state of the cluster?

A

Etcd

64
Q

What command can you use to allow Pods to be scheduled on a previously-drained node after Node maintenance is complete?

A

kubectl uncordon

65
Q

Which command allows you to upgrade control plane components?

A

kubeadm upgrade apply (This command will upgrade the control plane.)

66
Q

.

Which tool can help you perform a Kubernetes upgrade?

A

kubeadm includes functionality to help you upgrade Kubernetes clusters.

67
Q

How can you make Kubernetes highly available?

A

An HA setup for Kubernetes involved multiple control plane nodes

68
Q

Which tool provides a command-line interface for Kubernetes?

A

kubectl provides a command-line interface to the Kubernetes API.

69
Q

Which of the following are options for a highly-available Etcd architecture?

A

Why is this correct?
Stacked etcd, or managing Etcd alongside other control plane components, is one option for an HA setup.

Why is this correct?
External etcd, or managing Etcd separately from other control plane components, is one option for an HA setup.

70
Q

Which tool(s) allow you to create Kubernetes clusters?

A

Why is this correct?
kubeadm allows you to build Kubernetes clusters.

Correct Answer: C
Why is this correct?
Minikube allows you to easily create single-node clusters.

71
Q

Which command-line tool allows you to interact with Etcd and perform backups?

A

etcdctl is the command-line tool for Etcd.