Kubernetes Flashcards
What is the “imperative” command to create a config map?
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
What is the “declarative” command to create a config map?
kubectl create -f config-map.yaml
What is the “imperative” command to create a secret with key-value pairs?
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
What is the “imperative” command to create a secret in usage with a file?
kubectl create secret generic app-secret –from-file=app_secret.properties
What command can be used to view logs on a pod?
kubectl exec -it {pod-name} -n {namespace} cat /log/app.log
What are the steps in upgrading the master components to exact version v1.18.0?
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
What is the command used to know what the latest stable version?
kubectl upgrade plan
kubectl upgrade plan | grep -i stable
What is the command used to create a snapshot of the etcd database?
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
What is the command used to check the members of the cluster?
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
What are the 4 options needed to take a snapshot of the etcd datastore?
(1) –cacert
(2) –cert
(3) –endpoints
(4) –key
When performing a restore of the etcd database what are the options that are needed for the restore?
(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
What is the CNI plugin configured to be used on this kubernetes cluster?
ls /etc/cni/net.d/
What binary executable file will be run by kubelet after a container and its associated namespace are created.
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
Deploy weave-net networking solution to the cluster
kubectl apply -f “https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d ‘\n’)”
What is the Networking Solution used by this cluster?
ls /etc/cni/net.d/
What is the POD IP address range configured by weave?
Run the command ‘ip addr show weave’
What is the POD IP address range configured by weave?
Run the command ‘ip addr show weave’
What is the range of IP addresses configured for PODs on this cluster?
kubectl logs weave -n kube-system
and look for ipalloc-range
kc logs weave-net-brpnv weave -n kube-system | grep -i ipallo
What is the IP Range configured for the services within the cluster?
Inspect the setting on kube-api server by running on command cat /etc/kubernetes/manifests/kube-apiserver.yaml | grep cluster-ip-range
What type of proxy is the kube-proxy configured to use?
Check the logs of the kube-proxy pods. Command: kubectl logs kube-proxy-ft6n7 -n kube-system
Where does CoreDnS store its file?
/etc/coredns/Corefile
./Coredns
Identify the DNS solution implemented in this cluster.
Run the command kubectl get pods -n kube-system and look for the DNS pods
What is the IP of the CoreDNS server that should be configured on PODs to resolve services?
Run the command kubectl get service -n kube-system and look for cluster IP value.
Where is the configuration file located for configuring the CoreDNS service?
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
What is the name of the ConfigMap object created for Corefile?
Run the command kubectl get configmap -n kube-system
What is the root domain/zone configured for this kubernetes cluster?
Run the command kubectl describe configmap coredns -n kube-system and look for the entry after kubernetes
cluster.local
From the hr pod nslookup the mysql service and redirect the output to a file /root/nslookup.out
Run the command kubectl exec -it hr nslookup mysql.payroll > /root/nslookup.out
What is the Host configured on the ingress-resource?
Run the command ‘kubectl describe ingress –namespace app-space’ and look at Host under the Rules section.