Kubernetes 1.3 从入门到进阶 安装篇:minikube
Kubernetes单机运行环境一直是一个没有得到重视的问题。现在我们有了minikube,一个用go语言开发的可以在本地运行kubernetes的利器,不过目前应该只是支持kubernetes1.3。如果你只有一台机器或者虚拟机又想试验一下Kubernetes的新的功能,或者作kubernetes上开发的本地环境,minikube可能是你不错的选择。
下载minikube并设定
下载的时候突然发现版本已经是0.7.0了,发现是6个小时之前刚刚更新的,速度好快,从第一次发布的5/31的0.1版,到现在的第七次版本的迭代,基本上平均是一周一个版本的速度,这就是互联网时代的平均数度。当普通的企业推出新机能的时候,一般是在和用户的耐心在赛跑。但是一周一次的版本更新基本上是在脱着用户前进的节奏。下载来看看吧。
# curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.7.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 72.0M 100 72.0M 0 0 866k 0 0:01:25 0:01:25 --:--:-- 889k
[root@liumiao tmp]#
- 1
- 2
- 3
- 4
- 5
确认minikube
# which minikube
/usr/local/bin/minikube
# minikube version
There is a newer version of minikube available (v0.7.0). Download it here:
https://github.com/kubernetes/minikube/releases/tag/v0.7.0
To disable this notification, add WantUpdateNotification: False to the json config file at /root/.minikube/config
(you may have to create the file config.json in this folder if you have no previous configuration)
minikube version: v0.6.0
#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
简单解释
curl -Lo 会把minikube下载到本地
chmod +x 给其加上执行权限
mv kubectl /usr/local/bin下是因为普通用户的path中缺省的有/usr/local/bin
minikube version: v0.6.0 ?这是个什么节奏,我只是想看个版本号。
按照提示,创建了其提示的目录,明确提示是0.6.0的版本。
# mkdir -p /root/.minikube/config
# minikube version
minikube version: v0.6.0
#
- 1
- 2
- 3
- 4
找到一台能够连接google机器,一样做了一遍,版本正常显示。0.6也好0.7也罢,继续前进。
# minikube version
minikube version: v0.7.0
#
- 1
- 2
- 3
下载kubectl并设定
我们还需要下载kubectl并设定
# curl -Lo kubectl http://storage.googleapis.com/kubernetes-release/release/v1.3.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 53.8M 100 53.8M 0 0 688k 0 0:01:20 0:01:20 --:--:-- 874k
#
- 1
- 2
- 3
- 4
- 5
确认kubectl
# which kubectl
/usr/local/bin/kubectl
# kubectl version
Client Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.0", GitCommit:"283137936a498aed572ee22af6774b6fb6e9fd94", GitTreeState:"clean", BuildDate:"2016-07-01T19:26:38Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?
#
- 1
- 2
- 3
- 4
- 5
- 6
我们已经看到了新的版本信息了,Client Version: version.Info{Major:”1”, Minor:”3”, GitVersion:”v1.3.0”, Marjor的版本号1,Minor的3,1.3.0的kubernetes。但是为什么被8080refused了呢。别着急,还没有启动呢,这是没有成功连接kubernetes apiserver的节奏,一切正常,到目前为止,我们只是下载了一个可执行文件设置了权限而已。
安装条件
google官方是这样写的,Minikube requires the latest Virtualbox to be installed on your system,那么我们看看不安装会怎样。
# minikube start
Starting local Kubernetes cluster...
E0726 05:33:07.585166 4210 start.go:78] Error starting host: Error creating. Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path"
#
- 1
- 2
- 3
- 4
好的,我们会好好安装的。有Virtualbox的可以跳过此步,minikube start不出错,就可以使用了。
CentOS上安装VB5.10。
# cd /etc/yum.repos.d/
# wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
# yum update
# yum install binutils qt gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms
# export KERN_DIR=/usr/src/kernels/3.10.0-327.22.2.el7.x86_64
注意此处根据具体情况3.10.0-327.22.2.el7.x86_64可能有所变化
# yum install VirtualBox-5.1
log的确认:/var/log/vbox-install.log
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
BIOS或者虚拟机设定:VT-X/AMD-v
# minikube start
Starting local Kubernetes cluster...
E0727 06:27:17.242507 66718 start.go:78] Error starting host: Error creating. Error with pre-create check: "This computer doesn‘t have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory"
#
- 1
- 2
- 3
- 4
vmware的设定方法:VM => “Settings…” => Processors => 选中复选框Virtualize Intel VT-x/EPT or AMD-V/RVI
注意:只能在VM停下来的时候才能设定
BIOS的设定请根据机器型号自行google
启动:VirtualBox版本提示错误
# minikube start
Starting local Kubernetes cluster...
E0727 06:41:54.512097 3933 start.go:78] Error starting host: Error creating. Error with pre-create check: "We support Virtualbox starting with version 5. Your VirtualBox install is \"WARNING: The vboxdrv kernel module is not loaded. Either there is no module\\n available for the current kernel (3.10.0-327.22.2.el7.x86_64) or it failed to\\n load. Please recompile the kernel module and install it by\\n\\n sudo /sbin/vboxconfig\\n\\n You will not be able to start VMs until this problem is fixed.\\n5.1.2r108956\". Please upgrade at https://www.virtualbox.org"
#
- 1
- 2
- 3
- 4
被提示The vboxdrv kernel module is not loaded, 启动一下Virtualbox的Service吧
# /usr/lib/virtualbox/vboxdrv.sh setup
vboxdrv.sh: Starting VirtualBox services.
- 1
- 2
启动:成功
# minikube start
Starting local Kubernetes cluster...
Kubernetes is available at https://192.168.99.100:8443.
Kubectl is now configured to use the cluster.
#
- 1
- 2
- 3
- 4
- 5
总结
看起来很美好,目前用起来不是太方便。没有防火墙和内网限制的可以自由的使用非常方便。
安装脚本
#!/bin/bash
MINI_VERSION="0.8.0"
KUBE_VERSION="1.3.0"
MACHINE_VERSION="0.8.1"
curl -L https://github.com/docker/machine/releases/download/v${MACHINE_VERSION}/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine && chmod +x /usr/local/bin/docker-machine
which docker-machine
docker-machine version
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v${MINI_VERSION}/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
which minikube
minikube version
curl -Lo kubectl http://storage.googleapis.com/kubernetes-release/release/v${KUBE_VERSION}/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
kubectl version
cd /etc/yum.repos.d/
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
yum update -y
yum install -y binutils qt gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms
DIR=`ls -lrt /usr/src/kernels/|tail -n1 |awk ‘{print $NF}‘`
export KERN_DIR="/usr/src/kernels/${DIR}"
yum install VirtualBox-5.1
/usr/lib/virtualbox/vboxdrv.sh setup
minikube start
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net
原文地址:https://www.cnblogs.com/firsttry/p/10100380.html