Kubernetes Overview

Container Orchestration & Microservices

Posted by Craig Johnston on Thursday, March 1, 2018
SHARE

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

Command Description
kubectl get pods -o wide Get information about all running pods in the default namespace
kubectl get pods -o wide --namespace=test Get information about all running pods in the test namespace
kubectl describe pod <pod> Describe one pod
kubectl expose pod <pod> --port=2701 --name=api Expose the port of a pod (creates a new service)
kubectl attach <podname> -i Attach to a pod
kubectl exec <pod> -- command Execute a command in the pod
kubectl label pods <pod> mylabel=fun Add a new label to a pod
kubectl run -i --tty alpine --image=alpine --restart=Never --sh Run 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.

Kubernetes Overview: Container Orchestration & Microservices by Craig Johnston is licensed under a Creative Commons Attribution 4.0 International License. Creative Commons License


SHARE
FOLLOW