用minikube运行一个本地单节点Kubernetes集群
* 安装Minikube
mac:
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.23.0/minikube-darwin-amd64
linux:
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.23.0/minikube-linux-amd64
chmod a+x minikube
sudo cp minikube /usr/local/bin/
wget http://47.93.27.106/share/minikube.mac
* 使用minikube启动一个kubernetes集群
minikube start
========================================
kubectl could not be found on your path. kubectl is a requirement for using minikube
To install kubectl, please run the following:
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.8.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
To disable this message, run the following:
minikube config set WantKubectlDownloadMsg false
========================================
Starting local Kubernetes v1.8.0 cluster...
Starting VM...
E0310 15:40:41.822355 7185 start.go:150] Error starting host: Error creating host: Error executing step: Running precreate checks.
: VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path.
Retrying.
E0310 15:40:41.822851 7185 start.go:156] Error starting host: Error creating host: Error executing step: Running precreate checks.
: VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path
* 安装kubernetes
cd $GOPATH/src/k8s.io/
git clone https://github.com/kubernetes/kubernetes
cd kubernetes
make
cd $GOPATH/src/k8s.io/kubernetes/cmd/kubectl
go build
go install
which kubectl
/opt/go/1.12/bin/kubectl
* docker重装, 安装 kubernetes
sudo yum erase docker-ce
sudo yum install kubernetes
which kubectl
/usr/bin/kubectl
* VirtualBox虚拟机下载
https://www.virtualbox.org/wiki/Linux_Downloads
wget https://download.virtualbox.org/virtualbox/6.0.4/VirtualBox-6.0-6.0.4_128413_el7-1.x86_64.rpm
sudo yum install VirtualBox-6.0-6.0.4_128413_el7-1.x86_64.rpm
* 重试 启动一个minikube虚拟机
minikube start
Starting local Kubernetes v1.8.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
E0310 15:54:21.734335 17579 start.go:222] Error updating cluster: Error updating localkube from uri: Error attempting to download and cache localkube: Error getting localkube download url: Error getting valid localkube versions: Error getting the localkube versions: Error getting json via http with url: https://storage.googleapis.com/minikube/k8s_releases.json: Error getting json from url: https://storage.googleapis.com/minikube/k8s_releases.json via http: Get https://storage.googleapis.com/minikube/k8s_releases.json: dial tcp 172.217.163.240:443: i/o timeout
================================================================================
An error has occurred. Would you like to opt in to sending anonymized crash
information to minikube to help prevent future errors?
To opt out of these messages, run the command:
minikube config set WantReportErrorPrompt false
================================================================================
Please enter your response [Y/n]: Y
ISSUE:
1. 网络不通?
2. This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory.
在真实机器上做, 不能在云主机上搞.
* 使用kubectl查看集群是否正常工作
$ kubectl cluster-info
Kubernetes master is running at https://192.168.99.100:8443
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
** 可以运行minikube ssh登录到Minikube VM并从内部探索它
$ minikube ssh
代码以及命令行下载
git clone git://github.com/luksa/kubernetes-in-action