Chapter 2. Creating a Kubernetes Cluster

In this chapter we discuss multiple ways to set up a full-blown Kubernetes cluster. We cover low-level, standardized tooling (kubeadm) that also serves as the basis for other installers and show you where to find the relevant binaries for the control plane, as well as for worker nodes. We discuss a containerized Kubernetes setup with hyperkube, demonstrate how to write systemd unit files to supervise Kubernetes components, and finally show how to set up clusters in Google Cloud and on Azure.

2.1 Installing kubeadm to Create a Kubernetes Cluster

Problem

You want to use kubeadm to bootstrap a Kubernetes cluster from scratch.

Solution

Download the kubeadm CLI tool from the Kubernetes package repository.

You will need kubeadm installed on all the servers that will be part of your Kubernetes cluster—not only the master, but also all the nodes.

For example, if you are using Ubuntu-based hosts, on each host do the following as root to set up the Kubernetes package repository:

# apt-get update && apt-get install -y apt-transport-https

# curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

# cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
  deb http://apt.kubernetes.io/ kubernetes-xenial main
  EOF

# apt-get update

Now you can install the Docker engine and the various Kubernetes tools. You will need the following:

  • The kubelet binary

  • The kubeadm CLI

  • The kubectl client

  • kubernetes-cni, the Container Networking Interface ...

Get Kubernetes Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.