Steps

First Kubernetes Lab

Step1 of 4

Welcome to Katacoda

Welcome to the BoxBoat Bootcamp! For our labs, we utilize Katacoda. Katacoda is
a platform that enables you to run Docker and Kubernetes in your web browser.
Each lab has multiple steps where we'll explain concepts and how you can utilize
them in Kubernetes. In the future, if you want to experiment with Kubernetes,
you should check out Katacoda's
Kubernetes playground.

Our Katacoda environment is a lightweight Linux distribution where we can run pretty much whatever we want. Katacoda simplifies the process by allowing you to click on commands to execute them. For example:

ls

You can click on that, and it will execute ls inside the environment.

You can also view open ports, and even edit files. We will be using this platform for all of our Kubernetes labs.

We strongly recommend that you use a text editor on your host to edit and
save files ( VS Code and
Atom are excellent and free ). You will receive a copy of
all lab files we use at the conclusion of the training.

Each session has multiple hosts. Your current host is a master node that lets
us run the cluster. You also have another host that is a worker, which runs
workloads.

We generally keep files for labs in ./resources/. We also store all of your
old work from previous sessions in /old/ on this host.

Let's begin.

Cluster Info

Right now, we have a Kubernetes cluster running. The cluster can be interacted
with using the kubectl CLI. This is the main approach used for managing
Kubernetes and the applications running on top of the cluster.

Details of the cluster and its health status can be discovered via
kubectl cluster-info

To view the nodes in the cluster using kubectl get nodes

If the node is marked as NotReady then it is still starting the components.

This command shows all nodes that can be used to host our applications. At this
stage, we should have 2 nodes that are both ready for us to deploy applications
on.

We can see the other host in our cluster, and actually SSH to it:

ssh node01

However, we will be managing our Kubernetes cluster from the master, so exit
the SSH connection by typing exit.

Deploy Applications

With a running Kubernetes cluster, containers can now be deployed.

Generally, we would deploy these using Deployment YAML files, but for this
example, we will use the command line.

The kubectl run command allows containers to be deployed onto the cluster.

The status of the deployment can be discovered via viewing the running Pods.

kubectl get pods

Once the container is running, it can be exposed via different networking
options, depending on requirements. One possible solution is NodePort, that
provides a dynamic port on the host to a container. What this command does is
create iptables rules to route traffic that hits a specific port on the host to
the container that we deployed.

kubectl expose deployment first-deployment --port=80 --type=NodePort

The command below finds the allocated port and executes an HTTP request.

As you can see, the dashboard gives us a graphical view of our cluster. We can see all of the objects in the cluster, and actually, schedule workloads. We won't be using the dashboard during these training sessions, but as you continue your Kubernetes learning journey, it is a great resource.

We recommend doing all of your Kubernetes learning on the CLI so you can develop the muscle memory to run these commands without having to run through the Kubernetes documentation.

Help

Katacoda offerings an Interactive Learning Environment for Developers. This course uses a command line and a pre-configured sandboxed environment for you to use. Below are useful commands when working with the environment.

cd <directory>

Change directory

ls

List directory

echo 'contents' > <file>

Write contents to a file

cat <file>

Output contents of file

Vim

In the case of certain exercises you will be required to edit files or text. The best approach is with Vim. Vim has two different modes, one for entering commands (Command Mode) and the other for entering text (Insert Mode). You need to switch between these two modes based on what you want to do. The basic commands are: