以前に Rancher 関連で以下のメモを書きました。
- vSphere 上に RancherOS をインストールする
- vSphere 上に RancherOS 1.1.0 をインストールする
- Rancher 2.0 をローカルディスクにインストールする
- RancherOS で Kubernetes 環境を構築する際の cloud-init
現時点で RancherOS の最新リリースは v1.3.0-rc1
になったので、改めて RancherOS + Rancher 2.0 な環境を作ってみました。 その際の作業メモを残しておきます。
作業方針
作業方針 / 利用するバージョン等は以下の通りです。
- RancherOS v1.3.0-rc1
- Rancher v2.0.0-alpha21
- 仮想マシンのローカルディスクに RancherOS をインストールする
- RancherOS へのアクセスは鍵交換方式で SSH アクセス出来るようにする
- RancherOS には「ユーザ=
rancher
、パスワード=password
」でアクセス出来るようにする rancher/server
は 8080/TCP または 8443/TCP で公開する
Tech Preview 2 での変更点
Rancher Tech Preview 2 のアナウンスは以下にあります。
主な変更点は以下だそうです。
- Rancher server is now 100% written in Go and no longer requires a MySQL database.
- You can deploy Rancher server on any Docker host as before, or you can deploy Rancher server on an existing Kubernetes cluster.
- You can create new Kubernetes clusters using Rancher Kubernetes Engine (RKE) or cloud-managed Kubernetes services such as GKE. Rancher automates both RKE and GKE cluster provisioning. Support for additional cloud-managed Kubernetes services such as EKS and AKS will be added in the future.
- You can manage all your Kubernetes clusters from a unified cluster management interface. Rancher implements centralized authentication and authorization across all Kubernetes clusters, regardless where these Kubernetes clusters are hosted.
- Rancher provides a simple workload management interface across all your Kubernetes clusters. This is still a work in progress. We continue to offer an intuitive Rancher 1.0-style container-centric interface. We are working on adding many advanced workload management features such as the app catalog, CI/CD and monitoring integration, sophisticated stats, and centralized logging.
従来、rancher/server
のコンテナイメージは 8080/TCP を Listen していたと思うのですが、Tech Preview 2 からなのかは定かでないものの、最近の rancher/server
リリースでは 80/TCP と 443/TCP を Listen するようになっています。 従って、rancher/server
を起動するときはポート番号の指定に注意する必要があります。
vSphere 上に仮想マシンを作成する
以下のパラメータで仮想マシンを作成します。 仮想 DVD ドライブには RancerOS のインストールイメージをマウントします。 フロッピーディスク・ドライブは不要です。
項目 | 値 |
---|---|
ゲスト OS ファミリ | Linux |
ゲスト OS バージョン | その他の Linux (64 ビット) |
CPU | 4 |
メモリ | 8GB |
ハードディスク | 50GB |
初期ユーザのパスワード変更
仮想マシンが起動してきたら、vSphere のリモートコンソールから仮想マシンにアクセスします。 後の手順でファイル修正を行いますが、vSphere のコンソールではクリップボードが使えず、作業が辛い為、SSH でアクセス出来るようにします。 初期状態ではパスワードが設定されておらず、SSH ログイン出来ない為、コンソールから初期ユーザ(rancher
)のパスワードを変更します。 ここで設定するパスワードはインストール中に利用する、あくまで「一時的なパスワード」であり、RancherOS をローカルディスクにアクセスした後は使えません。
sudo passwd rancher
パスワードの設定が完了したら rancher
ユーザで SSH アクセスします。
cloud-config.yml を用意する
cloud-config.yml
というファイルにインストール用のパラメータを記載します。 Getting Started with Hosts というドキュメントの SUPPORTED DOCKER VERSIONS セクションに k8s と互換性のある Docker エンジンのバージョンについて記載されています。 現状では 17.03.x-ce
系が k8s をサポートしつつ、出来るだけ新しいバージョンのようです。 この点を踏まえ、cloud-config.yml
の中身は以下としました。 hostname
、<PUBLIC-KEY>
、address
、gateway
は任意の値で書き換えます。
#cloud-config
hostname: rancher-01
ssh_authorized_keys:
- ssh-rsa <PUBLIC-KEY>
rancher:
docker:
engine: docker-17.03.2-ce
network:
dns:
nameservers:
- 8.8.8.8
- 8.8.4.4
interfaces:
eth0:
address: 10.0.0.1/24
gateway: 10.0.0.0.254
mtu: 1500
dhcp: false
services:
console:
environment:
TZ: 'JST-9'
syslog:
environment:
TZ: 'JST-9'
server:
image: rancher/server:preview
restart: unless-stopped
ports:
- 8080:80
- 8443:443
RancherOS をローカルディスクにインストールする
用意した cloud-config.yml
を指定して、ローカルディスクに RancherOS をインストールします。 --append "rancher.password=password"
のように指定すると、RancherOS をローカルディスクにインストールした後でも、指定したパスワードで SSH アクセス出来るようになります。 下記のワンライナーを実行するとインストールが開始され、しばらくすると rancher/server
が起動してきます。
yes | sudo ros install -c cloud-config.yml -d /dev/sda --append "rancher.password=password"
Rancher にアクセスする
ブラウザから http://xx.xx.xx.xx:8080
または https://xx.xx.xx.xx:8443
へアクセスすると Rancher の画面が表示されるはずです。
コメント