LoginSignup
5
3

More than 3 years have passed since last update.

ESXi上のCentOS7にOpenShift(MiniShift)をインストール

Last updated at Posted at 2019-10-16

MiniShift向けの手順を書く機会があったので、久々にMiniShiftをインストールしました。

今回は、VMWareのESXi上のCentOS7にxrdpをインストールして、リモートデスクトップでCentOS7に接続してMiniShiftのGUIを操作したいと思います。

公式ドキュメント

Installing Minishift
https://docs.okd.io/latest/minishift/getting-started/index.html

CentOS7(仮想マシン)のインストール

VMWare ESXi 6.7上にCentOS7.7をミニマムインストール

OSインストール時の注意点

  • ESXiの場合はCPUの「ハードウェアアシストによる仮想化をゲストOSに公開」、「仮想CPUパフォーマンスカウンタの有効化」を有効にしてください。
    スクリーンショット 2019-10-16 22.55.55.png

  • VMwareWorkstationの場合は、「Intel VT-x/EPTまたはAMD-V/RVIを仮想化(V)」を有効にしてください。
    スクリーンショット 2019-10-16 22.56.06.png

手順

(前提)CentOS7のミニマムインストールが終了していること

パッケージの更新

  • OSのパッケージの最新化

# yum update -y
# reboot

リモートデスクトップの環境作成

CentOS7にxrdpを導入しWindowsからリモートデスクトップで接続 を参考にしました。
@shinoere さん サンキュー!

  • epelリポジトリのインストール

# yum install -y epel-release
  • xrdpとtigervnc-serverのインストール

# yum install -y xrdp tigervnc-server
  • 日本語キーボード対応

# cd /etc/xrdp
# curl -LO https://www.mail-archive.com/xrdp-devel@lists.sourceforge.net/msg00263/km-e0010411.ini
# cp km-e0010411.ini km-0411.ini
# cp km-e0010411.ini km-e0200411.ini
# cp km-e0010411.ini km-e0210411.ini
  • xrdp.serviceの自動起動設定&起動

# systemctl enable --now xrdp.service
Created symlink from /etc/systemd/system/multi-user.target.wants/xrdp.service to /usr/lib/systemd/system/xrdp.service.
  • firewalld停止&無効 (注:ローカル環境なので停止しました。それぞれの環境に合わせてください)

# systemctl disable --now firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
  • GNOME Desktopのインストール

# yum group install "GNOME Desktop"
  • 再起動

# reboot
  • リモートデスクトップのクライアントで接続
    WindowsでもMacでもお好みのリモートデスクトップクライアントで接続してください。 スクリーンショット 2019-10-16 23.19.55.png

MiniShiftのインストール

  • Dockerのインストール

個人的にDocker 17.09から追加された ADD/COPY --chownでファイルのオーナーを変更を使ったDockerfileを利用しなければならないので、CentOS7の1.13のDockerではなく docker-ceリポジトリの1.19のDockerをインストールしました。

yum-config-managerコマンドがない場合はyum-utilsをインストール
# yum install yum-utils

# yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

yum install docker-ce
  • libvirtとqemu-kvmのインストール

# yum install libvirt qemu-kvm -y
  • docker-machine-driver-kvm のインストール

# curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-centos7 > /usr/local/bin/docker-machine-driver-kvm

# chmod +x /usr/local/bin/docker-machine-driver-kvm
  • minishiftコマンドのインストール

# curl -LO https://github.com/minishift/minishift/releases/download/v1.34.1/minishift-1.34.1-linux-amd64.tgz

# tar xf minishift-1.34.1-linux-amd64.tgz --strip=1 -C /usr/local/bin minishift-1.34.1-linux-amd64/minishift

# ls -l /usr/local/bin/
-rwxr-xr-x. 1 root root 11939128 Oct 16 21:30 docker-machine-driver-kvm
-rwxrwxr-x. 1 1000 1000 28037312 Jul 16 22:07 minishift
  • MiniShiftの起動

cpu、memory,disk-sizeを指定しないと2cpu,4GBメモリ,20GBディスクで起動します。


# minishift start --openshift-version v3.11.0 --iso-url centos --cpus 4 \
--memory 12GB --disk-size 60GB
-- Starting profile 'minishift'
-- Check if deprecated options are used ... OK
-- Checking if https://github.com is reachable ... OK
-- Checking if requested OpenShift version 'v3.11.0' is valid ... OK
-- Checking if requested OpenShift version 'v3.11.0' is supported ... OK
-- Checking if requested hypervisor 'kvm' is supported on this platform ... OK
-- Checking if KVM driver is installed ... 
   Driver is available at /usr/local/bin/docker-machine-driver-kvm ... 
   Checking driver binary is executable ... OK
-- Checking if Libvirt is installed ... OK
-- Checking if Libvirt default network is present ... OK
-- Checking if Libvirt default network is active ... OK
-- Checking the ISO URL ... OK
-- Downloading OpenShift binary 'oc' version 'v3.11.0'
 53.89 MiB / 53.89 MiB [========================================================================================] 100.00% 0s-- Downloading OpenShift v3.11.0 checksums ... OK
-- Checking if provided oc flags are supported ... OK
-- Starting the OpenShift cluster using 'kvm' hypervisor ...
-- Minishift VM will be configured with ...
   Memory:    12 GB
   vCPUs :    4
   Disk size: 60 GB

   Downloading ISO 'https://github.com/minishift/minishift-centos-iso/releases/download/v1.15.0/minishift-centos7.iso'
 355.00 MiB / 355.00 MiB [======================================================================================] 100.00% 0s
-- Starting Minishift VM ....................... OK
-- Checking for IP address ... OK
-- Checking for nameservers ... 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 ... 1% used OK
-- Writing current configuration for static assignment of IP address ... WARN
   Importing 'openshift/origin-control-plane:v3.11.0'  CACHE MISS
   Importing 'openshift/origin-docker-registry:v3.11.0'  CACHE MISS
   Importing 'openshift/origin-haproxy-router:v3.11.0'  CACHE MISS
-- OpenShift cluster will be configured with ...
   Version: v3.11.0
-- Pulling the OpenShift Container Image ................. OK
-- Copying oc binary from the OpenShift container image to VM ... OK
-- Starting OpenShift cluster ...................................................................
Getting a Docker client ...
Checking if image openshift/origin-control-plane:v3.11.0 is available ...
Pulling image openshift/origin-cli:v3.11.0
E1016 13:06:16.908093    4904 helper.go:173] Reading docker config from /home/docker/.docker/config.json failed: open /home/docker/.docker/config.json: no such file or directory, will attempt to pull image docker.io/openshift/origin-cli:v3.11.0 anonymously
Image pull complete
Pulling image openshift/origin-node:v3.11.0
E1016 13:06:20.665147    4904 helper.go:173] Reading docker config from /home/docker/.docker/config.json failed: open /home/docker/.docker/config.json: no such file or directory, will attempt to pull image docker.io/openshift/origin-node:v3.11.0 anonymously
Pulled 5/6 layers, 89% complete
Pulled 6/6 layers, 100% complete
Extracting
Image pull complete
Checking type of volume mount ...
Determining server IP ...
Using public hostname IP 192.168.42.138 as the host IP
Checking if OpenShift is already running ...
Checking for supported Docker version (=>1.22) ...
Checking if insecured registry is configured properly in Docker ...
Checking if required ports are available ...
Checking if OpenShift client is configured properly ...
Checking if image openshift/origin-control-plane:v3.11.0 is available ...
<<<省略>>>
I1016 13:11:38.894803    4904 interface.go:41] Finished installing "centos-imagestreams" "sample-templates" "openshift-web-console-operator" "openshift-image-registry" "openshift-router" "persistent-volumes"
Login to server ...
Creating initial project "myproject" ...
Server Information ...
OpenShift server started.

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

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

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


-- Exporting of OpenShift images is occuring in background process with pid 4534.
  • 環境変数定義

# eval $(minishift oc-env) ← OpenShift のクライアント(oc コマンド)
# eval $(minishift docker-env) ← MiniShift の仮想マシン内のDockerとの接続
# source <(oc completion bash) ← コマンドとリソースのシェル補完

minishift oc-envを実行してみると ocコマンドのPATHを通すためコマンドが出力される。

# minishift oc-env
export PATH="/root/.minishift/cache/oc/v3.11.0/linux:$PATH"

# ls -1 /root/.minishift/cache/oc/v3.11.0/linux
oc

minishift docker-envを実行すると、下記のように KVM上で動作しているMiniShiftのVMで動作しているDockerへの接続情報が出力されます。 この環境変数を定義することでローカルのDockerレジストリではなくMiniShiftのVMのDockerレジストリでコンテナイメージを取り扱います。

# minishift docker-env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.42.138:2376"
export DOCKER_CERT_PATH="/root/.minishift/certs"

minishift-1.png

  • OpenShift ログイン (CLI)

ユーザーは、一般ユーザ: developer (パスワードは任意の文字でOK)、システム管理者: system:adminの2つがデフォルトで設定されている。

# oc login -u developer
Logged into "https://192.168.42.138:8443" as "developer" using existing credentials.

You have one project on this server: "myproject"

Using project "myproject".
# oc whoami
developer
  • OpenShift ログイン (GUI) リモートデスクトップでCentOS7に接続した後に、MiniShift起動時に出力された Web ConsoleのURLを FireFoxで開いて、ユーザー名、パスワード共にdeveloper(任意の文字列でいいんですが)を入れてログインします。
The server is accessible via web console at:
    https://192.168.42.138:8443/console

スクリーンショット 2019-10-17 0.06.03.png

Web Consoleが表示されました。
スクリーンショット 2019-10-16 22.40.59.png

  • MiniShiftの停止 minishift stopコマンドで MiniShiftの仮想マシンが停止します。
$ minishift stop
  • その他のコマンドは minishift help コマンドを実行して参照してください。
# minishift help
Minishift is a command-line tool that provisions and manages single-node OpenShift clusters optimized for development workflows.

Usage:
  minishift [command]

Available Commands:
  addons      Manages Minishift add-ons.
  completion  Outputs minishift shell completion for the given shell (bash or zsh)
  config      Modifies Minishift configuration properties.
  console     Opens or displays the OpenShift Web Console URL.
  delete      Deletes the Minishift VM.
  docker-env  Sets Docker environment variables.
  help        Help about any command
  hostfolder  Manages host folders for the Minishift VM.
  image       Exports and imports container images.
  ip          Gets the IP address of the running cluster.
  logs        Gets the logs of the running OpenShift cluster.
  oc-env      Sets the path of the 'oc' binary.
  openshift   Interacts with your local OpenShift cluster.
  profile     Manages Minishift profiles.
  services    Manage Minishift services
  setup       Configures pre-requisites for Minishift on the host machine
  ssh         Log in to or run a command on a Minishift VM with SSH.
  start       Starts a local OpenShift cluster.
  status      Gets the status of the local OpenShift cluster.
  stop        Stops the running local OpenShift cluster.
  update      Updates Minishift to the latest version.
  version     Gets the version of Minishift.

Flags:
      --alsologtostderr                  log to standard error as well as files
  -h, --help                             help for minishift
      --log_backtrace_at traceLocation   when logging hits line file:N, emit a stack trace (default :0)
      --log_dir string                   If non-empty, write log files in this directory
      --logtostderr                      log to standard error instead of files
      --profile string                   Profile name (default "minishift")
      --show-libmachine-logs             Show logs from libmachine.
      --stderrthreshold severity         logs at or above this threshold go to stderr (default 2)
  -v, --v Level                          log level for V logs. Level varies from 1 to 5 (default 1).
      --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging

Use "minishift [command] --help" for more information about a command.

これで、OpenShift(minishift)が使えるようになりました。 OpenShift楽しんでくださいね。

5
3
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
5
3