12.2. サンプル YAML ファイル
Cluster API テクノロジープレビューの場合、Cluster API が必要とするプライマリーリソースを手動で作成する必要があります。このセクションのサンプル YAML ファイルは、これらのリソースを連携させて、それらが作成するマシンを環境に応じて設定する方法を示しています。
12.2.1. Cluster API クラスターリソースのサンプル YAML リンクのコピーリンクがクリップボードにコピーされました!
クラスターリソースは、クラスターの名前とインフラストラクチャープロバイダーを定義し、Cluster API によって管理されます。このリソースは、すべてのプロバイダーで同じ構造を持っています。
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: <cluster_name>
namespace: openshift-cluster-api
spec:
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: <infrastructure_kind>
name: <cluster_name>
namespace: openshift-cluster-api
残りはプロバイダー固有の Cluster API リソースです。クラスターのサンプル YAML ファイルを参照してください。
12.2.2. Amazon Web Services クラスターを設定するサンプル YAML ファイル リンクのコピーリンクがクリップボードにコピーされました!
一部の Cluster API リソースはプロバイダー固有です。このセクションのサンプル YAML ファイル、Amazon Web Services (AWS) クラスターの設定を示しています。
12.2.2.1. Amazon Web Services 上の Cluster API インフラストラクチャーリソースのサンプル YAML リンクのコピーリンクがクリップボードにコピーされました!
インフラストラクチャーリソースはプロバイダー固有であり、リージョンやサブネットなど、クラスター内のすべてのマシンセットで共有されるプロパティーを定義します。マシンセットは、マシン作成時にこのリソースを参照します。
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AWSCluster
metadata:
name: <cluster_name>
namespace: openshift-cluster-api
spec:
region: <region>
12.2.2.2. Amazon Web Services の Cluster API マシンテンプレートリソースのサンプル YAML リンクのコピーリンクがクリップボードにコピーされました!
マシンテンプレートリソースはプロバイダー固有であり、マシンセットが作成するマシンの基本的なプロパティーを定義します。マシンセットは、マシン作成時にこのテンプレートを参照します。
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha4
kind: AWSMachineTemplate
metadata:
name: <template_name>
namespace: openshift-cluster-api
spec:
template:
spec:
uncompressedUserData: true
iamInstanceProfile: ....
instanceType: m5.large
cloudInit:
insecureSkipSecretsManager: true
ami:
id: ....
subnet:
filters:
- name: tag:Name
values:
- ...
additionalSecurityGroups:
- filters:
- name: tag:Name
values:
- ...
12.2.2.3. Amazon Web Services の Cluster API マシンセットリソースのサンプル YAML リンクのコピーリンクがクリップボードにコピーされました!
マシンセットリソースは、作成するマシンの追加プロパティーを定義します。マシンセットは、マシン作成時にインフラストラクチャーリソースとマシンテンプレートも参照します。
apiVersion: cluster.x-k8s.io/v1alpha4
kind: MachineSet
metadata:
name: <machine_set_name>
namespace: openshift-cluster-api
spec:
clusterName: <cluster_name>
replicas: 1
selector:
matchLabels:
test: example
template:
metadata:
labels:
test: example
spec:
bootstrap:
dataSecretName: worker-user-data
clusterName: <cluster_name>
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha4
kind: AWSMachineTemplate
name: <cluster_name>
12.2.3. Google Cloud Platform クラスターを設定するサンプル YAML ファイル リンクのコピーリンクがクリップボードにコピーされました!
一部の Cluster API リソースはプロバイダー固有です。このセクションのサンプル YAML ファイルは、Google Cloud Platform (GCP) クラスターの設定を示しています。
12.2.3.1. Google Cloud Platform 上の Cluster API インフラストラクチャーリソースのサンプル YAML リンクのコピーリンクがクリップボードにコピーされました!
インフラストラクチャーリソースはプロバイダー固有であり、リージョンやサブネットなど、クラスター内のすべてのマシンセットで共有されるプロパティーを定義します。マシンセットは、マシン作成時にこのリソースを参照します。
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPCluster
metadata:
name: <cluster_name>
spec:
network:
name: <cluster_name>-network
project: <project>
region: <region>
12.2.3.2. Google Cloud Platform 上の Cluster API マシンテンプレートリソースのサンプル YAML リンクのコピーリンクがクリップボードにコピーされました!
マシンテンプレートリソースはプロバイダー固有であり、マシンセットが作成するマシンの基本的なプロパティーを定義します。マシンセットは、マシン作成時にこのテンプレートを参照します。
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPMachineTemplate
metadata:
name: <template_name>
namespace: openshift-cluster-api
spec:
template:
spec:
rootDeviceType: pd-ssd
rootDeviceSize: 128
instanceType: n1-standard-4
image: projects/rhcos-cloud/global/images/rhcos-411-85-202203181601-0-gcp-x86-64
subnet: <cluster_name>-worker-subnet
serviceAccounts:
email: <service_account_email_address>
scopes:
- https://www.googleapis.com/auth/cloud-platform
additionalLabels:
kubernetes-io-cluster-<cluster_name>: owned
additionalNetworkTags:
- <cluster_name>-worker
ipForwarding: Disabled
12.2.3.3. Google Cloud Platform 上の Cluster API マシンセットリソースのサンプル YAML リンクのコピーリンクがクリップボードにコピーされました!
マシンセットリソースは、作成するマシンの追加プロパティーを定義します。マシンセットは、マシン作成時にインフラストラクチャーリソースとマシンテンプレートも参照します。
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineSet
metadata:
name: <machine_set_name>
namespace: openshift-cluster-api
spec:
clusterName: <cluster_name>
replicas: 1
selector:
matchLabels:
test: test
template:
metadata:
labels:
test: test
spec:
bootstrap:
dataSecretName: worker-user-data
clusterName: <cluster_name>
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPMachineTemplate
name: <machine_set_name>
failureDomain: <failure_domain>