minishiftでOKD 3.11を利用する

Red HatでOpenShiftのサポートをしているid:nekopです。

f:id:nekop:20181130183459p:plain:w160

さて今年もOpenShift 全部俺 Advent Calendar 2018 - Qiitaがはじまりました。去年のものはOpenShift 全部俺 Advent Calendar 2017 - Qiitaです。

まずは去年に引き続きくminishiftでOpenShift環境を作るところをおさらいしつつ、minishiftやOpenShiftのバージョンが変わっているので手順に落とし穴などがないか再確認したいと思います。

minishiftはシングルノードVMのOpenShift環境を起動するツールです。以下のインストールガイドに記述されているように、VMを立ち上げるので事前にOS毎に異なるそれのセットアップが必要です。

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

Fedora 29でのminishiftのセットアップ手順を凝縮すると以下のようになります。

sudo curl -L https://github.com/minishift/minishift/releases/download/v1.27.0/minishift-1.27.0-linux-amd64.tgz | tar xz --strip=1 -C /usr/bin \*minishift
sudo curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-ubuntu16.04 -o /usr/local/bin/docker-machine-driver-kvm
sudo chmod +x /usr/local/bin/docker-machine-driver-kvm
sudo dnf install libvirt qemu-kvm -y
sudo usermod -a -G libvirt $USER
newgrp libvirt

minishift startを実行するとOKD 3.11環境が立ち上がります。実行環境のパフォーマンスや通信環境によりますが数分から十数分程度かかります。デフォルトでCPU数が2, メモリ4GB, ディスク20GBとなるので、適宜調節してください。いろいろ試す予定であればCPUとディスクを増やしておいたほうが良いかもしれません。

$ minishift start --cpus 4 --memory 4GB --disk-size 40GB
-- 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
-- Checking if provided oc flags are supported ... OK
-- Starting the OpenShift cluster using 'kvm' hypervisor ...
-- Minishift VM will be configured with ...
   Memory:    4 GB
   vCPUs :    4
   Disk size: 40 GB
-- 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
E1130 03:59:36.394936    2085 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
E1130 03:59:39.485644    2085 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, 84% 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.86 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 ...
Starting OpenShift using openshift/origin-control-plane:v3.11.0 ...
I1130 04:00:13.225675    2085 config.go:40] Running "create-master-config"
I1130 04:00:16.930808    2085 config.go:46] Running "create-node-config"
I1130 04:00:18.663382    2085 flags.go:30] Running "create-kubelet-flags"
I1130 04:00:19.191976    2085 run_kubelet.go:49] Running "start-kubelet"
I1130 04:00:19.482454    2085 run_self_hosted.go:181] Waiting for the kube-apiserver to be ready ...
I1130 04:01:28.538189    2085 interface.go:26] Installing "kube-proxy" ...
I1130 04:01:28.539188    2085 interface.go:26] Installing "kube-dns" ...
I1130 04:01:28.539217    2085 interface.go:26] Installing "openshift-service-cert-signer-operator" ...
I1130 04:01:28.539237    2085 interface.go:26] Installing "openshift-apiserver" ...
I1130 04:01:28.539296    2085 apply_template.go:81] Installing "openshift-apiserver"
I1130 04:01:28.541322    2085 apply_template.go:81] Installing "kube-proxy"
I1130 04:01:28.541587    2085 apply_template.go:81] Installing "kube-dns"
I1130 04:01:28.544197    2085 apply_template.go:81] Installing "openshift-service-cert-signer-operator"
I1130 04:01:35.806696    2085 interface.go:41] Finished installing "kube-proxy" "kube-dns" "openshift-service-cert-signer-operator" "openshift-apiserver"
I1130 04:03:19.878643    2085 run_self_hosted.go:242] openshift-apiserver available
I1130 04:03:19.879281    2085 interface.go:26] Installing "openshift-controller-manager" ...
I1130 04:03:19.879365    2085 apply_template.go:81] Installing "openshift-controller-manager"
I1130 04:03:24.663263    2085 interface.go:41] Finished installing "openshift-controller-manager"
Adding default OAuthClient redirect URIs ...
Adding centos-imagestreams ...
Adding router ...
Adding sample-templates ...
Adding web-console ...
Adding registry ...
Adding persistent-volumes ...
I1130 04:03:24.693008    2085 interface.go:26] Installing "centos-imagestreams" ...
I1130 04:03:24.693029    2085 interface.go:26] Installing "openshift-router" ...
I1130 04:03:24.693043    2085 interface.go:26] Installing "sample-templates" ...
I1130 04:03:24.693056    2085 interface.go:26] Installing "openshift-web-console-operator" ...
I1130 04:03:24.693067    2085 interface.go:26] Installing "openshift-image-registry" ...
I1130 04:03:24.693081    2085 interface.go:26] Installing "persistent-volumes" ...
I1130 04:03:24.693812    2085 apply_list.go:67] Installing "centos-imagestreams"
I1130 04:03:24.694690    2085 interface.go:26] Installing "sample-templates/mariadb" ...
I1130 04:03:24.694711    2085 interface.go:26] Installing "sample-templates/postgresql" ...
I1130 04:03:24.694723    2085 interface.go:26] Installing "sample-templates/cakephp quickstart" ...
I1130 04:03:24.694735    2085 interface.go:26] Installing "sample-templates/django quickstart" ...
I1130 04:03:24.694748    2085 interface.go:26] Installing "sample-templates/rails quickstart" ...
I1130 04:03:24.694759    2085 interface.go:26] Installing "sample-templates/mongodb" ...
I1130 04:03:24.694773    2085 interface.go:26] Installing "sample-templates/dancer quickstart" ...
I1130 04:03:24.694784    2085 interface.go:26] Installing "sample-templates/nodejs quickstart" ...
I1130 04:03:24.694815    2085 interface.go:26] Installing "sample-templates/jenkins pipeline ephemeral" ...
I1130 04:03:24.694828    2085 interface.go:26] Installing "sample-templates/sample pipeline" ...
I1130 04:03:24.694838    2085 interface.go:26] Installing "sample-templates/mysql" ...
I1130 04:03:24.694911    2085 apply_list.go:67] Installing "sample-templates/mysql"
I1130 04:03:24.695637    2085 apply_template.go:81] Installing "openshift-web-console-operator"
I1130 04:03:24.696476    2085 apply_list.go:67] Installing "sample-templates/mariadb"
I1130 04:03:24.696688    2085 apply_list.go:67] Installing "sample-templates/postgresql"
I1130 04:03:24.696888    2085 apply_list.go:67] Installing "sample-templates/cakephp quickstart"
I1130 04:03:24.697064    2085 apply_list.go:67] Installing "sample-templates/django quickstart"
I1130 04:03:24.697237    2085 apply_list.go:67] Installing "sample-templates/rails quickstart"
I1130 04:03:24.697416    2085 apply_list.go:67] Installing "sample-templates/mongodb"
I1130 04:03:24.697582    2085 apply_list.go:67] Installing "sample-templates/dancer quickstart"
I1130 04:03:24.697727    2085 apply_list.go:67] Installing "sample-templates/nodejs quickstart"
I1130 04:03:24.697889    2085 apply_list.go:67] Installing "sample-templates/jenkins pipeline ephemeral"
I1130 04:03:24.698050    2085 apply_list.go:67] Installing "sample-templates/sample pipeline"
I1130 04:03:45.557071    2085 interface.go:41] Finished installing "sample-templates/mariadb" "sample-templates/postgresql" "sample-templates/cakephp quickstart" "sample-templates/django quickstart" "sample-templates/rails quickstart" "sample-templates/mongodb" "sample-templates/dancer quickstart" "sample-templates/nodejs quickstart" "sample-templates/jenkins pipeline ephemeral" "sample-templates/sample pipeline" "sample-templates/mysql"
I1130 04:04:20.436153    2085 interface.go:41] Finished installing "centos-imagestreams" "openshift-router" "sample-templates" "openshift-web-console-operator" "openshift-image-registry" "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.86: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 19504.

ocコマンドにパスを通してbash補完を有効化したらセットアップは終了です。

eval $(minishift oc-env)
source <(oc completion bash)
sudo cp ~/.minishift/cache/oc/v3.11.0/linux/oc /usr/bin/
oc completion bash | sudo tee /etc/bash_completion.d/oc

* 各記事は著者の見解によるものでありその所属組織を代表する公式なものではありません。その内容については非公式見解を含みます。