Kubernetes 101 - Free Online Course

Learn the basics of Kubernetes


What do I need to start with Kubernetes?

You'll get the most out of this mini-course if you follow along with the practical examples. To do that, you will need the following tools:

Which Kubernetes cluster should I use?

You have multiple choices. The most 'real-world' option would be to get a Kubernetes cluster from one cloud provider. However, for numerous reasons, that might not be an option for everyone.

The next best option is to run a Kubernetes cluster on your computer. Assuming you have some memory and CPU to spare, you can use one of the following tools to run a single-node Kubernetes cluster on your computer:

You could go with any of the above options. Creating Kubernetes ReplicaSets, Deployments, and Pods works with any of them. You can also create Kubernetes Services. However, things get a bit complicated when you're trying to use a LoadBalancer service type.

With the cloud-managed cluster, creating a LoadBalancer service type creates an actual instance of the load balancer, and you would get an external/public IP address you can use to access your services.

The one solution from the above list closest to simulating the LoadBalancer service type is Docker Desktop. With Docker Desktop your service gets exposed on an external IP, localhost. You can access these services using both kind and Minikube as well; however, it requires you to run additional commands.

Kubernetes and contexts

After you've installed one of these tools, make sure you download the Kubernetes CLI. Kubernetes CLI is a single binary called kubectl, and it allows you to run commands against your cluster. To make sure everything is working correctly, you can run kubectl get nodes to list all nodes in the Kubernetes cluster. The output from the command should look like this:

$ kubectl get nodes
docker-desktop   Ready    master   63d   v1.16.6-beta.0

You can also check that the context is set correctly to docker-desktop. Kubernetes uses a configuration file called config to find the information it needs to connect to the cluster. Kubernetes CLI reads this file from your home folder - for example $HOME/.kube/config. Context is an element inside that config file, and it contains a reference to the cluster, namespace, and the user. If you're accessing or running a single cluster, you will only have one context in the config file. However, you can have multiple contexts defined that point to different clusters.

Using the kubectl config command, you can view these contexts and switch between them. You can run the current-context command to view the current context:

$ kubectl config current-context

There are other commands such as use-context, set-context, view-contexts, etc. I prefer to use a tool called[`kubectx`]. This tool allows you to switch between different Kubernetes contexts quickly. For example, if I have three clusters (contexts) set in the config file, running kubectx outputs this:

$ kubectx

The tool highlights the currently selected context when you run the command. To switch to the minikube context, I can run: kubectx minikube.

The equivalent commands you can run with kubectl would be kubectl config get-contexts to view all contexts, and kubectl config use-context minikube to switch the context.

Before you continue, make sure your context is set to docker-desktop if you're using Docker for Mac/Windows or minikube if you're using Minikube.

Let's get started with your journey to Kubernetes and cloud-native world with the container orchestration!

Enjoying this course? Subscribe for more content from Peter.

Peter Jausovec

Peter Jausovec
Full-Stack Developer

Peter is a software engineer focused on developing distributed systems and cloud-native solutions using Docker, Kubernetes, and Istio. I am an author of multiple books, speaker, and trainer.