当前位置: 首页 > 工具软件 > minishift > 使用案例 >

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

柳高卓
2023-12-01

虚拟化支持:

  • 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 <bparees@users.noreply.github.com>
    Date:    Thu Oct 19 14:56:53 2017 +0200
---> Installing application source ...
---> Building your Node application from source
npm WARN deprecated to-iso-string@0.0.2: to-iso-string has been deprecated, use @segment/to-iso-string instead.
npm WARN deprecated jade@0.26.3: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
nodejs-ex@0.0.1 /opt/app-root/src
+-- chai@3.5.0
| +-- assertion-error@1.0.2
| +-- deep-eql@0.1.3
| | `-- type-detect@0.1.1
| `-- type-detect@1.0.0
+-- chai-http@2.0.1
| +-- cookiejar@2.0.6
| +-- is-ip@1.0.0
| | `-- ip-regex@1.0.3
| +-- methods@0.0.1
| +-- qs@2.0.0
| `-- superagent@1.2.0
|   +-- component-emitter@1.1.2
|   +-- cookiejar@2.0.1
|   +-- extend@1.2.1
|   +-- form-data@0.2.0
|   | +-- async@0.9.2
|   | +-- combined-stream@0.0.7
|   | | `-- delayed-stream@0.0.5
|   | `-- mime-types@2.0.14
|   |   `-- mime-db@1.12.0
|   +-- formidable@1.0.14
|   +-- methods@1.0.1
|   +-- mime@1.3.4
|   +-- qs@2.3.3
|   +-- readable-stream@1.0.27-1
|   | +-- isarray@0.0.1
|   | `-- string_decoder@0.10.31
|   `-- reduce-component@1.0.1
+-- ejs@2.5.7
+-- express@4.16.2
| +-- accepts@1.3.4
| | +-- mime-types@2.1.17
| | | `-- mime-db@1.30.0
| | `-- negotiator@0.6.1
| +-- array-flatten@1.1.1
| +-- body-parser@1.18.2
| | +-- bytes@3.0.0
| | +-- http-errors@1.6.2
| | | `-- setprototypeof@1.0.3
| | +-- iconv-lite@0.4.19
| | +-- qs@6.5.1
| | `-- raw-body@2.3.2
| +-- content-disposition@0.5.2
| +-- content-type@1.0.4
| +-- cookie@0.3.1
| +-- cookie-signature@1.0.6
| +-- debug@2.6.9
| | `-- ms@2.0.0
| +-- depd@1.1.1
| +-- encodeurl@1.0.1
| +-- escape-html@1.0.3
| +-- etag@1.8.1
| +-- finalhandler@1.1.0
| | `-- unpipe@1.0.0
| +-- fresh@0.5.2
| +-- merge-descriptors@1.0.1
| +-- methods@1.1.2
| +-- on-finished@2.3.0
| | `-- ee-first@1.1.1
| +-- parseurl@1.3.2
| +-- path-to-regexp@0.1.7
| +-- proxy-addr@2.0.2
| | +-- forwarded@0.1.2
| | `-- ipaddr.js@1.5.2
| +-- qs@6.5.1
| +-- range-parser@1.2.0
| +-- safe-buffer@5.1.1
| +-- send@0.16.1
| | +-- destroy@1.0.4
| | `-- mime@1.4.1
| +-- serve-static@1.13.1
| +-- setprototypeof@1.1.0
| +-- statuses@1.3.1
| +-- type-is@1.6.15
| | +-- media-typer@0.3.0
| | `-- mime-types@2.1.17
| |   `-- mime-db@1.30.0
| +-- utils-merge@1.0.1
| `-- vary@1.1.2
+-- mocha@2.5.3
| +-- commander@2.3.0
| +-- debug@2.2.0
| | `-- ms@0.7.1
| +-- diff@1.4.0
| +-- escape-string-regexp@1.0.2
| +-- glob@3.2.11
| | +-- inherits@2.0.3
| | `-- minimatch@0.3.0
| |   +-- lru-cache@2.7.3
| |   `-- sigmund@1.0.1
| +-- growl@1.9.2
| +-- jade@0.26.3
| | +-- commander@0.6.1
| | `-- mkdirp@0.3.0
| +-- mkdirp@0.5.1
| | `-- minimist@0.0.8
| +-- supports-color@1.2.0
| `-- to-iso-string@0.0.2
+-- mongodb@2.2.33
| +-- es6-promise@3.2.1
| +-- mongodb-core@2.1.17
| | +-- bson@1.0.4
| | `-- require_optional@1.0.1
| |   +-- resolve-from@2.0.0
| |   `-- semver@5.4.1
| `-- readable-stream@2.2.7
|   +-- buffer-shims@1.0.0
|   +-- core-util-is@1.0.2
|   +-- isarray@1.0.0
|   +-- process-nextick-args@1.0.7
|   +-- string_decoder@1.0.3
|   `-- util-deprecate@1.0.2
+-- morgan@1.9.0
| +-- basic-auth@2.0.0
| `-- on-headers@1.0.1
`-- object-assign@4.1.0


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 -> 浏览器

 类似资料: