Let's Learn Kubernetes - Basics - 4
Tags: beginners, kubernetes, devops, go
Published: 2021-10-21 15:41:06

Kubernetes is a container management tool that automates the deployment, scaling, and operations of an application.

In the previous blog of ['Let's learn Kubernetes'](https://dev.to/pghildiyal/lets-learn-kubernetes-basics-3-4lm) Series, we have learnt all about Storage. We learnt about concepts like Persistent Volume & Persistent Volume Claims, Storage Classes & Dynamic provisioning of Storage Classes.

{% link pghildiyal/lets-learn-kubernetes-basics-3-4lm %}

Continuing with the series, this blog consists about few additional configurations that are useful/necessary. In this blog we'll give a short explanation of each concept and then post a link that explains the same in-depth. 

Before diving in, it would be great if you can check out, star ⭐ our Repo - Devtron, An End-to-End Kubernetes Software Delivery Workflow, which makes the DevOps workflow flawless for Developers, DevOps Engineers.
{% github devtron-labs/devtron no-readme %}

## Configurations

In the final blog of the Let's learn Kubernetes series, here are some of the few additional configurations that are usually used by the folks working on Kubernetes in their day-to-day routine.
The blog covers following configurations:

* ConfigMaps
* Secrets
* Resource management 
* KubeConfig Files
* Best practices of using Kubernetes

### ConfigMaps

ConfigMaps are more like an API object that is used to store some non-confidential data in the form of key-value pairs. They contain environment variables, command line arguments which are in turn used by pods for fetching data. They also allow you to keep your configurations separate from your pods and components which helps to keep your workloads portable. It keeps their configurations easy to change and manage.

![ConfigMaps Illustration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wq561654sq0pz8lbikjs.png)

To know more about ConfigMaps you can Check out the link below:

* [Creating & Using ConfigMaps in Kubernetes](https://www.bmc.com/blogs/kubernetes-configmap/)

### Secrets

Secrets store confidential information for your pods or clusters. This information can be passwords, AuthTokens , SSH keys etc. 

Keeping confidential data in secrets is way more secure than defining them in Configmaps in the form plain text or in the pods specifications. It reduces the risk of exposing data to unauthorized users. Kubernetes Secrets are, by default, stored unencrypted in the API server's underlying data store (etcd).

![Secrets Illustrtion](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/re7lr0h3og3njr6xrls4.png)

Want to know more about Secrets? Check out this article:

* [Introduction to Kubernetes Secrets](https://www.bmc.com/blogs/kubernetes-secrets)

### Resource management

As Kubernetes helps in automating the major portion of your deployments making it simple to manage the applications. Yet, these containerized applications commonly share pooled resources so the resource allocation and management should be done properly.
 
Here are 5 ways in which this works:

* Use namespace and resource quotas
* Use limit ranges
* Set network policies
* Don’t forget about storage when applicable
* Keep things tidy API objects and monitoring

![Resource Management in Kubernetes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cngupqtseioc73nec9ad.png)

This article goes in-depth regarding Resource Management:

* [Managing Kubernetes resources: 5 things to remember](https://enterprisersproject.com/article/2020/8/managing-kubernetes-resources-5-things-remember)

### Kubeconfig Files

A Kubeconfig file is a file used to configure access to Kubernetes when used in conjunction with the kubectl command-line tool (or other clients). The use of this file is to organize the information about clusters, users, and namespaces. This kubectl command-line program uses the Kubeconfig file to find the information within a particular cluster by communicating with the API server of that cluster.

By default, kubectl looks for a file named config in the $HOME/.kube directory. You can specify other Kubeconfig files by setting the KUBECONFIG environment variable or by setting the --kubeconfig flag.

![Kubeconfig Illustration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8azxj17k2gwy2yn77d36.png)

The above image shows how the contexts define the information and configuration of the clusters listed in the Kubeconfig file.

To better understand the process, check out:

* Article - [Mastering the KUBECONFIG file](https://ahmet.im/blog/mastering-kubeconfig/)
* Video - [13 What are Kubeconfigs and Why Do We Need Them](https://www.youtube.com/watch?v=D0x28jMD4qI)

## Best practices of using Kubernetes

Till now, we came up with a series of blogs addressing all the basic concepts of Kubernetes. Starting from pods, controllers  to networking and storage. Now at the end of this series, it is very important to understand how to use these configurations in the best possible way to keep on enhancing the cluster’s efficiency.

Following are the few best practices to realize a Kubernetes cluster model that is scalable, secured and highly optimized:

* Download the latest version
* Use namespaces 
* Maintain small container images
* Set resources , requests and limits
* Use readinessProbe and livenessProbe
* Deploy RBAC for security
* Auto scale  and many more.

To get a better understanding regarding these practices check out:

* [Kubernetes Best Practices for Enhanced Cluster Efficiency](https://www.bmc.com/blogs/kubernetes-best-practices/)


Finally, we come to an end of our series discussing various basic concepts that are essential to get a grip on Kubernetes. I am really glad to see a lot of positive response on the previous blogs in the series. It is always helpful, If you'd like to suggest what are the other topics you want me to write on. 

Meanwhile, you can also check previous blogs in this series.