LoginSignup
17
12

More than 5 years have passed since last update.

Rancher Charts 紹介

Last updated at Posted at 2018-11-06

1. Rancher カタログを作る為のRancher Chartsについて

Catalogs and Charts | Rancher Labs
https://rancher.com/docs/rancher/v2.x/en/catalog/

2. Rancher 2.0系におけるカタログ

  • Rancher 1.6にはカタログというのがありました。1ボタンで必要なアプリケーションがデプロイできるというとっても便利な機能でした。しかし、それは、docker-compose.ymlを利用したものでした。
  • Rancher 2.0 ではオーケストレーションがKubernetesベースになりました。当然、docker-compose.ymlが使えなくなりました。
  • Kubernetesでのパッケージマネージャーはまだ混沌としている状態ですが、Rancher Labs社としては、Rancher 2.0ではHelm を拡張して、Rancher Catalogを実装しています。

3. Helm Charts とカタログ

3.1 Helm Charts

  • Helm Chartsとは、アプリケーションを実行する為の様々なアプリケーションを含んだパッケージです。
  • 元々のHelm Chartsでは、キーと値をペアのセットのパラメーターを理解し、それを Answers としてセットしてデプロイする必要があります。
  • Helm 安定版とHelm インキュベーターでは、元々のHelm Chartがそのまま表示されます。カスタムカタログでHelm Charts(Rancher形式でない)を利用することもできます(もちろん、Rancher Chartsの利用を推奨します)。

3.2 Rancher Charts

  • Rancher Chartsは、元々のHelm Chartsをコピーしたものですが、利便性をよくするため app-readme.md と questions.yaml という2つのファイルを追加しています。それぞれについて詳しくは、Rancher Charts 追加ファイルを参照してください。

4. Rancher Chartsのメリット

4.1 リビジョンの追跡を拡張

Helmでは、バージョンごとのデプロイには対応していますが、Rancher ではチャート間のバージョンの違いを表示するためのトラッキングと改訂履歴を追加しました。

4.2 アプリケーション起動の利便性向上

Rancher Chartsは、チャートの詳細と設定フォームを追加して、カタログアプリを簡単にデプロイできるようにしています。Rancher のユーザーは、Helm 変数リストを全て確認して、アプリケーションの起動方法を考える必要はありません。

4.3 アプリケーションリソース管理

Rancherは、アプリケーションの利用リソース状況を追跡します。アプリケーションを動かす為のオブジェクトがリストアップされたページで簡単に確認することができ、トラブルシューティングすることもできます。

5. Rancher Catalog

5.1 app-readme.md

チャートのUIヘッダーに説明的なテキストを提供するファイル。
(以下の画像は、Rancherチャートとネイティブヘルムチャートの違い)
image.png

5.2 question.yml

チャートの展開を簡素化するためのフォームの質問を含むファイル。
これがなければ、Key−Valueを使用して配置を構成する必要がある。

image.png

6. Chartの構造

image.png

項目 Rancher Chart 詳細
app-readme.md Rancher 2.0 UIで表示するためのReadmeファイル
charts/ Chartの依存関係を含めるディレクトリ
app-readme.md Helm Chartの情報ファイル
question.yml Rancher 2.0 UIに関する質問を含むファイル
templates/ values.ymlと組み合わせ、コンテナを生成するテンプレートYAMLの配置
requirements.yml チャートの依存関係をリストするファイル
README.md Helm Readmeファイル。[詳細説明]に表示される。
values.yaml チャートのデフォルトの設定値

6.1 Helm Charts の question.yml(1)

image.png

6.2 Helm Charts の question.yml(2)

image.png
※注意:subquestions[]には、keyとして subquestionsやshow_subquestion_if
をネストすることはできません。その他の種別は利用できます。

7. サンプルファイル

7.1 app-readme.md

image.png
https://raw.githubusercontent.com/rancher/charts/master/charts/wordpress/v1.0.5/app-readme.md

7.2 questions.yml

image.png
https://github.com/rancher/charts/blob/master/charts/wordpress/v1.0.5/questions.yml

7.3 question.yml と画面の対比

image.png

8. Rancher Helmリソースの指定

  • Rancher Helmのquestions.yml でのコンテナーリソースの指定の仕方

Helm Chartsのvalues.yamlファイルで指定しているある特定の値をRancher Chartsのquestions.yamlで上書きしたい場合は、次のように指定します。(例として spec.template.spec.containers.resources.requests.nvidia.com/gpu を書き換えることとします)

それぞれのyamlファイルの関連は以下のようになります
image.png

8.1 Native Helm Charts の deployment.yaml

https://github.com/helm/charts/blob/master/stable/tensorflow-notebook/templates/deployment.yaml
で以下のように指定されているとする。

deployment.yaml
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: {{ template "tensorflow-notebook.fullname" . }}
  labels:
    app: {{ template "tensorflow-notebook.name" . }}
    chart: {{ template "tensorflow-notebook.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  selector:
    matchLabels:
      app: {{ template "tensorflow-notebook.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ template "tensorflow-notebook.name" . }}
        release: {{ .Release.Name }}
    spec:
      containers:
        - name: jupyter

8.2 Native Helm Charts の values.yaml

https://github.com/helm/charts/blob/master/stable/tensorflow-notebook/values.yaml
で以下のように指定されているとする。

values.yaml
# Default values for ack-tensorflow-dev.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
jupyter:
  image:
    repository: tensorflow/tensorflow
    tag: 1.6.0-devel
    pullPolicy: IfNotPresent
  password: tensorflow
  resources: {}
  # limits:
  #  cpu: 100m
  #  memory: 128Mi
  #  nvidia.com/gpu: 1
  # requests:
  #  cpu: 100m
  #  memory: 128Mi
  #  nvidia.com/gpu: 1

8.3 Racher Helm Charts の questions.yaml

questions.yaml で以下のように指定します。
簡単に言うと、Helmのvalues.yaml のファイル内の変数をフル指定で variable に記載するだけです。
(ここで例としては jupyter.resources.requests.nvidia.com/gpu )

questions.yaml
# Default values for ack-tensorflow-dev.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
questions:
- variable: jupyter.resources.requests.nvidia.com/gpu
  label: request gpu
  default: 1
  type: int
  required: false
- variable: jupyter.resources.requests.cpu
  label: request cpu
  default: 100m
  type: string
  required: true
- variable: jupyter.resources.requests.memory
  label: request memory
  default: 128Mi
  type: string
  required: true

9. Rancher Charts で楽しんでください!

17
12
1

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
17
12