25 Kubernetes questions that will help you get certified and become more efficient with K8s
Mastering Kubernetes can be a complex task, but certain tips and tricks can expedite your journey, instilling you with confidence when it comes to maintaining Kubernetes clusters. This curated set of questions is designed to elevate your skills to the next level. If you're aiming for certification, going through this list is a must.
How do you convert a Kubernetes pod to a deployment?
Answer
Export the pod to a yaml definition using the following command:
Create a new deployment definition using the following command:
Display the pod yaml:
Copy the spec part
Edit the deployment file:
Paste the pod .spec block to deployment template .spec, correct indentation, save the file.
Create the deployment using the file:
How do you create a service svc1 from a Kubernetes pod pod1? The service should use a tcp port redirection of 8080:80.
Answer
Run the following command:
How do you create a temporary pod and verify a http connectivity to a service svc1 that exposed a port 80?
Answer
Run the following command:
The -m 5 parameter defines maximum time allowed for the transfer. It is used as a 5 second timeout. If the response is not transferred by that time, wget stops.
What are the three kinds of object management supported in Kubernetes?
Answer
- Imperative commands
- Imperative object configuration
- Declarative object configuration
Very often you generate a manifest using an imperative command together with --dry-run=client parameter and then further tweak it using an editor. Once finished, you apply the changes.
Example:
Run the following to generate a pod manifest.
Run the following to open the pod manifest in an editor:
Apply the changes by running the following command:
The above technique will also allow you to get back to the manifest if needed. You can always delete the resoruce (pod), modify the manifest and recreate it again using the modified version.
How can you display a list of Kubernetes pods that will automatically rerender when a pod status changes?
Answer
Run the following command:
How do you list Kubernetes service accounts?
Answer
Run one of the following commands (they are all the same):
What command can you use to get the address of the Kubernetes control plane and cluster services?
Answer
Run the following command:
How can you speed up your work flow when using kubectl?
Answer
Configure alias, so that you don't need to type kubectl.
Run the following command:
Then you can type kubectl commands like this:
How can you speed up switching between namespaces using kubectl?
Answer
Option 1:
Create alias and variable:
Then switch namespace like this:
Option 2:
Create two aliases
Then switch namespace like this:
How do you find Kubernetes pods that consume the most CPU?
Answer
Run the following command:
You can also disable headers by using --no-headers parameter.
To display
information about usage of containers, use --containers=true parameter.
What does kubectl cordon do?
Answer
Cordon marks the Kubernetes node unschedulable to prevent new pods from arriving. This is usually done as a preparation for node upgrade.
To cordon the node, run the following command:
What does kubectl uncordon do?
Answer
Uncordon makes the node schedulable again after it has been cordoned before. This command is usually used after the node has been upgraded to higher version (for which it needed to be cordoned).
To uncordon the node, run the following command:
What does kubectl drain do?
Answer
Drain marks the node as unschedulable to prevent new pods from arriving. It also evicts the pods from the node.
Drain is executed to drain the node in preparation for maintenance.
To drain the node, run the following command:
What is a taint in Kubernetes?
Answer
How can you identify what IP addresses have the nodes assigned in Kubernetes?
Answer
To get IP addresses of all nodes, run the following command:
How do you display current Kubernetes context using kubectl?
Answer
Option 1:
Run the following command:
Option 2:
Run the following command:
Using kubectl, how do you display list of names of available Kubernetes contexts that you can use from the machine?
Answer
Run the following command:
Without kubectl, how do you display list of names of available Kubernetes contexts that you can use from the machine?
Answer
Use the following command:
How does it work?
- The configuration data is stored the file ~/.kube/config
- cat command displays the conent of the file
- yq command converts the output from yaml to JSON format
- jq command will iterate over all child elements of element (array) contexts, name property of each child element is displayed.
How can you display all objects that are present in the current Kubernetes namespace?
Answer
Run the following command:
How can you display yaml details of all deployments, pods and services that are present in the current Kubernetes namespace?
Answer
Run the following command:
You are looking for IP address details of your Kubernetes nodes, but you are not sure what is a structure of node manifests. How can you find this details and learn more about the structure?
Answer
Run the following command:
How it works?
- Using kubectl, details of nodes are displayed in yaml format
- Using grep command, rows are searched for string ip (case insensitive search), besides the row, block of 10 rows before and 10 rows after is displayed
- This allows you to quickly find key blocks in manifests when you don't know exactly what you are looking for. Based on the output you can further refine the query.
Using kubectl, how do you convert yaml manifest of a specific pod pod1 to JSON format?
Answer
Run the following command:
How do you find all pods that run on a master node?
Answer
Run the following command to find a master node:
Copy the node name and run the following command:
How can you run a pod on each node of Kubernetes and make sure that it is running only once on on each node?
Answer
Option 1:
Create a deamonset.
Option 2:
Create a deployment that has pods with antiaffinity that allows only one pod to run on a node. Make sure the count of replicas is the same or higher than the number of nodes.
How do you get a list of endpoints that are available for service service1?
Answer
Run the following command
Blog
15 Azure Cloud questions to verify that you understand Azure Network Security Groups
Azure Network Security Groups play a crucial role in fortifying your virtual network and enhancing the security of your cloud-based application. Evaluate your understanding of these key components now.
Read article25 Adobe XD questions that will help you to nail your job interview
Presenting a thorough list of Adobe XD job interview questions, accompanied by their answers. This resource is expertly designed to empower you to excel in job interviews, pinpoint knowledge gaps, and uncover fresh insights about Adobe XD. Recognized as a potent tool, Adobe XD streamlines the creation of prototypes and the design of user experiences.
Read article25 Flexbox questions that will help you to nail your job interview
Introducing an all-inclusive list of Flexbox job interview questions, complete with answers. This resource is meticulously curated to aid you in acing job interviews, spotting areas of knowledge deficit, and discovering new facets of Flexbox. An innovative layout mode introduced in CSS3, Flexbox was designed to supersede less efficient float and table layouts. It enables the automatic arrangement of responsive elements within a container, adapting fluidly to different screen sizes.
Read article25 Git questions that will help you to nail your job interview
Presenting an extensive list of Git job interview questions, complete with answers. This resource is designed not only to help you ace your job interview but also to identify any existing knowledge gaps and provide an opportunity to learn new aspects about Git. As a modern distributed version control system, Git holds the position as the most widely used system in today's tech landscape.
Read article25 Kubernetes questions that will help you get certified and become more efficient with K8s
Mastering Kubernetes can be a complex task, but certain tips and tricks can expedite your journey, instilling you with confidence when it comes to maintaining Kubernetes clusters. This curated set of questions is designed to elevate your skills to the next level. If you're aiming for certification, going through this list is a must.
Read article