安装并尝试使用 Minishift

OpenShift的简易全合一版本

为了方便地在我手头的环境中快速尝试,我决定试试看。

环境

    • OS: Windows 7 Home Premiun

 

    • CPU: Core7i

 

    • Memory: 4GB

 

    Virtual box 5.2

设置

    • Download minishift.exe

 

    • https://github.com/minishift/minishift/releases

 

    • Run cmd

 

    • C:\drive を作り(https://github.com/minishift/minishift/issues/236)

 

    • そこにダウンロードしたminishift.exeを置く

 

    デフォルト仮想環境がHyper-Vとなっているので、オプションをつけて実行する
c:\drive>minishift.exe start --vm-driver virtualbox
-- Checking if requested hypervisor 'virtualbox' is supported on this platform .
.. OK
-- Checking the ISO URL ... OK
-- Starting profile 'minishift'
-- Starting local OpenShift cluster using 'virtualbox' hypervisor ...
-- Minishift VM will be configured with ...
   Memory:    2 GB
   vCPUs :    2
   Disk size: 20 GB

   Downloading ISO 'https://github.com/minishift/minishift-b2d-iso/releases/down
load/v1.2.0/minishift-b2d.iso'
 40.00 MiB / 40.00 MiB [===========================================] 100.00% 0s
-- 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% used OK
-- Downloading OpenShift binary 'oc' version 'v3.6.0'
 33.92 MiB / 33.92 MiB [===========================================] 100.00% 0s-
- Downloading OpenShift v3.6.0 checksums ... OK
-- OpenShift cluster will be configured with ...
   Version: v3.6.0
-- Checking `oc` support for startup flags ...
   routing-suffix ... OK
   host-config-dir ... OK
   host-data-dir ... OK
   host-pv-dir ... OK
   host-volumes-dir ... OK
Starting OpenShift using openshift/origin:v3.6.0 ...
Pulling image openshift/origin:v3.6.0
Pulled 1/4 layers, 26% complete
Pulled 1/4 layers, 74% complete
Pulled 2/4 layers, 84% complete
Pulled 3/4 layers, 88% complete
Pulled 4/4 layers, 100% complete
Extracting
Image pull complete
OpenShift server started.

The server is accessible via web console at:
    https://192.168.99.100:8443

You are logged in as:
    User:     developer
    Password: <any value>

To login as administrator:
    oc login -u system:admin


c:\drive>

访问

使用浏览器访问https://192.168.99.100:8443。
管理员使用ID = system,密码 = admin进行访问。

首先,创建一个项目。

命令行界面

在cmd中先添加执行路径,然后使用oc命令。

C:\>cd c:\drive

c:\drive>minishift.exe oc-env
SET PATH=C:\Users\hoge\.minishift\cache\oc\v3.6.0\windows;%PATH%
REM Run this command to configure your shell:
REM     @FOR /f "tokens=*" %i IN ('minishift oc-env') DO @call %i

c:\drive>SET PATH=C:\Users\hoge\.minishift\cache\oc\v3.6.0\windows;%PATH%
c:\drive>REM     @FOR /f "tokens=*" %i IN ('minishift oc-env') DO @call %i

c:\drive>oc status
In project My Project (myproject) on server https://192.168.99.100:8443

You have no services, deployment configs, or build configs.
Run 'oc new-app' to create an application.

运行示例应用程序

C:\drive> oc new-app https://github.com/openshift/nodejs-ex -l name=mya
pp
--> Found image 0129e5e (About an hour old) in image stream "openshift/nodejs" u
nder tag "6" for "nodejs"

    Node.js 6
    ---------
    Node.js 6 available as docker container is a base platform for building and
running various Node.js 6 applications and frameworks. Node.js is a platform bui
lt on Chrome's JavaScript runtime for easily building fast, scalable network app
lications. Node.js uses an event-driven, non-blocking I/O model that makes it li
ghtweight and efficient, perfect for data-intensive real-time applications that
run across distributed devices.

    Tags: builder, nodejs, nodejs6

    * The source repository appears to match: nodejs
    * A source build using source code from https://github.com/openshift/nodejs-
ex will be created
      * The resulting image will be pushed to image stream "nodejs-ex:latest"
      * Use 'start-build' to trigger a new build
      * WARNING: this source repository may require credentials.
                 Create a secret with your git credentials and use 'set build-se
cret' to assign it to the build config.
    * This image will be deployed in deployment config "nodejs-ex"
    * Port 8080/tcp will be load balanced by service "nodejs-ex"
      * Other containers can access this service through the hostname "nodejs-ex
"

--> Creating resources with label name=myapp ...
    imagestream "nodejs-ex" created
    buildconfig "nodejs-ex" created
    deploymentconfig "nodejs-ex" created
    service "nodejs-ex" created
--> Success
    Build scheduled, use 'oc logs -f bc/nodejs-ex' to track its progress.
    Run 'oc status' to view your app.

可以确认构建和部署的进度

C:\drive>oc logs -f bc/nodejs-ex
Cloning "https://github.com/openshift/nodejs-ex" ...
        Commit: d1af14dc9fcabc06a5b2987e94de92c730d878f1 (Merge pull request #1
9 from gabemontero/app-label)
        Author: Ben Parees <bparees@users.noreply.github.com>
        Date:   Thu Nov 9 11:13:37 2017 -0500
---> 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 t
e 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

中略

Pushed 8/10 layers, 82% complete
Pushed 8/10 layers, 86% complete
Pushed 8/10 layers, 93% complete
Pushed 8/10 layers, 97% complete
Pushed 9/10 layers, 99% complete
Pushed 10/10 layers, 100% complete
Push successful
c:\drive>oc expose svc/nodejs-ex
route "nodejs-ex" exposed

c:\drive> minishift openshift service nodejs-ex --in-browser
Opening the route/NodePort http://nodejs-ex-myproject.192.168.99.100.nip.io in t
he default browser...

c:\drive>

使用浏览器访问 http://nodejs-ex-myproject.192.168.99.100.nip.io/。

欢迎来到您在OpenShift上的Node.js应用程序页面。

广告
将在 10 秒后关闭
bannerAds