4
4

More than 5 years have passed since last update.

Red Hat CodeReady Workspacesをminishift環境で

Last updated at Posted at 2019-03-09

Red Hat CodeReady Workspaces環境を整える

自宅のminishift環境にRed Hat CodeReady Workspacesを整えてみました。

minishift v3.12@CentOS7

Red Hat CodeReady Workspacesとは

Red Hat CodeReady Workspaces

Red Hatが提供するOpenShift上での統合開発環境の事
今まではEclipse等を使っていましたが、ブラウザ(Chrome)ベースになるようです。

インストール

Red Hat CodeReady Workspaces for OpenShift 1.0.0 : Administration Guide

マニュアルは1.0.0でしたが、モノは1.0.1でした。

基本的には簡単でマニュアル通りでしたが、
非力なわたしの環境(VMWare Player@NotePC)ではタイムアウト時間を延ばしてインストールに成功しました。

Red Hat CodeReady Workspacesのダウンロード

Red Hat CodeReady Workspacesの「GET STARTED」からダウンロードします。

Red Hat CodeReady Workspacesのインストール

まずはmimnishiftを起動します。
の前にVersionUpしときます(笑)

[root@centos76 ~]# chmod 777 /usr/local/bin
[root@centos76 ~]# su - tak
[tak@centos76 ~]$ minishift update
Do you want to update from 1.31.0 to 1.32.0 now? [y/N]: y
:
[tak@centos76 ~]$ exit
[root@centos76 ~]# chmod 755 /usr/local/bin
[root@centos76 ~]# su - tak
[tak@centos76 ~]$

マニュアルのChapter 2. Installing CodeReady Workspacesには

Prerequisites
・ Downloaded and unpacked the deployment script and the configuration file. See Section 2.1, “Downloading the CodeReady Workspaces deployment script”.
・ A running instance of Red Hat OpenShift Container Platform 3.11 or OpenShift Dedicated 3.11. To install OpenShift Container Platform, see the Getting Started with OpenShift Container Platform guide. To install OpenShift Dedicated 3.11, see OKD documentation.
・ The OpenShift command-line client tool, oc, is in the path.
・ The user is logged in to the OpenShift instance (using, for example, oc login).
・ CodeReady Workspaces is supported for use with Google Chrome 70.0.3538.110 (Official Build) (64bit).

とありますので
minishiftを起動します。

[tak@centos76 ~]$ minishift start --disk-size 50GB

ocコマンドのパスを通します。

[tak@centos76 ~]$ eval $(minishift oc-env)
[tak@centos76 ~]$ oc login 
Authentication required for https://192.168.42.85:8443 (openshift)
Username: tak
Password: 
Login successful.

落としてきたRed Hat CodeReady Workspacesを解凍します。

[tak@centos76 ~]$ cd /tmp
[tak@centos76 tmp]$ tar zxvf codeready-workspaces-1.0.1.GA-operator-installer.tar.gz
codeready-workspaces-operator-installer/
codeready-workspaces-operator-installer/README.adoc
codeready-workspaces-operator-installer/deploy.sh
codeready-workspaces-operator-installer/config.yaml
[tak@centos76 tmp]$ cd codeready-workspaces-operator-installer
[tak@centos76 codeready-workspaces-operator-installer]$ 

非力なマシンなのでデフォルトのタイムアウト420secが怖いので600secに変更します。
config.yamlの最終行を以下の様に修正します。

config.yaml
  WAIT_DEPLOYMENT_TIMEOUT: ""

↓↓↓↓

config.yaml
  WAIT_DEPLOYMENT_TIMEOUT: "600"
config.yaml
[tak@centos76 codeready-workspaces-operator-installer]$ cat config.yaml 
#
# Copyright (c) 2012-2018 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
#   Red Hat, Inc. - initial API and implementation
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: che-operator
data:
  ############################
  ## General Che Settings ####
  ############################

  # CHE flavor. Upstream `che` or Red Hat `codeready`. Defaults to `che`
  CHE_FLAVOR: "codeready"
  # Docker image for Che server. Defaults to eclipse/che-server:latest. Keep blank unless you need to deploy your custom image
  CHE_IMAGE: ""
  # TLS support in Che. Defaults to false
  CHE_TLS_SUPPORT: ""
  # PVC strategy for Che workspaces. Defaults to 'common' where all workspaces use one shared PVC
  # A 'unique' strategy implies that each workspaces gets own PVCs
  CHE_INFRA_KUBERNETES_PVC_STRATEGY: ""
  # Workspace PVC claim. Defaults to 1Gi. It is recommended to increase it when using shared PVC
  CHE_INFRA_KUBERNETES_PVC_QUANTITY: ""
  # Content of your self signed cert as string, e.g:
  # cat root ca.crt | base64 -w 0
  CHE_SELF__SIGNED__CERT: ""
  # enable Login with OpenShift in Codeready Workspaces. OpenShift only. Defaults to false
  CHE_OPENSHIFT_OAUTH: ""
  # OpenShift API endpoint URL. Required only when OPENSHIFT_OAUTH is true. Auto detected
  CHE_OPENSHIFT_API_URL: ""
  # Plugin registry URL. Defaults to https://che-plugin-registry.openshift.io
  CHE_WORKSPACE_PLUGIN__REGISTRY__URL: ""
  # Ask for password update at first login as Che admin user. Defaults to true, i.e. you will be asked to update password
  CHE_UPDATE_CHE_ADMIN_PASSWORD: ""

  ############################
  ##   Che Proxy settings   ##
  ############################

  # proxy settings for workspace master, for example:
  # -Dhttp.proxyHost=host -Dhttp.proxyPort=8080 -Dhttps.proxyHost=host -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts='localhost^|127.0.0.1^|*.foo.com'
  CHE_WORKSPACE_MASTER_PROXY_JAVA_OPTS: ""
  # proxy settings for workspace JVM, Maven and workspace agent:
  # -Dhttp.proxyHost=host -Dhttp.proxyPort=8080 -Dhttps.proxyHost=host -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts='localhost^|127.0.0.1^|*.foo.com'
  CHE_WORKSPACE_PROXY_JAVA_OPTS: ""
  # http proxy for workspaces, e.g. 'http://myproxy:8051'
  CHE_WORKSPACE_HTTP__PROXY: ""
  # https proxy for workspaces, e.g. 'http://myproxy:8051'
  CHE_WORKSPACE_HTTPS__PROXY: ""
  # no_proxy for workspaces, e.g. 'localhost,10.2.34.54'
  CHE_WORKSPACE_NO__PROXY: ""

  ############################
  ##    Database settings   ##
  ############################

  # use external existing Postgres DB. Defaults to false which means a new instance of Postgres will be started
  # when set to true, provide connection details and make sure DB user is a SUPERUSER
  CHE_EXTERNAL_DB: ""
  # DB hostname
  CHE_DB_HOSTNAME: ""
  # DB port
  CHE_DB_PORT: "5432"
  # DB database
  CHE_DB_DATABASE: ""
  # DB username
  CHE_JDBC_USERNAME: ""
  # DB password
  CHE_JDBC_PASSWORD: ""
  # Your DB admin password
  CHE_DB_ADMIN_PASSWORD: ""

  ############################
  ## Keycloak settings #######
  ############################

  # Connect to an existing external Keycloak
  # and skip deploying a dedicated Keycloak instance. Defaults to false
  CHE_EXTERNAL_KEYCLOAK: ""
  # Keycloak/Red Hat SSO
  CHE_KEYCLOAK_AUTH__SERVER__URL: ""
  # Keyloak Admin Username.
  # Not required when connecting to an existing realm
  CHE_KEYCLOAK_ADMIN_USERNAME: ""
  # Keycloak admin password. Auto-generated if empty
  CHE_KEYCLOAK_ADMIN_PASSWORD: "admin"
  # Red Hat SSO realm
  CHE_KEYCLOAK_REALM: ""
  # Red Hat SSO client ID
  CHE_KEYCLOAK_CLIENT__ID: ""

  ############################
  ## Operator settings #######
  ############################

  # wait timeout for an Operator to watch deployments
  # defaults to 420 seconds
  WAIT_DEPLOYMENT_TIMEOUT: "600"

インストールします。

[tak@centos76 codeready-workspaces-operator-installer]$ ./deploy.sh --deploy
[INFO]: Welcome to CodeReady Workspaces Installer 
[INFO]: Found oc client in PATH 
[INFO]: Checking if you are currently logged in... 
[INFO]: Active session found. Your current context is: workspace/192-168-42-85:8443/tak 
[WARNING]: Namespace 'workspaces' not found, or current user does not have access to it. Installer will try to create namespace 'workspaces' 
[INFO]: Creating namespace "workspaces" 
[INFO]: Namespace "workspaces" successfully created 
[INFO]: Creating installer service account 
serviceaccount/che-operator created
rolebinding.rbac.authorization.k8s.io/che-operator created
configmap/che-operator created
configmap/che-operator patched
Unable to use a TTY - container che-operator did not allocate one
If you don't see a command prompt, try pressing enter.
time="2019-03-09T08:36:18Z" level=info msg="postgres successfully deployed" 
time="2019-03-09T08:36:18Z" level=info msg="Provisioning resources in pod postgres-97bdc58c4-md9dx" 
time="2019-03-09T08:36:19Z" level=info msg="Provisioning completed" 
time="2019-03-09T08:36:20Z" level=info msg="Waiting for deployment keycloak. Default timeout: 600 seconds" 
time="2019-03-09T08:37:35Z" level=info msg="keycloak successfully deployed" 
time="2019-03-09T08:37:35Z" level=info msg="Provisioning resources in pod keycloak-b547b9b77-8lw9c" 
time="2019-03-09T08:37:59Z" level=info msg="Provisioning completed" 
time="2019-03-09T08:37:59Z" level=info msg="Waiting for deployment codeready. Default timeout: 600 seconds" 
time="2019-03-09T08:40:44Z" level=info msg="codeready successfully deployed" 
time="2019-03-09T08:40:44Z" level=info msg="Che is available at: http://codeready-workspaces.192.168.42.85.nip.io" 
time="2019-03-09T08:40:44Z" level=info msg="Deployment took 4m46.97171819s" 
[INFO]: CodeReady Workspaces successfully deployed and available at http://codeready-workspaces.192.168.42.85.nip.io 
[tak@centos76 codeready-workspaces-operator-installer]$ 

Red Hat CodeReady Workspacesへのアクセス

普通にOpenShiftのコンソールからアクセスします。

[tak@centos76 ~]$ minishift console

標準ではworkspacesプロジェクトが作成され、CodeReady関連Podsが存在します。

02-087.png

OverviewからURLをクリックするとRed Hat CodeReady Workspacesのコンソールにアクセスできます。

02-01.png

02-02.png

初めてなので、New User? Registerをクリックします。
下の絵ではLast Name空欄にしてましたが、必須でした(笑)

02-03.png

ログインするとこんなダッシュボード画面が表示されます。

02-04.png

ここから開発する言語を選択しworkspaceを作成していくようですが…

02-05.png

メモリは控えめにして

03-02.png

CREATE&OPEN

02-06.png

そして、わたしの環境ではminishiftが落ちました(笑)

03-03.png

次回は再起動して試してみたいと思います!

再起動しました(笑)

対応言語はこんな感じみたい。Add Stackで追加できそうです。
02-07.png

で先ほどのWorkspasesを確認すると
04-01.png

04-02.png
で、イメージをPullしようとしてまた落ちたみたいです( ;∀;)
Memory足りなさすぎかもしれませんね…。

再度トライしてみましたが…
おぉPullまで成功しているっ!!

05-01.png

嫌なエラーが…

Error: Failed to run the workspace: "Bootstrapping of machine dev-machine failed. Cause: Error occured while executing command in pod: java.net.SocketException: Connection reset"

05-02.png

やっぱり死んでる…( ;∀;)

05-03.png

Red Hat CodeReady Workspacesのアンインストール

workspacesをプロジェクトごと削除します♪

Red Hat CodeReady Workspacesをminishiftで使うには

メモリが足りないようなので、デフォルトの4GBから6GBに変更してみました。

[tak@centos76 ~]$ minishift start --disk-size=50GB --memory=6GB

Pod的には起動しています。

06-01.png

既に作成済みのWorkspaseを選択します。

06-02.png

あれ…様子がおかしいですね。

Error: Failed to start the workspace: "An error has occurred."

途中で失敗したからかな…と新たなworkspaseを作成してみます。
workspases>Add Workspaceから
07-01.png

SELECT STACKからPythonを選択して、RAMをデフォルトの2GBから1GBに変更
07-02.png

勝手がわからないのでサンプルプロジェクトを追加します。
07-03.png

で、CREATE & OPENをクリック
07-04.png

07-05.png
やっぱり同じError

まさかと思いOpenShift側のConsoleを確認すると…やっぱり出てました。Error
07-06.png

この状態でも CodeReady Workspaces は操作できているのでWeb ConsoleのPodが逝っちゃったんですかね。

とりあえずもう一度綺麗な状態からという事でworkspacesを削除します。
workspacesからworkspaceをチェックするとDELETEボタンが現れるのでDELETE

07-07.png

ようやくコードまでたどり着いた(^^♪

5度目のチャレンジでようやくworkspaceが正常にグリーンフラグでスタートできました(笑)
こんな感じのIDE環境になります。

08-01.png

sampleプロジェクトはしょぼしょぼでHello, worldでした(笑)
画面下のTerminalでcdしてpython main.pyするとちゃんとレスポンス良く結果が返ってきました。
08-02.png

画面のツールバーにある実行ボタンを押すと実行結果が下側に表示されました。
08-03.png

コマンドライン版は良いとしてブラウザAppとかの場合はどうやるんでしょうかねぇ~

ちなみにworkspaseはPodになっていましたよ。
08-04.png

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4