Unit #1
Hello, k8s!


use ←↑↓→ or <space>

Skyscrapers vs. Skylines

 
 
 
 
 
 
 
 
 
 

Scaling up

Adds resources (CPU, memory) to the server

Oldest capacity management method

Limitations

Hardware can only get so big

Time, money, or technical reasons

 
 
 
 
 
 
 

Scaling out

Adds more servers to application

Multiple for the same part of the app

Limitations

Requires app re-architecting

Can be difficult for humans to manage, troubleshoot

Containers and clustering

 
 
 
 
 
 
 

Dependencies

Libraries, versions, key configuration

Co-hosted apps may have conflicting requirements!

Containers

Packages OS image with application

Dependencies managed as single unit

Docker

Popular container toolkit

Simplifies underlying container details

Strong developer support

 

Clustering containers

Requires deep knowledge

Difficult to manage manually

What to manage?

  • Provisioning
  • Resource limits & access policies
  • Network, firewall, load balancing
  • Health monitoring
  • Lots more...
 

Kubernetes to the rescue!

Container orchestrator

Coordinates hosts (nodes) to act as one

Deploys instances, distributes load, delivers resources

Open source

Created by Google, maintained by CNCF

Available on Github

Expressive power

Pods only one manageable object

Taylor k8s to your app, not the other way around

Interacting

Objects defined as declarative YAML

Can be live edited, patched, diffed

Terminal friendly

kubectl command

Single point of access to cluster

Plays well with scripts, automation

Hosting Kubernetes

Self-hosting

More work, but you control everything

Requires dedicated staff to maintain

Dedicated manager node required

Installation

  1. Install Docker, kubelet
  2. Install kubeadm, kubectl on manager
  3. Install Container Networking, such as Calico
  4. Use kubeadm to stand up cluster

Tutorial on Linode docs

Storage

Requires additional infrastructure for k8s

NFS works, Ceph, Rook, Heketi are k8s native

Managed hosting

Like a VPS, but for k8s workloads

Pay only for workers, storage baked in

Providers

Amazon, Azure, DigitalOcean, Google GKE, others

Pick the Right Solution on k8s docs

Digitalocean

Worldwide k8s provider

REST-based API

Creating a cluster

Planning

Always estimate capacity first!

New servers easier to add in k8s

Server count

2 worker nodes minimum

3 or more is best

CPU, memory

Balance hosting costs with needed resources

Start with today's resources * 1.25

Flexibility

Scaling out easier on managed k8s

Plan, but not too hard!

Allocation

Done at hosting provider level

Via web portal, API, or dedicated CLI app

Not kubectl!

Using the API

POST a JSON request using curl

ten7.digitalocean role on Ansible Galaxy

Using the web portal

cloud.digitalocean.com

Create > Clusters

 
 
 
 

Using kubectl

Installation

Multiple options, different pros, cons

From dist

Installs only needed binaries

kubernetes.io/docs/tasks/tools/install-kubectl

Package Manager

homebrew on macOS

Chocolatey, Scoop, or Powershell Gallery On Windows

Linux: use your distro's default

Docker for Mac, Win

kubectl included out of the box

Docker needed to develop containers

Large (1GB) download, requires account

Authorizing

Depends on hosting provider

CLI command, auth token, kubeconfig file

Getting kubeconfig

  1. cloud.digitalocean.com
  2. Manage > Kubernetes
  3. Click Download config file
 

Getting via API

Better for scripts, automation

ten7.digitalocean_kubeconfig role

Using a Service Account

Requires prior access

Advanced, has security implications

Command form

kubectl verb object

Listing worker nodes

$ kubectl get nodes

NAME            STATUS   ROLES    AGE     VERSION
web-pool-b64y   Ready    <none>   2d13h   v1.13.10
web-pool-b6hs   Ready    <none>   2d13h   v1.13.10
web-pool-b6hu   Ready    <none>   2d14h   v1.13.10

Getting details

kubectl describe node nodeName

Lists status, CPU, memory allocation, and more

Lab #1

  1. Install kubectl
  2. Create cluster
  3. Download kubeconfig file
  4. Interact with cluster