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.
- Deeper Reading and Resources
- Test Installation
- Get some status
- Create a Deployment
- Useful Commands
Deeper Reading and Resources
- Official Kubernetes Tutorials
- Udacity: Scalable Microservices with Kubernetes
- Kubernetes The Hard Way For anyone planning to support a production Kubernetes cluster and wants to understand how everything fits together.
- Lynda: Learning Kubernetes
- Lynda: Kubernetes: Native Tools
- Udemy: Learn DevOps: The Complete Kubernetes Course
- Udemy: Learn DevOps: Advanced Kubernetes Usage
$ 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
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
||Get information about all running pods in the default namespace|
||Get information about all running pods in the test namespace|
||Describe one pod|
||Expose the port of a pod (creates a new service)|
||Attach to a pod|
||Execute a command in the pod|
||Add a new label to a pod|
||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.