Also at Deasil Works · txn2 · Plexara
Profiles GitHub · X · LinkedIn
Theme Light · Auto · Dark
Professional notes by Craig Johnston
long-form, short-form, working drafts · since 2008
VOL. XIX · MMXXVI
82 NOTES IN PRINT
FOLIO IV 01 MAR 2018 · 3 MIN · SHORT-FORM

Kubernetes Overview

Container Orchestration & Microservices

Diagram · folio iv
mindmap
  root((Kubernetes basics))
    Workloads
      Pod
      Deployment
      StatefulSet
      DaemonSet
      Job
      CronJob
    Networking
      Service
      Ingress
      NetworkPolicy
      DNS
    Storage
      Volume
      PersistentVolume
      PersistentVolumeClaim
      StorageClass
    Config
      ConfigMap
      Secret
    Access
      Namespace
      RBAC
      ServiceAccount
    Tools
      kubectl
      kubeadm
      minikube
      helm

Getting started with Kubernetes for local development. I develop on a Mac however much of this is easily translated to windows.

The following is primarily a getting started guide wrapped around my personal development notes. This set of notes are specifically for my co-workers in helping them get up to speed quickly. If you see an error feel free to make a pull request or just add an issue.

§Contents

§Deeper Reading and Resources

§Free Courses

§Prerequisites

§Test Installation

$ minikube version
minikube version: v0.25.0

$ minikube start
Starting local Kubernetes v1.9.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.

$ minikube addons list
- addon-manager: enabled
- coredns: disabled
- dashboard: enabled
- default-storageclass: enabled
- efk: disabled
- freshpod: disabled
- heapster: disabled
- ingress: disabled
- kube-dns: enabled
- registry: disabled
- registry-creds: disabled
- storage-provisioner: enabled


# enable heapster for CPU and mem
$ minikube addons enable heapster
heapster was successfully enabled

# open the dashboard (in a browser)
$ minikube dashboard

§Get some status

# are we running a cluster?
$ kubectl cluster-info
Kubernetes master is running at https://192.168.99.100:8443

# we should have a minikube node
$ kubectl get nodes
NAME       STATUS    ROLES     AGE       VERSION
minikube   Ready     <none>    2d        v1.9.0

§Architecture

Read Kubernetes Basics for a better understanding.

  • A Cluster has Nodes
  • A Node has Pods
  • A Pod has (Docker in our case) containers and volumes

§Create a Deployment

Run a “hello world” using example echoserver


# get a list of commands
$ kubectl run --help

# run a hello world echo server
$ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080

deployment "hello-minikube" created

# expose the node's port
$ kubectl expose deployment hello-minikube --type=NodePort

service "hello-minikube" exposed

# get the URL
$ minikube service hello-minikube --url

http://192.168.99.100:31923

§Useful Commands

CommandDescription
kubectl get pods -o wideGet information about all running pods in the default namespace
kubectl get pods -o wide --namespace=testGet information about all running pods in the test namespace
kubectl describe pod <pod>Describe one pod
kubectl expose pod <pod> --port=2701 --name=apiExpose the port of a pod (creates a new service)
kubectl attach <podname> -iAttach to a pod
kubectl exec <pod> -- commandExecute a command in the pod
kubectl label pods <pod> mylabel=funAdd a new label to a pod
kubectl run -i --tty alpine --image=alpine --restart=Never --shRun a shell in a pod

§Port Forwarding / Local Development

Check out kubefwd for a simple command line utility that bulk forwards services of one or more namespaces to your local workstation.

← back to all notes