私は非常ヘルムを使用することをお勧めします。 https://github.com/kubernetes/helm
上記のリンクに記載されている情報を使用してHELMをインストールすることができます。これにより、helm
コマンドを使用できるようになります。
helm create YOUR_APP_NAME
を実行すると、次のようなディレクトリ構造が作成されます。
apiVersion: v1
kind: ReplicationController
...
spec:
containers:
- name: myapp
image: {{.Values.container.name}}:{{.Values.container.version}}
...
レプリケーションのためのYAMLファイル:あなたが使用して変数を参照することができますReplicationController
ファイルで
container:
name: "nginx"
version: "latest"
:あなたのようないくつかのENV変数を設定することができvalues.yaml
ファイルで
YOUR_APP_NAME/
Chart.yaml # A YAML file containing information about the chart
LICENSE # OPTIONAL: A plain text file containing the license for the chart
README.md # OPTIONAL: A human-readable README file
values.yaml # The default configuration values for this chart
charts/ # OPTIONAL: A directory containing any charts upon which this chart depends.
templates/ # OPTIONAL: A directory of templates that, when combined with values,
# will generate valid Kubernetes manifest files.
templates/NOTES.txt # OPTIONAL: A plain text file containing short usage notes
コントローラーをtemplatesディレクトリに配置する必要があります。
helm package YOUR_PACKAGE_NAME
というコマンドを実行できます。 K8Sクラスタにパッケージをインストールするにはhelm install PACKAGE_NAME
注:ReplicationController
の代わりにDeployments
を使用するように変更することをお勧めします。参照:https://kubernetes.io/docs/user-guide/deployments/