Docker and Kubernetes are two of the most important tools in a modern developer’s toolkit. Together, they form the foundation for creating and deploying dockerized applications. Container adoption is rapidly growing. There are predictions from Gartner that by 2023 more than 70% of organizations will run more or equal to 2 containerized applications in production. In this blog post, we will cover basic tips on how to learn Docker and Kubernetes. We will also provide some tips on how to avoid common pitfalls when learning these technologies.
So, let’s get started!
The first step in learning Docker and Kubernetes is to install them on your computer.
If you are using a Mac, you can use Docker for Mac. For Windows, you can use the Docker toolbox. When it comes to Linux first you need to check for an older version of Docker, then install Docker Engine. To uninstall the older version of Docker use the following command:
$ sudo apt-get remove docker docker-engine docker.io containerd runc
You can install Docker Engine in different ways. If it’s the first time installing Docker Engine on the host machine before you proceed with the installation you will need to set up a Docker repository. After all that you can update the apt package index, and install the latest version of Docker Engine.
Run the following command after installing Docker to install Kubernetes:
$ curl -Lo kubectl get. docker.com/kube-install | bash
This will install kubectl, which is the command line tool for interacting with Kubernetes.
Once Kubernetes is installed it requires a cluster to connect to. Clusters are a foundational concept in Kubernetes. They’re the collection of all components that make up a Kubernetes system, including containers, pods, nodes, configuration management, networking, and storage. Usually for booting up a cluster locally there are applications like kind, minikube, microk8s and many others.
Now that you have docker and Kubernetes installed, you can begin learning how to use them. The great starting point is Docker documentation. The Docker documentation is very comprehensive and will teach you everything you need to know about docker. Once you have a good understanding of docker, you can move on to the Kubernetes documentation. The Kubernetes documentation is also very comprehensive, but it can be a bit daunting at first. A good way to approach it is to read the sections that correspond to the features you want to use.
Once you understand the basics of Docker and Kubernetes, you can begin working with them on your projects. A great way to learn is by following along with tutorials. There are many great Docker and Kubernetes tutorials available online.
As you continue learning Docker and Kubernetes, you will undoubtedly run into problems. When this happens, don’t be discouraged! The Docker and Kubernetes communities are very friendly and helpful. Just one search on Google or Stack Overflow will usually turn up a solution to your problem.
Pitfalls that almost every beginner is making when learning Kubernetes.
- Trying to learn everything at once. This is a recipe for disaster because you’ll quickly become overwhelmed and lost. It’s better to focus on one thing at a time and gradually expand your knowledge.
- Not having enough hands-on experience. It’s important to experiment with Kubernetes in your environment. Only by using it in real projects will you be able to truly understand how it works.
- Ignoring Health Checks. Health Checks via probes are essential for running services in Kubernetes. By ignoring the Health Checks you’re risking that your services are not running as intended or might even fail without you noticing. To know the health status of your application and the services running inside them there are a startup, liveness, and readiness probes. These probes will help you whether everything is working fine on your pods.
- Using the ‘Latest’ Tag when deploying containers. This makes tracking the version of the image you are working with really hard.
- Deploying a Service to the wrong Kubernetes Cluster. This is one of the top 5 most common mistakes that one beginner will make. In Kubernetes, you can add multiple clusters to your kube config. There is a handy extension for visual-code called kubernetes and it allows you to switch between clusters easily, but there are many other options available if you search online. Useful link
- Duplicated Deployments. This will happen when you create more than one replica of the same state deployed in parallel to a different cluster. Maybe you wonder why this is so essential? The answer is that if one of your clusters goes down, the replica will continue to process requests for your deployment. When the cluster comes back up, both replicas will be processing requests and doubling up and they may oversubscribe the CPU and memory on the hosts. Using Headless Service or Daemon Set will help fix this mistake so that only one deployment version is running at any given time.
- Not Employing Deployment Models. Kubernetes makes deployment easy with their deployment techniques. Kubernetes have 5 deployment strategies for you to use: Blue-Green, Canary, Rolling, A/B Testing, and The Multi-Service Deployment
- Deploying your application without considering Monitoring & Logging Requirements. As a beginner, you will probably make this mistake in your first projects when learning Kubernetes. A lot of people deploy their applications without thinking about how they will monitor and debug them in production. Down the road, this will bring a lot of problems. To avoid this mistake, you should set up a monitoring system and a log aggregation system before deploying your application on Kubernetes.
- Deploying your application without any security configuration in place. This can have serious consequences. You should always deploy your applications with security in mind. Security challenges include Authorization, Networking, and Storage.
- Not setting resource Consumption Limits on your Pods & Containers. If you don’t set limits on the resources your bills will start shooting up. To avoid this perform a stress test against your application. Setting a limit on the CPU and the container’s memory will limit those skyrocketing bills. You can specify the resource limits in the deployment of YAML.
These pitfalls can be avoided by following the tips in this blog. If you are interested to learn more about Docker, Kubernetes, and container orchestration, check out our Docker and Kubernetes course. We cover everything you need to know to get started and work on projects with these technologies.
I hope this blog post helped get you started with learning docker and Kubernetes.