Install minikube:
# curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.18.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
Install kubectl:
# curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.5.3/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
- KVM driver
Install Kvm driver:
# curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.7.0/docker-machine-driver-kvm -o /usr/local/bin/docker-machine-driver-kvm
# chmod +x /usr/local/bin/docker-machine-driver-kvm
# apt install libvirt-bin qemu-kvm
启动libvirtd,virtlogd失败:
open("/usr/lib/locale/en_US/LC_NAME", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en/LC_NAME", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_NAME", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_NAME", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
write(2, "/usr/sbin/virtlogd: initializati"..., 42/usr/sbin/virtlogd: initialization failed
运行locale-gen en_US
,参考修改locale。再重启libvirtd和virtlogd:
systemctl restart libvirtd
systemctl restart virtlogd
- Install docker-machine
# curl -L https://github.com/docker/machine/releases/download/v0.10.0/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine && \
chmod +x /usr/local/bin/docker-machine
root@ubuntu:~# docker-machine create --driver kvm vm01
Running pre-create checks...
Creating machine...
(vm01) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/vm01/boot2docker.iso...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env vm01
root@ubuntu:~# docker-machine env vm01
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.42.229:2376"
export DOCKER_CERT_PATH="/root/.docker/machine/machines/vm01"
export DOCKER_MACHINE_NAME="vm01"
# Run this command to configure your shell:
# eval $(docker-machine env vm01)
- libvirt
root@ubuntu:~# ls /etc/libvirt/qemu
minikube.xml networks vm01.xml
virsh # list
Id Name State
----------------------------------------------------
1 vm01 running
virsh # net-list
Name State Autostart Persistent
----------------------------------------------------------
default active yes yes
docker-machines active yes yes
virsh # net-info default
Name: default
UUID: db7fb561-7813-43da-8f07-8a70cf065787
Active: yes
Persistent: yes
Autostart: yes
Bridge: virbr0
virsh # net-info docker-machines
Name: docker-machines
UUID: 89da5ae0-69d1-4437-bbf0-09d803eafb31
Active: yes
Persistent: yes
Autostart: yes
Bridge: virbr1
root@ubuntu:~# docker-machine ssh vm01
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 17.03.1-ce, build HEAD : 4c264fa - Tue Mar 28 21:11:51 UTC 2017
Docker version 17.03.1-ce, build c6d412e
root@ubuntu:~# docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
vm01 - kvm Running tcp://192.168.42.229:2376 v17.03.1-ce
root@ubuntu:~# minikube start --vm-driver kvm --docker-env HTTP_PROXY=http://proxy:8080 --docker-env HTTPS_PROXY=http://proxy:8080
Starting local Kubernetes cluster...
Starting VM...
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.
root@ubuntu:~# minikube docker-env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.42.223:2376"
export DOCKER_CERT_PATH="/root/.minikube/certs"
export DOCKER_API_VERSION="1.23"
# Run this command to configure your shell:
# eval $(minikube docker-env)
root@ubuntu:~# kubectl get nodes
NAME LABELS STATUS AGE
minikube beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=minikube Ready 2h
root@ubuntu:~# kubectl run nginx --image=nginx --port=80
replicationcontroller "nginx" created
root@ubuntu:~# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-jc0k7 0/1 ContainerCreating 0 3s
root@ubuntu:~# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-jc0k7 1/1 Running 0 33s
root@ubuntu:~# minikube stop
Stopping local Kubernetes cluster...
Machine stopped.
参考minikube.
# docker-machine-driver-kvm
docker-machine-driver-kvm: /usr/lib64/libvirt.so.0: version `LIBVIRT_1.1.1' not found (required by docker-machine-driver-kvm)
docker-machine-driver-kvm: /usr/lib64/libvirt.so.0: version `LIBVIRT_1.0.2' not found (required by docker-machine-driver-kvm)
- nest
<cpu mode='custom' match='exact'>
<model fallback='allow'>SandyBridge</model>
<feature policy='require' name='vmx'/>
</cpu>
qemu支持的cpu model:
# qemu-system-x86_64 -cpu ?
x86 qemu64 QEMU Virtual CPU version 2.5+
x86 phenom AMD Phenom(tm) 9550 Quad-Core Processor
x86 core2duo Intel(R) Core(TM)2 Duo CPU T7700 @ 2.40GHz
x86 kvm64 Common KVM processor
x86 qemu32 QEMU Virtual CPU version 2.5+
...