Minishift로 간편하게 Openshift 사용해 보기

Kubernetes|2017. 7. 29. 13:45

Openshift를 설치해서 공부하려니 리눅스 머신에 직접 설치하는건 너무 번거롭고 힘든 일이더군요. Vagrant 버전을 찾아보니, 이는 Minishift라는 것으로 대체된 것을 알게 됐습니다. 설치 중 약간의 문제(아래에 나옵니다)가 있었지만, 사용해 보니 편하게 Openshift를 시작할 수 있는 방법입니다. 윈도 환경에서 설치/사용하는 방법을 소개합니다.

설치

아래가 홈페이지입니다.

https://www.openshift.org/minishift/

다운로드를 하려면 release 페이지로 가서 받으면 됩니다. 현재 v1.3.1이 최신이군요.

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

윈도 64비트 버전(minishift-1.3.1-windows-amd64.zip)을 받습니다.

윈도 버전에는 문제가 조금 있어서 사용자의 홈 디렉토리가 있는 드라이브에 설치를 해야합니다.

C:\minishift 폴더를 만들고 이곳에 위에서 받은 압축 파일의 내용물을 넣습니다.

이제 명령 프롬프트를 실행한 후 위 폴더로 이동한 후 아래 명령으로 Minishift를 실행합니다.

minishift.exe start --vm-driver virtualbox

윈도 버전의 경우 Hyper-V를 하이퍼바이저로 사용하는게 기본인데, 저는 VirtualBox를 사용했습니다. 물론 VirtualBox를 먼저 설치해야겠지요. 최신 버전(v5.1.12 이상)을 사용해 주세요.

아래는 설치 로그인데 중간에 다운로드를 강제 종료하는 부분이 있습니다. 저만 그런지는 모르겠는데 이렇게 하지 않으면 ISO 파일을 받다가 The process cannot access the file because it is being used by another process.. Retrying. 라는 오류를 내면서 더 이상 진행이 안되더군요.

C:\WINDOWS\system32> cd C:\minishift

C:\minishift>
C:\minishift>
C:\minishift> minishift.exe start --vm-driver virtualbox
-- Installing default add-ons ... OK
Starting local OpenShift cluster using 'virtualbox' hypervisor...
Downloading ISO 'https://github.com/minishift/minishift-b2d-iso/releases/download/v1.0.2/minishift-b2d.iso'
 84.57 KiB / 40.00 MiB [>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------]   0.21% 14m32s

# 여기에서 다운로드를 강제 종료
# 시작 명령어 다시 실행

C:\minishift> minishift start --vm-driver virtualbox
Starting local OpenShift cluster using 'virtualbox' hypervisor...
Downloading OpenShift binary 'oc' version 'v1.5.1'
 19.05 MiB / 19.05 MiB [========================================================================================================================================================================================================] 100.00% 0s
-- Checking OpenShift client ... OK
-- Checking Docker client ... OK
-- Checking Docker version ... OK
-- Checking for existing OpenShift container ... OK
-- Checking for openshift/origin:v1.5.1 image ...
   Pulling image openshift/origin:v1.5.1
   Pulled 0/3 layers, 3% complete
   Pulled 0/3 layers, 74% complete
   Pulled 1/3 layers, 88% complete
   Pulled 2/3 layers, 90% complete
   Pulled 3/3 layers, 100% complete
   Extracting
   Image pull complete
-- Checking Docker daemon configuration ... OK
-- Checking for available ports ... OK
-- Checking type of volume mount ...
   Using Docker shared volumes for OpenShift volumes
-- Creating host directories ... OK
-- Finding server IP ...
   Using 192.168.99.100 as the server IP
-- Starting OpenShift container ...
   Creating initial OpenShift configuration
   Starting OpenShift using container 'origin'
   Waiting for API server to start listening
   OpenShift server started
-- Adding default OAuthClient redirect URIs ... OK
-- Installing registry ... OK
-- Installing router ... OK
-- Importing image streams ... OK
-- Importing templates ... OK
-- Login to server ... OK
-- Creating initial project "myproject" ... OK
-- Removing temporary directory ... OK
-- Checking container networking ... OK
-- Server Information ...
   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: developer

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

다운로드를 CTRL+C로 강제 종료한 후 https://github.com/minishift/minishift-b2d-iso/releases/download/v1.0.2/minishift-b2d.iso 파일을 받아서 C:\Users\사용자명\.minishift\cache\iso\ 폴더에 직접 넣어줍니다. 그리고 cache 디렉토리를 제외한 C:\Users\daniel\.minishift\ 디렉토리의 하위 디렉토리를 모두 지웁니다. 이렇게 한 후에 다시 시작 명령을 실행합니다.

minishift.exe start --vm-driver virtualbox

IP나 로그인 정보 등이 나오면서 실행이 완료되면 아래와 같이 몇몇 명령어를 실행해 봅니다.

C:\minishift>minishift ip
192.168.99.100

C:\minishift>minishift status
Running


OC(OpenShift Client Binary) 사용

minishift oc-env 명령을 실행하면, oc를 사용하기 위한 설정 명령어를 출력합니다. 윈도의 경우 출력의 마지막 줄에서 REM을 제거한 텍스트를 실행하면 됩니다.

@FOR /f "tokens=*" %i IN ('minishift oc-env') DO @call %i

아래는 위의 명령을 실행해서 oc를 사용 가능하게 만든 후, oc status를 사용하는 예입니다.

C:\minishift>minishift oc-env
SET PATH=C:\Users\daniel\.minishift\cache\oc\v1.5.1;%PATH%
REM Run this command to configure your shell:
REM     @FOR /f "tokens=*" %i IN ('minishift oc-env') DO @call %i

C:\minishift>oc status
'oc'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는
배치 파일이 아닙니다.

C:\minishift>@FOR /f "tokens=*" %i IN ('minishift oc-env') DO @call %i

C:\minishift>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.


샘플 애플리케이션 배포

oc new-app 명령을 이용해서 새로운 애플리케이션을 만들고 배포할 수 있습니다. 아래는 GitHub에서 소스를 가져와서 배포하는 명령과 그 실행의 예입니다. -l 옵션은 labels를 의미합니다. name 레이블을 붙이고 값으로 myapp을 사용했습니다.

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

C:\minishift>oc new-app https://github.com/openshift/nodejs-ex -l name=myapp
--> Found image ccdf360 (2 days old) in image stream "openshift/nodejs" under tag "4" for "nodejs"

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

    Tags: builder, nodejs, nodejs4

    * 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-secret' 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:\minishift>oc status
In project My Project (myproject) on server https://192.168.99.100:8443

svc/nodejs-ex - 172.30.43.241:8080
  dc/nodejs-ex deploys istag/nodejs-ex:latest <-
    bc/nodejs-ex source builds https://github.com/openshift/nodejs-ex on openshift/nodejs:4
    deployment #1 deployed 8 minutes ago - 1 pod

View details with 'oc describe <resource>/<name>' or list everything with 'oc get all'.

설치 단계의 로그에서 알려주듯이 developer 계정으로 이미 로그인이 된 상태이기 때문에, developer 계정에 애플리케이션이 생성되었습니다. 콘솔에 로그인하여 UI로 확인할 수 있습니다.

https://192.168.99.100:8443에 브라우저로 접속한 후, developer 계정으로 로그인합니다. 암호는 동일합니다.

My Project를 클릭하여 이동합니다. My Project는 OpenShift가 자동으로 만드는 기본 프로젝트입니다.

#1 링크를 클릭하면 name 레이블이 myapp인 것을 확인할 수 있습니다.


Route 생성

Applications > Pods 메뉴로 이동하여 애플리케이션 Status가 Running으로 변경된 것을 확인한 후, Router를 만들면 브라우저에서 직접 화면을 볼 수 있습니다. Applications > Services 메뉴로 이동한 후 nodejs-ex 서비스를 클릭합니다. Actions > Create Route 메뉴나 Create route 링크를 클릭하여 Route 생성 화면으로 이동합니다.

현재 서비스가 하나 밖에 없고 Hostname은 입력하지 않으면 자동 생성되기 때문에 바로 Create 버튼을 클릭해서 Route를 생성합니다.

Traffic 영역의 표에서 Hostname을 클릭합니다.

드디어 배포한 애플리케이션의 화면을 볼 수 있습니다.

oc로는 아래와 같이 하면, 위와 같게 Route를 생성할 수 있습니다.

C:\minishift>oc expose svc/nodejs-ex
route "nodejs-ex" exposed


Minishift의 종료

아래와 같이 minishift stop 명령으로 종료합니다.

C:\minishift>minishift stop



EOF

댓글()

PDF 문서에서 영어 사전을 쉽게 사용하자

기타|2017. 7. 11. 15:53

PDF를 문서를 보면서 모르는 단어를 만났을 때, 브라우저를 이용해 온라인 영어사전을 검색해 왔습니다. 문득 PDF 문서에서 툴팁을 띄워서 단어의 뜻을 보여주면 좋을 것 같다는 생각이 들었습니다.

찾아 보니, 지금은 지원이 중단 됐지만 다음에서 꼬마사전이라는 프로그램을 제공했었더군요. 예전 버전을 설치하고 꼬마사전이 지원하는 PDF 뷰어인 Foxit Reader도 설치했지만 동작을 하지 않았습니다. Foxit Reader는 궁합이 맞는다는 버전을 부러 찾아서 설치도 해봤습니다만 여전했습니다. 아무래도 윈도 10(Windows 10)에서는 안되는 것 같습니다.

결국 꼬마사전은 포기했지만 어찌어찌 방법을 찾아 냈습니다. 간단합니다. 모질라 파이어폭스(Firefox)를 설치한 후, Naver English Dictionary (Unofficial) 부가 기능을 설치하면 됩니다.


Firefox 다운로드


Naver English Dictionary를 파이어폭스에 추가

다 됐습니다. 이제 PDF 파일을 Firefox 위에 드래그앤드롭하여 PDF 문서를 열고(혹은 Ctrl+O 단축키 사용), 찾고 싶은 단어를 더블클릭하거나 드래그해서 선택하면 됩니다.


2017-07-11 추가

현재 더블클릭이나 드래그를 통해서는 네이버 사전이 동작하지 않습니다. 아래와 같이 하면 PDF에서 사용 가능합니다.

1. 주소줄에서 about:addons 페이지로 이동합니다

2. Naver English Dictionary (Unofficial) 애드온의 설정 버튼을 클릭합니다

3. Mode 항목을 Classic mode (Drag)로 선택합니다

4. Firefox를 재시작합니다

위의 과정을 완료한 후 PDF 파일을 열어서, 원하는 단어를 Alt + Drag 하면 단어 사전이 동작합니다.


EOF

댓글()

컨텍스트 메뉴 단축키로 "Sublime Text 3로 문서 열기(Open with Sublime Text)" 실행

Developer Tools|2017. 7. 6. 20:03

서브라임 텍스트에 컨텍스트 메뉴 단축키가 없어서 불편하다면, 아래의 코드를 reg 파일로 저장한 후 윈도 레지스트리에 병합하면 된다.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text]
@="Open with Sublime Text(&2)"

[HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command]
@="C:\\Program Files\\Sublime Text 3\\sublime_text.exe \"%1\""

주의할 점은 현재 C:\\Program Files\\Sublime Text 3\\sublime_text.exe로 되어 있는 경로를 본인의 Sublime Text 설치 위치에 맞게 바꿔야 한다.

내 환경에서는 유니크한 키가 2라서 컨텍스트 메뉴에서 2 키를 누르면 바로 Sublime Text로 열리도록 했는데, &를 2가 아닌 다른 문자 앞에 두면 그 키를 단축키로 사용할 수 있다.

만약 w를 사용하고 싶다면 아래의 내용을 사용하면 된다.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text]
@="Open &with Sublime Text"

[HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command]
@="C:\\Program Files\\Sublime Text 3\\sublime_text.exe \"%1\""


EOF

댓글()