Skip to content

lesson-01

Forward

Thank you for taking the time to start reading this educational material.

I hope this hands-on, interactive lesson can reduce the startup cost in your journey to learning Kubernetes.

The Web Terminal

If you want to take advantage of the interactive, hands-on nature of these labs, you'll need to either already have a web terminal connection available or fire one up yourself.

Instructions for that can be found here.

Lesson 01

This lesson will cover the following exercises:

  • Installing kind
  • Installing helm
  • Initialize a local Kubernetes cluster using kind

What is Kubernetes?

Kubernetes is a microservices architecture (MSA) platform for automating deployment, operations and scaling of containerized applications.

It can run anywhere where Linux runs and supports on-premise, hybrid and public cloud deployments.

Exercise 1 - Install prerequisites

Install Kind

We'll be using kind to initialize our demo cluster.

Below are several means of installing the kind binary

Install on Linux
export KIND_VERSION=v0.14.0
curl -fLo ./kind "https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64" \
&& chmod +x ./kind \
&& mv ./kind /usr/local/bin/kind
Install on OSX (ARM)

If you have homebrew installed, you can simply run brew install kind.

Otherwise you download via curl:

export KIND_VERSION=v0.14.0 
curl -fLo ./kind "https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-darwin-arm64" \
&& chmod +x ./kind \
&& mv ./kind /usr/local/bin/kind
Install on Windows

On Windows, we can use chocolatey to install: choco install kind

Manually download binary

You can manually download the kind binary from https://github.com/kubernetes-sigs/kind/releases to get started

Install helm

Below are several means of installing the helm binary

Install on Linux
export HELM_VERSION=v3.9.2
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 \
&& chmod +x get_helm.sh && DESIRED_VERSION=$HELM_VERSION ./get_helm.sh
Install on OSX (ARM)

If you have homebrew installed, you can simply run brew install helm.

Install on Windows

On Windows, we can use chocolatey to install: choco install helm

Manually download binary

You can manually download the kind binary from https://github.com/helm/helm/releases to get started

Exercise 2 - Initialize a local Kubernetes cluster

For those of you not familiar with the tool, it's used for running local Kubernetes clusters using Docker containers as worker nodes.

I've already installed version v0.14.0 of the tool: kind version

The syntax for creating a Kubernetes cluster using the kind command is quite simple.

We can run kind create cluster --help to get more info, but you can create a cluster by just running kind create cluster.

For our demonstration, we'll create a Kubernetes cluster named k8s-demo with some customizations

echo -e """
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraPortMappings:
  - containerPort: 30001
    hostPort: 30001
  - containerPort: 30002
    hostPort: 30002
- role: worker
"""  | kind create cluster --name k8s-demo --config=-

Next, we'll initialize our Kubernetes config and context.

You can retrieve your cluster's kubeconfig via the command kind --name k8s-demo get kubeconfig

We'll pipe that to our kubeconfig file using the tee command:
kind --name k8s-demo get kubeconfig | tee ~/.kube/k8s-demo.yaml

We'll then set our KUBECONFIG environmental variable to read any yaml files under our ~/.kube directory: export KUBECONFIG=$(ls ~/.kube/*.yaml | tr '\n' ':')
then set our active Kubernetes context: kubectl config use-context kind-k8s-demo

Verify things are working with: kubectl cluster-info

You should now be ready to start playing with Kubernetes.