Skip to content

Instantly share code, notes, and snippets.

@jdeathe
Last active March 12, 2017 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdeathe/7d52e94356c7ac1ea1d007bdbbaacd3c to your computer and use it in GitHub Desktop.
Save jdeathe/7d52e94356c7ac1ea1d007bdbbaacd3c to your computer and use it in GitHub Desktop.
Notes made during initial trial of Kubernetes minkube

Notes on first trial of Kubernetes

Using minikube makes it easy to install a single server Kubernetes cluster for local testing/development.

Resources

References

Install kubectl - OSX

Ref: https://kubernetes.io/docs/user-guide/prereqs/

Switch to bash if necessary.

$ bash

Download and install the latest stable release.

$ curl -#LO https://storage.googleapis.com/kubernetes-release/release/$(
    curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt
  )/bin/darwin/amd64/kubectl \
  && install kubectl /usr/local/bin/kubectl

Install minikube - OSX

$ curl -#Lo minikube \
  https://storage.googleapis.com/minikube/releases/v0.17.1/minikube-darwin-amd64 \
  && install minikube /usr/local/bin/minikube

Configure to use VirtualBox by default.

$ minikube config set vm-driver virtualbox

Install xhyve driver (an optional alternative to VirtualBox)

This step is optional. Skip this if intending to use the virtualbox vm driver.

$ brew install docker-machine-driver-xhyve

Start up minkube

Note: This will take some time

$ minikube start

OR, if using xhyve.

$ minikube start --vm-driver=xhyve

Discover minikube IP address

$ minikube ip

OR

$ kubectl cluster-info

Access the Kubernetes Dashboard

$ minikube dashboard

Setup a Deployment

Note: Will take some time pulling images.

$ kubectl create -f php-hello-world.yml --record

How to Delete a Deployment

$ kubectl delete -f php-hello-world.yml

Setup a Service

$ kubectl create -f php-hello-world.svc.yml

Show info on the deployment

$ kubectl get deployment php-hello-world

Scale up from 1 to 3 pods

$ kubectl scale --current-replicas=1 --replicas=3 deployment/php-hello-world

List pods

$ kubectl get pods --show-labels

Check deployment rollout status

$ kubectl rollout status deployment/php-hello-world

Discover Service URL endpoint(s)

$ minikube service php-hello-world --url

Given a pod name, run an interactive bash session

$ kubectl exec -it {pod-name} bash

Updating a deployment

Ref: https://kubernetes.io/docs/user-guide/deployments/#updating-a-deployment

To update the image named php-hello-world to use the tag jdeathe/centos-ssh-apache-php:2.1.1.

$ kubectl set image deployment/php-hello-world php-hello-world=jdeathe/centos-ssh-apache-php:2.1.1

Alternatively, edit the deployment to be applied on save.

$ kubectl edit deployment/php-hello-world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment