Skip to content

Using Kubernetes

Success
  • See minikube for a small local K8s with a focus on ease and learning.
  • Use the minikube dashboard command to get a graphical view of your cluster
  • Look into important tools for supporting k8s deployments such as Linkerd, Dapr, and Prometheus

Kubernetes (k8s) is a distributed container orchestration tool. It allows one to schedule and run containers across a group of machines, either physical or virtual. A k8s container isn't tied to an individual machine, but is instead abstracted across the cloud. K8s allows you to move your Docker workflows, but manage complexities that arise when deploying them at scale.

  • Cluster: To run k8s, several items need to be present, including a control plane (which is itself a set of applications) and worker nodes. When all of these are up and running together, the collection is said to be a k8s cluster. For a more details on what constitutes a cluster, see Kubernetes Components.
  • Deployment. K8s lets you specify how many times an application should be deployed, memory allocations, etc. When this is boxed up, you get a k8s deployment.
  • Development. For each deployment, k8s will also create a service that lets you connect your services.
  • Monitoring. Give you observability into the internal of your applications by providing metrics on CPU usage, etc.

K8s cluster

k8s-high-level-diagram

+

By default, k8s is significantly more restrictive regarding networking setup than anything you may be used to with Docker.

Important Commands

The kubectl program is used to control k8s clusters

kubectl cluster-info

kubectl apply -f <filename>

  • Change the current configuration of our cluster

kubectl get <resource>

  • Show information about resources

<resources>

  • pods
  • services
  • nodes
  • deployments

minikube ip

  • Retrieves the IP of your running k8s Node (VM)

To access a pod within your k8s cluster use this IP instead of localhost.

minikube start

  • Starts a local k8s cluster

minikube dashboard

  • Starts a k8s web-UI for inspecting the cluster

K8s Deployment

As developers, we work with the master via kubectl, not with any node directly. We will always use the kubectl tools to manage the containers and worker nodes.

Key Idea

The master is always monitoring the state of the system and works to fulfill the requirements we define in our configuration files.

Understanding Kubernetes
  • Kubernetes is a system to deploy containerized apps.
  • Nodes are individual machines (or VM's) that run containers.
  • Masters are machines (or VM's) with a set of programs to manage nodes
  • K8s doesn't build our images, it retrieves them from somewhere called a registry.
  • K8s selects where to run each container, that is, on which machines.
  • To deploy something, we update the desired state of the master config file.

Terminology

  • Worker node: Represents a single host, e.g., a server stack or machine, running containerized applications (pods).
  • Scheduling:
  • Auto healing:
  • Auto scaling:
  • Load balancing:
  • Kubernetes Object: "Persistent entities in the Kubernetes system [...] used to represent the state of a cluster" (see Understanding Kubernetes Objects). Objects describe which containerized apps are running, resources available, and enforced behaviour. Objects are described with in .yaml files.

Resources

ADDITIONAL RESOURCES