×

使用集群 API 管理机器仅是技术预览功能。技术预览功能不受 Red Hat 生产服务级别协议 (SLA) 的支持,并且功能可能不完整。Red Hat 不建议在生产环境中使用它们。这些功能可让您抢先体验即将推出的产品功能,从而能够在开发过程中测试功能并提供反馈。

有关 Red Hat 技术预览功能的支持范围的更多信息,请参见 技术预览功能支持范围

您可以通过更新集群 API 自定义资源清单中的值来更改 Google Cloud Platform (GCP) 集群 API 机器的配置。

配置 Google Cloud Platform 集群的示例 YAML

以下示例 YAML 文件显示了 Google Cloud Platform 集群的配置。

Google Cloud Platform 上的集群 API 基础设施资源的示例 YAML

基础设施资源是特定于提供程序的,并定义了集群中所有计算机器集共享的属性,例如区域和子网。计算机器集在创建机器时会引用此资源。

apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPCluster (1)
metadata:
  name: <cluster_name> (2)
spec:
  controlPlaneEndpoint: (3)
    host: <control_plane_endpoint_address>
    port: 6443
  network:
    name: <cluster_name>-network
  project: <project> (4)
  region: <region> (5)
1 指定集群的基础设施类型。此值必须与您的平台的值匹配。
2 指定集群 ID 作为集群的名称。
3 指定控制平面端点的 IP 地址以及用于访问它的端口。
4 指定 GCP 项目名称。
5 指定 GCP 区域。

Google Cloud Platform 上的集群 API 机器模板资源的示例 YAML

机器模板资源是特定于提供程序的,并定义了计算机器集创建的机器的基本属性。计算机器集在创建机器时会引用此模板。

apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPMachineTemplate (1)
metadata:
  name: <template_name> (2)
  namespace: openshift-cluster-api
spec:
  template:
    spec: (3)
      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
1 指定机器模板类型。此值必须与您的平台的值匹配。
2 指定机器模板的名称。
3 指定您环境的详细信息。此处的数值是示例。

Google Cloud Platform 上的集群 API 计算机器集资源的示例 YAML

计算机器集资源定义了其创建的机器的其他属性。计算机器集在创建机器时还会引用基础设施资源和机器模板。

apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineSet
metadata:
  name: <machine_set_name> (1)
  namespace: openshift-cluster-api
spec:
  clusterName: <cluster_name> (2)
  replicas: 1
  selector:
    matchLabels:
      test: example
  template:
    metadata:
      labels:
        test: example
    spec:
      bootstrap:
         dataSecretName: worker-user-data (3)
      clusterName: <cluster_name>
      infrastructureRef:
        apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
        kind: GCPMachineTemplate (4)
        name: <template_name> (5)
      failureDomain: <failure_domain> (6)
1 指定计算机器集的名称。
2 指定集群 ID 作为集群的名称。
3 对于集群 API 技术预览版,操作员可以使用来自 `openshift-machine-api` 命名空间的 worker 用户数据密钥。
4 指定机器模板类型。此值必须与您的平台的值匹配。
5 指定机器模板名称。
6 指定 GCP 区域内的故障域。