2 構成ファイルの使用
環境およびモジュールの作成と管理を簡素化するために、構成ファイルを使用できます。 構成ファイルには、作成する環境およびモジュールに関するすべての情報が含まれます。 構成ファイルを使用して、Platform CLIコマンド・オプションの繰返しエントリを保存します。
構成ファイルは、グローバル・コマンド・オプションであるため、任意のPlatform CLIコマンドで--config-fileオプションを使用して使用できます。 Platform CLIコマンドで--config-fileオプションを使用すると、--forceオプションを除く他のコマンドライン・オプションは無視されます。 olcnectlコマンドでは、構成ファイルに含まれる情報のみが使用されます。
次の項では、構成ファイルの記述および構成ファイルを使用した環境およびモジュールの作成と削除について説明します。 構成ファイルのその他のユースケースは可能ですが、この章では説明しません。 この章で説明するユースケースは、構成ファイルを使用する最も一般的な方法です。
構成ファイルの作成
構成ファイルは、yamlまたはymlのファイル拡張子を持つ有効なYAMLである必要があります。 構成ファイル内のコンポーネントの基本的な形式は、次のとおりです:
environments:
- environment-name: name
globals:
key: value
modules:
- module: name
name: name
args:
key: value
- module: name
name: name
args:
key: value
- environment-name: name
globals:
key: value
modules:
- module: name
name: name
args:
key: value
- module: name
name: name
args:
key: value olcnectl templateコマンドは、環境の構成ファイルを起動するための基本的な構成オプションを含むYAMLファイルを作成する場合に便利です。
olcnectl template このコマンドは、ローカル・ディレクトリにconfig-file-template.yamlという名前のファイルを作成します。 このファイルは環境に合わせて編集できます。
構成ファイルには、olcnectlコマンド・オプションのkey: valueペアが含まれています。 たとえば、環境を作成するときに、次のようなolcnectlコマンドを使用できます:
olcnectl environment create \
--api-server 127.0.0.1:8091 \
--environment-name myenvironment \
--secret-manager-type vault \
--vault-token s.3QKNuRoTqLbjXaGBOmO6Psjh \
--vault-address https://192.0.2.20:8200 \
--update-config 構成ファイルでこの同じ情報をYAML形式で表すには、次を使用します:
environments:
- environment-name: myenvironment
globals:
api-server: 127.0.0.1:8091
secret-manager-type: vault
vault-token: s.3QKNuRoTqLbjXaGBOmO6Psjh
vault-address: https://192.0.2.20:8200
update-config: true 環境マップをYAMLのkey: valueペアに直接作成するためのolcnectl environment createコマンド・オプションに注意してください。
modulesセクションを記述する場合は、モジュールに関連する任意のolcnectl moduleコマンド・オプションを使用できます。 モジュールで使用できるolcnectl moduleコマンド・オプションは、moduleセクションに含めることができます。 モジュールのargsセクションには、olcnectl module createコマンドで使用可能なオプションのみが含まれます。 その他のオプションは、メインのmoduleオプション・セットの下にあります。
この例では、--generate-scriptsおよび--forceオプションはolcnectl module createコマンドでは有効ではありませんが、olcnectl module validateまたはolcnectl module uninstallオプションの有効なオプションです。 generate-scriptsおよびforceオプションは、モジュールargsとして追加されるのではなく、module: kubernetesセクションの下に一覧表示されます。
...
modules:
- module: kubernetes
name: mycluster
generate-scripts: true
force: true
args:
kube-version: 1.29.3
container-registry: container-registry.oracle.com/olcne
load-balancer: lb.example.com:6443
control-plane-nodes:
- control1.example.com:8090
- control2.example.com:8090
- control3.example.com:8090
worker-nodes:
- worker1.example.com:8090
- worker2.example.com:8090
- worker3.example.com:8090
selinux: enforcing
restrict-service-externalip: true
restrict-service-externalip-ca-cert: /etc/olcne/certificates/restrict_external_ip/ca.cert
restrict-service-externalip-tls-cert: /etc/olcne/certificates/restrict_external_ip/node.cert
restrict-service-externalip-tls-key: /etc/olcne/certificates/restrict_external_ip/node.key コマンドにすべての必須オプションを指定しない場合は、olcnectlで構成ファイルを使用するときに、それらのオプションの入力を求められます。 キーの値を指定しない場合、そのolcnectlコマンド・オプションのデフォルトが使用されるか、デフォルト値がないキーの場合、そのキーは無視されます。 無効なキー値を追加すると、無効なオプションの修正に役立つエラーが表示されます。 有効でないキーを追加すると、それらは無視されます。
構成ファイルにolcnectlコマンドの--config-fileオプションを含めないでください。 このオプションは無視され、構成ファイルでは使用できません。
YAMLファイルのコンポーネントの順序は重要です。 コンポーネントは、Platform CLIでのコマンドの完全なセットを使用して作成する場合と同じ順序である必要があります。
たとえば、このファイルでは2つの環境が作成され、最初の環境にはKubernetesモジュールのみが含まれます。 2番目の環境には、Kubernetesモジュール、Operator Lifecycle Managerモジュール、Istioモジュール、最後にOracle Cloud Infrastructure Cloud Controller Managerモジュールが含まれます。 環境とすべてのモジュールの両方を、単一のolcnectlコマンドを使用して作成およびインストールできます。
environments:
- environment-name: myenvironment1
globals:
api-server: 127.0.0.1:8091
secret-manager-type: file
olcne-ca-path: /etc/olcne/certificates/ca.cert
olcne-node-cert-path: /etc/olcne/certificates/node.cert
olcne-node-key-path: /etc/olcne/certificates/node.key
modules:
- module: kubernetes
name: mycluster1
args:
container-registry: container-registry.oracle.com/olcne
load-balancer: lb.example.com:6443
control-plane-nodes:
- control1.example.com:8090
- control2.example.com:8090
- control3.example.com:8090
worker-nodes:
- worker1.example.com:8090
- worker2.example.com:8090
- worker3.example.com:8090
selinux: enforcing
restrict-service-externalip: true
restrict-service-externalip-ca-cert: /etc/olcne/certificates/restrict_external_ip/ca.cert
restrict-service-externalip-tls-cert: /etc/olcne/certificates/restrict_external_ip/node.cert
restrict-service-externalip-tls-key: /etc/olcne/certificates/restrict_external_ip/node.key
- environment-name: myenvironment2
globals:
api-server: 127.0.0.1:8091
secret-manager-type: file
olcne-ca-path: /etc/olcne/certificates/ca.cert
olcne-node-cert-path: /etc/olcne/certificates/node.cert
olcne-node-key-path: /etc/olcne/certificates/node.key
modules:
- module: kubernetes
name: mycluster2
args:
container-registry: container-registry.oracle.com/olcne
load-balancer: lb.example.com:6443
control-plane-nodes:
- control4.example.com:8090
- control5.example.com:8090
- control6.example.com:8090
worker-nodes:
- worker4.example.com:8090
- worker5.example.com:8090
- worker6.example.com:8090
selinux: enforcing
restrict-service-externalip: true
restrict-service-externalip-ca-cert: /etc/olcne/certificates/restrict_external_ip/ca.cert
restrict-service-externalip-tls-cert: /etc/olcne/certificates/restrict_external_ip/node.cert
restrict-service-externalip-tls-key: /etc/olcne/certificates/restrict_external_ip/node.key
- module: operator-lifecycle-manager
name: myolm
args:
olm-kubernetes-module: mycluster2
- module: istio
name: myistio
args:
istio-kubernetes-module: mycluster2
- module: oci-ccm
name: myoci
args:
oci-ccm-kubernetes-module: mycluster2
oci-region: us-ashburn-1
oci-tenancy: ocid1.tenancy.oc1..unique_ID
oci-compartment: ocid1.compartment.oc1..unique_ID
oci-user: ocid1.user.oc1..unique_ID
oci-fingerprint: b5:52:...
oci-private-key-file: /home/opc/.oci/oci_api_key.pem
oci-vcn: ocid1.vcn.oc1..unique_ID
oci-lb-subnet1: ocid1.subnet.oc1..unique_ID 構成ファイルを使用したインストール
この項では、構成ファイルを使用して環境を作成し、それにKubernetesをデプロイする例を示します。
この構成ファイルはmyenvironment.yamlという名前で、次が含まれます:
environments:
- environment-name: myenvironment
globals:
api-server: 127.0.0.1:8091
secret-manager-type: file
olcne-ca-path: /etc/olcne/certificates/ca.cert
olcne-node-cert-path: /etc/olcne/certificates/node.cert
olcne-node-key-path: /etc/olcne/certificates/node.key
modules:
- module: kubernetes
name: mycluster
args:
container-registry: container-registry.oracle.com/olcne
load-balancer: lb.example.com:6443
control-plane-nodes:
- control1.example.com:8090
- control2.example.com:8090
- control3.example.com:8090
worker-nodes:
- worker1.example.com:8090
- worker2.example.com:8090
- worker3.example.com:8090
selinux: enforcing
restrict-service-externalip: true
restrict-service-externalip-ca-cert: /etc/olcne/certificates/restrict_external_ip/ca.cert
restrict-service-externalip-tls-cert: /etc/olcne/certificates/restrict_external_ip/node.cert
restrict-service-externalip-tls-key: /etc/olcne/certificates/restrict_external_ip/node.key環境の作成およびKubernetesモジュールのデプロイに使用するのと同じコマンドを使用しますが、Platform CLIを使用してすべてのコマンド・オプションを渡すかわりに、構成ファイルのロケーションを指定します。
環境を作成し、Kubernetesをオペレータ・ノードにデプロイするには:
-
olcnectl environment createコマンドを--config-fileオプションとともに使用します:olcnectl environment create \ --config-file myenvironment.yaml環境が作成され、Kubernetesモジュールのインストールに使用する準備が整います。 構成ファイルに多数の環境が設定されている場合は、すべてこの1つのステップを使用して作成されます。
-
olcnectl module createコマンドを使用して、Kubernetesモジュールを作成します。olcnectl module create \ --config-file myenvironment.yaml構成ファイルに多数のモジュールが設定されている場合は、すべてこの1つのステップを使用して作成されます。
-
モジュールをノードにインストールできることを確認します。
olcnectl module validateコマンドを使用して、モジュールを検証します。olcnectl module validate \ --config-file myenvironment.yaml構成ファイルに多数のモジュールが設定されている場合は、すべて検証されます。
-
最後のステップは、モジュールを取り付けることです。
olcnectl module installコマンドを使用して、モジュールをインストールします。olcnectl module install \ --config-file myenvironment.yaml構成ファイルに多数のモジュールが設定されている場合、それらはすべてインストールされます。
-
Kubernetesモジュールがデプロイされ、ノードが
olcnectl module instancesコマンドを使用して設定されていることを確認できます。olcnectl module instances \ --config-file myenvironment.yaml出力は次のようになります:
INSTANCE MODULE STATE control1.example.com:8090 node installed control2.example.com:8090 node installed control3.example.com:8090 node installed worker1.example.com:8090 node installed worker2.example.com:8090 node installed worker3.example.com:8090 node installed mycluster kubernetes installed
構成ファイルを使用したモジュールまたは環境の追加
モジュールまたは環境をデプロイメントに追加するには、構成ファイルに追加してから、olcnectlコマンドを実行してデプロイメントに追加します。 たとえば、Operator Lifecycle Managerモジュールを既存のKubernetesデプロイメントに追加するには、次のようなファイルを作成します。 このファイルは、Operator Lifecycle Managerモジュールが追加され、環境を作成してKubernetesをデプロイするために「構成ファイルを使用したインストール」で使用されるものと同じです。
environments:
- environment-name: myenvironment
globals:
api-server: 127.0.0.1:8091
secret-manager-type: file
olcne-ca-path: /etc/olcne/certificates/ca.cert
olcne-node-cert-path: /etc/olcne/certificates/node.cert
olcne-node-key-path: /etc/olcne/certificates/node.key
modules:
- module: kubernetes
name: mycluster
args:
container-registry: container-registry.oracle.com/olcne
load-balancer: lb.example.com:6443
control-plane-nodes:
- control1.example.com:8090
- control2.example.com:8090
- control3.example.com:8090
worker-nodes:
- worker1.example.com:8090
- worker2.example.com:8090
- worker3.example.com:8090
selinux: enforcing
restrict-service-externalip: true
restrict-service-externalip-ca-cert: /etc/olcne/certificates/restrict_external_ip/ca.cert
restrict-service-externalip-tls-cert: /etc/olcne/certificates/restrict_external_ip/node.cert
restrict-service-externalip-tls-key: /etc/olcne/certificates/restrict_external_ip/node.key
- module: operator-lifecycle-manager
name: myolm
args:
olm-kubernetes-module: mycluster olcnectl moduleコマンドを使用して、Operator Lifecycle Managerモジュールをインストールします。
olcnectl module create \
--config-file myenvironment.yaml
olcnectl module validate \
--config-file myenvironment.yaml
olcnectl module install \
--config-file myenvironment.yaml Operator Lifecycle Managerモジュールは、環境内の既存のKubernetesクラスタにインストールされます。
構成ファイルを使用した特定のモジュールまたは環境のアンインストール
Platform API Serverは、構成ファイルに含まれるすべての情報を処理し、デプロイメントから特定のコンポーネントを削除する一方で、他のコンポーネントを残すため、削除するコンポーネントのみを含む個別の構成ファイルを作成する必要があります。 新しい構成ファイルには、アンインストールする環境およびモジュールに関する情報のみが含まれます。
たとえば、環境内のKubernetesモジュールではなくOperator Lifecycle Managerモジュールを削除するには、次のようなファイルを作成します。 このファイルは、Kubernetesモジュールに関する情報なしで「構成ファイルを使用したモジュールまたは環境の追加」で使用されるファイルと同じです。 モジュールがデプロイされる環境と、削除するモジュールのみを指定します。
environments:
- environment-name: myenvironment
globals:
api-server: 127.0.0.1:8091
secret-manager-type: file
olcne-ca-path: /etc/olcne/certificates/ca.cert
olcne-node-cert-path: /etc/olcne/certificates/node.cert
olcne-node-key-path: /etc/olcne/certificates/node.key
modules:
- module: operator-lifecycle-manager
name: myolm
args:
olm-kubernetes-module: mycluster
この例のファイル名はmyenvironment-olm.yamlです。
重要:
構成ファイルが正しいことを確認してから、デプロイメントの整合性を維持するためにモジュールをアンインストールします。
olcnectl module uninstallコマンドを使用して、Operator Lifecycle Managerモジュールをアンインストールします。 Platform API Serverによってモジュールが正しく削除されるようにするには、必ず--forceオプションを使用してください。
olcnectl module uninstall \
--config-file myenvironment-olm.yaml \
--forceOperator Lifecycle Managerモジュールは環境からアンインストールされますが、Kubernetesモジュールは変更されません。
構成ファイルを使用したクラスタのスケーリング
この項の情報は、構成ファイルを使用してKubernetesクラスタをスケーリングする方法を示しています。 クラスタのスケーリングおよびノードの準備の詳細は、「Kubernetesモジュール」を参照してください。
構成ファイルを使用してKubernetesクラスタをスケーリングするには、Kubernetesモジュールにリストされているノードを変更し、olcnectl module updateコマンドを使用して変更内容をモジュールに適用します。 たとえば、構成ファイルに次がリストされている既存のクラスタにノードを追加するには:
...
modules:
- module: kubernetes
name: mycluster
args:
container-registry: container-registry.oracle.com/olcne
load-balancer: lb.example.com:6443
control-plane-nodes:
- control1.example.com:8090
- control2.example.com:8090
- control3.example.com:8090
worker-nodes:
- worker1.example.com:8090
- worker2.example.com:8090
- worker3.example.com:8090
...新しいノードを構成ファイルに追加します。 この場合、2つの追加のコントロール・プレーン・ノードと1つの追加ワーカー・ノードがあります。
...
modules:
- module: kubernetes
name: mycluster
args:
container-registry: container-registry.oracle.com/olcne
load-balancer: lb.example.com:6443
control-plane-nodes:
- control1.example.com:8090
- control2.example.com:8090
- control3.example.com:8090
- control4.example.com:8090
- control5.example.com:8090
worker-nodes:
- worker1.example.com:8090
- worker2.example.com:8090
- worker3.example.com:8090
- worker4.example.com:8090
... olcnectl module updateコマンドを使用して、クラスタをスケール・アップします。
olcnectl module update \
--config-file myenvironment.yamlPlatform API Serverがクラスタをバックアップし、新しいノードを追加します。
クラスタをスケール・ダウンするには、クラスタから削除するノードに関する情報を構成ファイルから削除すること以外は、同じステップを実行します。
構成ファイルを使用した更新およびアップグレード
モジュールを更新またはアップグレードするときに、構成ファイルを使用できます。 モジュールの更新またはアップグレードの詳細は、「更新およびアップグレード」を参照してください。
すべてのモジュールを、使用可能な最新のエラータ・リリースに更新するには、olcnectl module updateコマンドを使用します。
olcnectl module update \
--config-file myenvironment.yaml モジュールを使用可能な最新のリリースにアップグレードするには、構成ファイルでモジュールのバージョンを設定し、olcnectl module updateコマンドを使用します。 たとえば、Kubernetesモジュールを最新バージョンにアップグレードするには、kube-version: 1.29.3を追加し、Istioモジュールの場合は、istio-version: 1.20.4を追加します:
...
modules:
- module: kubernetes
name: mycluster
args:
container-registry: container-registry.oracle.com/olcne
load-balancer: lb.example.com:6443
kube-version: 1.29.3
control-plane-nodes:
- control1.example.com:8090
- control2.example.com:8090
- control3.example.com:8090
worker-nodes:
- worker1.example.com:8090
- worker2.example.com:8090
- worker3.example.com:8090
selinux: enforcing
restrict-service-externalip: true
restrict-service-externalip-ca-cert: /etc/olcne/certificates/restrict_external_ip/ca.cert
restrict-service-externalip-tls-cert: /etc/olcne/certificates/restrict_external_ip/node.cert
restrict-service-externalip-tls-key: /etc/olcne/certificates/restrict_external_ip/node.key
modules:
- module: istio
name: myistio
args:
istio-kubernetes-module: mycluster
istio-version: 1.20.4 olcnectl module updateコマンドを使用して、構成ファイルにリストされているモジュールをアップグレードします。
olcnectl module update \
--config-file myenvironment.yaml構成ファイルを使用したアンインストール
構成ファイルを使用して環境およびモジュールをアンインストールするには、ファイルを使用せずにモジュールを削除するのに使用するのと同じolcnectlコマンドを使用します。 最初にモジュールを取り外してから、環境を削除します。
olcnectl module uninstallコマンドの--forceオプションを使用して、環境からモジュールを削除するときに、Platform API Serverによってモジュール依存関係の順序が内部的に維持されるようにします。
olcnectl module uninstall \
--config-file myenvironment.yaml \
--force構成ファイル内のすべてのモジュールが削除されます。
次を使用して環境を削除します:
olcnectl environment delete \
--config-file myenvironment.yaml 環境が削除されます。