minikube on portabledevops
minikube is the solution for single node kubernetes cluster inside a VM.
portabledevops is portable devops tool set on windows, I used msys64 as demo on win7 here.
minikube features
- DNS
- NodePorts
- ConfigMaps and Secrets
- Dashboards
- Container Runtime: Docker, and rkt
- Enabling CNI (Container Network Interface)
- Ingress
kubernetes concept
master
- coordinates all activities in your cluster
- scheduling applications
- maintaining applications’ desired state
- scaling applications
- rolling out new updates
pod
- basic building block of Kubernetes
- represents a running process on your cluster
- a Kubernetes abstraction that represents a group of one or more application containers
- Shared storage, as Volumes
- Networking, as a unique cluster IP address, each container in a Pod shares the network namespace, including the IP address and network ports
- Information about how to run each container, such as the container image version or specific ports to use
node
- a node is worker machine, can be vm or physical
- a pod always run on a node
- a node can have multi pods
- master to handle scheduling
- kubelet is a process for communication between kubernetes master and nodes, managing pods and containers
service
- abstraction which defines a logical set of Pods and a policy by which to access them
- enable a loose coupling between dependent Pods
- defained using YAML (preferred) or JSON
- determined by a LabelSelector
- each Pod has a unique IP address, those IPs are not exposed outside the cluster without a Service
volume
- simply a directory on disk or in another container
- has an explicit lifetime – the same as the pod that encloses it
namespaces
- provide a scope for names
- divide cluster resources between multiple users
deployment
Deployment creates pods with containers inside them, not creating containers directly.
minikube download
This test is on win7 so download latest 64bit binary from link
place to win7, for me is here:
$ which -a minikube /C/oldhorse/portableapps/dockertoolbox/minikube
minikube installation
Let’s start minikube, it create/start a VM in Virtualbox name as minikube:
- memory 2GB
- CPU 2
- disk 20GB
$ minikube version minikube version: v0.22.2 $ minikube start There is a newer version of minikube available (v0.24.1). Download it here: https://github.com/kubernetes/minikube/releases/tag/v0.24.1 To disable this notification, run the following: minikube config set WantUpdateNotification false Starting local Kubernetes v1.7.5 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.
minikube upgrade
From last session there is latest v0.24.1 64bit binary available, download it from link
replace here,
/C/oldhorse/portableapps/dockertoolbox/minikube
Have a try new version of minikube:
$ minikube start Starting local Kubernetes v1.8.0 cluster... Starting VM... E1209 12:10:07.451560 13164 start.go:150] Error starting host: Temporary Error: Error configuring auth on host: ssh command error: command : sudo systemctl -f restart crio err : Process exited with status 5 output : Failed to restart crio.service: Unit crio.service not found.
Not sure the reason behind of those error, would be better to remove cluster and re-create it using new minikube.
$ minikube status minikube:Running cluster:stopped kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100 $ minikube delete Deleting local Kubernetes cluster... Machine deleted. It looks good this time, $ minikube version minikube version: v0.24.1 $ minikube start Starting local Kubernetes v1.8.0 cluster... Starting VM... Downloading Minikube ISO 140.01 MB / 140.01 MB [============================================] 100.00% 0s Getting VM IP address... Moving files into cluster... Downloading localkube binary 148.25 MB / 148.25 MB [============================================] 100.00% 0s 0 B / 65 B [----------------------------------------------------------] 0.00% 65 B / 65 B [======================================================] 100.00% 0sSetting 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 status minikube: Running cluster: Running kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.101
I comment on this existing issue of minikube here
ssh to minikube vm
$ minikube ssh _ _ _ _ ( ) ( ) ___ ___ (_) ___ (_)| |/') _ _ | |_ __ /' __
\| |/' _\| || , < ( ) ( )| '_
\ /'__`\ | ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )( ___/ (_) (_) (_)(_)(_) (_)(_)(_) (_)\___/'(_,__/'
\____) $ hostname minikube $ df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 933M 0 933M 0% /dev tmpfs 1001M 0 1001M 0% /dev/shm tmpfs 1001M 8.8M 992M 1% /run tmpfs 1001M 0 1001M 0% /sys/fs/cgroup /dev/sda1 17G 831M 15G 6% /mnt/sda1 /c/Users 440G 240G 201G 55% /c/Users $
will see minikube service running as docker containers in vm,
$ which -a docker /bin/docker /usr/bin/docker $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES eba767c6b6be gcr.io/google_containers/echoserver "nginx -g 'daemon ..." 12 minutes ago Up 12 minutes k8s_hello-minikube_hello-minikube-57889c865c-zcfcn_default_80f0ba0a-dd07-11e7-bd7f-0800271d37e3_0 b608a9cee6f8 gcr.io/google_containers/pause-amd64:3.0 "/pause" 12 minutes ago Up 12 minutes $ docker inspect eba767c6b6be
reusing docker daemon on host
Above session we demoed how to run and check docker inside minikube vm via ssh, in fact you can reuse local host docker toolset.
First need to export all env to local host, for me it is win7 msys64, it is same position as OSX.
$ minikube docker-env export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.99.101:2376" export DOCKER_CERT_PATH="C:\oldhorse\portableapps\msys64\home\username\.minikube\certs" export DOCKER_API_VERSION="1.23" # Run this command to configure your shell: # eval $(minikube docker-env)
This is just verify not export yet, so need to execute all above by:
$ eval $(minikube docker-env)
then run local docker will give running containers, which same as inside minikube vm,
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES eba767c6b6be gcr.io/google_containers/echoserver "nginx -g 'daemon ..." 19 minutes ago Up 19 minutes k8s_hello-minikube_hello-minikube-57889c865c-zcfcn_default_80f0ba0a-dd07-11e7-bd7f-0800271d37e3_0 b608a9cee6f8 gcr.io/google_containers/pause-amd64:3.0 "/pause" 19 minutes ago Up 19 minutes cut
minikube dashboard
it is web based dashboard,
$ minikube dashboard Opening kubernetes dashboard in default browser... it launch web browser at url: http://192.168.99.101:30000/#!/node?namespace=default
persistent volumes
default persist files stored these folders:
- /data
- /var/lib/localkube
- /var/lib/docker
$ df -h /data Filesystem Size Used Avail Use% Mounted on /dev/sda1 17G 831M 15G 6% /data $ df -h /var/lib/localkube Filesystem Size Used Avail Use% Mounted on /dev/sda1 17G 831M 15G 6% /var/lib/localkube $ df -h /var/lib/docker Filesystem Size Used Avail Use% Mounted on /dev/sda1 17G 831M 15G 6% /var/lib/docker
mounted host folders
this is default shared folder via Virtulbox,
/c/Users 440G 240G 201G 55% /c/Users
it can be used for file transfer between local host and minikube vm.
kubectl
- kubectl a command line interface for running commands against Kubernetes clusters
- deploy and manage applications on Kubernetes
- inspect cluster resources
- create, delete, and update components
kubectl installation
You can download latest win x86 64bit binary,
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.8.0/bin/windows/amd64/kubectl.exe
then add binary to your PATH or place to portable path like me,
$ curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.8.0/bin/windows/amd64/kubectl.exe % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 50.2M 100 50.2M 0 0 4716k 0 0:00:10 0:00:10 --:--:-- 5039k $ which kubectl /C/oldhorse/portableapps/dockertoolbox/kubectl $ cp kubectl.exe /C/oldhorse/portableapps/dockertoolbox/ $ kubectl version Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.0"
kubectl commands
kubectl get nodes kubectl get pods kubectl get services kubectl get deployments