Random   •   Archives   •   RSS   •   About   •   Contact

Minikube

Minikube allows you to run a self contained, single node, Kubernetes cluster on your workstation. Once installed and configured, you may use kubectl to interact with it, just like a production Kubernetes cluster.

Reference: https://kubernetes.io/docs/getting-started-guides/minikube/

install

Requirements: Virtualbox

install kubectl

Reference: https://kubernetes.io/docs/tasks/kubectl/install/

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin

install minikube

Reference: https://github.com/kubernetes/minikube/releases

curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.17.1/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

start

Supported hypervisors: virtualbox, vmwarefusion, kvm, xhyve

minikube start --vm-driver=virtualbox

If this is your first time starting minikube, it will perform the following:

Starting local Kubernetes cluster...
Starting VM...
Downloading Minikube ISO 89.24 MB / 89.24 MB [==============================================] 100.00% 0s
SSH-ing files into VM...
Setting up certs...
Starting cluster components...
Connecting to cluster...
Setting up kubeconfig...
Kubectl is now configured to use the cluster

Also, you should see a new VM running in VirtualBox, like this:

virtualbox running minikube.

To verify that kubectl is configured to use minikube look at the config file (~/.kube/config).

Also try running:

  • kubectl get nodes
  • kubectl get services

You can also connect to the VirtualBox guest using SSH to have a look around. In my case the Minikube VM was assigned 192.168.99.100.

ssh -i ~/.minikube/machines/minikube/id_rsa docker@192.168.99.100

You can see all the containers running with:

docker ps
ps aux

Exit out, you really don't need to interact at this level

Instead we will treat Minikube as a "real" Kubernetes cluster and only use the kubectl tool.

demo

create a deployment

In this example we create an echoserver cluster.

kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080

this command will create -

1 deployment:

kubectl get deployments

1 replicaset:

kubectl get replicasets

1 pod:

kubectl get pods

To make the echoserver accessible externally, you need to expose the deployment, like this:

kubectl expose deployment hello-minikube --type=NodePort

The expose command creates -

1 service:

kubectl get services
NAME            CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
kubernetes      10.0.0.1     <none>        443/TCP          2d
hello-minikube  10.0.0.225   <nodes>       8080:31136/TCP   58m

To access the service, you connect to the Minikube's IP address on the exposed port.

In my case the Minikube VirtualBox IP is 192.168.99.100 and the exposed port is 31136 as listed above.

The minikube tool has a shortcut for this info, try:

minikube service hello-minikube --url
http://192.168.99.100:31136

Toss this into a web browser on your local machine and it should echo back!

scale a deployment

Scale up the deployment named hello-minikube by setting the number of replicas to 3:

kubectl scale deployment hello-minikube --replicas=3

verify:

kubectl get deployments
kubectl get pods

delete a deployment

trash this demo (delete the deployment, replicaset, pods, and service):

kubectl delete deployment hello-minikube



Want comments on your site?

Remarkbox — is a free SaaS comment service which embeds into your pages to keep the conversation in the same place as your contentr. It works everywhere, even static HTML sites like this one!

Remarks: Minikube

© Russell Ballestrini.