容器化应用: 实验环境-安装配置Minishift

虚拟化支持:

  • OS X: xhyve (default), VirtualBox, VMware Fusion
  • GNU/Linux: KVM (default), VirtualBox
  • Windows: Hyper-V (default), VirtualBox

本文所述过程全部在MacOS X环境下完成

启动

命令行和参数

$ minishift start --vm-driver=virtualbox

由于总所周知的原因, 可以使用Docker镜像

$ minishift start --vm-driver=virtualbox --registry-mirror=https://docker.mirrors.ustc.edu.cn

参数 --vm-driver 可用的值有: virtualbox, vmwarefusion, xhyve (默认为xhyve), 由于我的系统上已经安装了VirtualBox, 因此选择 virtualbox, --registry-mirror指定了公共Docker镜像库的地址.

输出

-- Starting local OpenShift cluster using 'virtualbox' hypervisor ...
-- Minishift VM will be configured with ...
   Memory:    2 GB
   vCPUs :    2
   Disk size: 20 GB
-- Starting Minishift VM ......................... OK
-- Checking for IP address ... OK
-- Checking if external host is reachable from the Minishift VM ... 
   Pinging 8.8.8.8 ... OK
-- Checking HTTP connectivity from the VM ... 
   Retrieving http://minishift.io/index.html ... OK
-- Checking if persistent storage volume is mounted ... OK
-- Checking available disk space ... 0% OK
-- OpenShift cluster will be configured with ...
   Version: v3.6.0
-- Checking `oc` support for startup flags ... 
   host-config-dir ... OK
   host-data-dir ... OK
   host-pv-dir ... OK
   host-volumes-dir ... OK
   routing-suffix ... OK
Starting OpenShift using openshift/origin:v3.6.0 ...
Pulling image openshift/origin:v3.6.0
Pulled 1/4 layers, 26% complete
Pulled 2/4 layers, 69% complete
Pulled 3/4 layers, 77% complete
Pulled 4/4 layers, 100% complete
Extracting
Image pull complete
OpenShift server started.

如果过程中出现任何错误, 执行 minishift delete 删除集群然后重试, 启动过程中会下载镜像库等资源, 保持良好的网络连接.

oc 命令添加到PATH中

使用minishift oc-env输出要添加到PATH中的export命令:

export PATH="/Users/username/.minishift/cache/oc/v3.6.0:$PATH"
# Run this command to configure your shell:
# eval $(minishift oc-env)

应用部署

部署一个简单的Node.js应用

$ oc new-app https://github.com/openshift/nodejs-ex -l name=myapp

查看日志输出:

$ oc logs -f bc/nodejs-ex

Cloning "https://github.com/openshift/nodejs-ex" ...
    Commit:    96e651f58aee338e24ea1a170da6d631be1c33da (Merge pull request #143 from bparees/annotations)
    Author:    Ben Parees <[email protected]>
    Date:    Thu Oct 19 14:56:53 2017 +0200
---> Installing application source ...
---> Building your Node application from source
npm WARN deprecated [email protected]: to-iso-string has been deprecated, use @segment/to-iso-string instead.
npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
[email protected] /opt/app-root/src
+-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| `-- [email protected]
+-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| `-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   | +-- [email protected]
|   | +-- [email protected]
|   | | `-- [email protected]
|   | `-- [email protected]
|   |   `-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   | +-- [email protected]
|   | `-- [email protected]
|   `-- [email protected]
+-- [email protected]
+-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | | `-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | | `-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| |   `-- [email protected]
| +-- [email protected]
| `-- [email protected]
+-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| |   +-- [email protected]
| |   `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| `-- [email protected]
+-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| |   +-- [email protected]
| |   `-- [email protected]
| `-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   +-- [email protected]
|   `-- [email protected]
+-- [email protected]
| +-- [email protected]
| `-- [email protected]
`-- [email protected]


Pushing image 172.30.1.1:5000/reactive-microservices/nodejs-ex:latest ...
Pushed 0/9 layers, 17% complete
Pushed 1/9 layers, 12% complete
Pushed 2/9 layers, 23% complete
Pushed 3/9 layers, 34% complete
Pushed 4/9 layers, 47% complete
Pushed 5/9 layers, 62% complete
Pushed 6/9 layers, 73% complete
Pushed 7/9 layers, 83% complete
Pushed 8/9 layers, 100% complete
Pushed 9/9 layers, 100% complete
Push successful

查看控制台地址

$ oc project
Using project "prometheus-example" on server "https://192.168.99.100:8443".

Then:

https://192.168.99.100:8443 -> 浏览器

相关推荐