第 5 章 管理托管的 control plane


5.1. 在 AWS 上管理托管的 control plane

当您为 Amazon Web Services (AWS) 上的 OpenShift Container Platform 使用托管的 control plane 时,基础架构要求会因设置而异。

5.1.1. 管理 AWS 基础架构和 IAM 权限的先决条件

要在 Amazon Web Services (AWS) 上为 OpenShift Container Platform 配置托管的 control plane,您必须满足以下要求:

  • 在创建托管集群前,配置了托管的 control plane。
  • 您创建了 AWS Identity and Access Management (IAM) 角色和 AWS 安全令牌服务(STS) 凭证。

5.1.1.1. AWS 的基础架构要求

当您在 Amazon Web Services (AWS) 上使用托管的 control plane 时,基础架构要求适合以下类别:

  • 任意 AWS 帐户中的 HyperShift Operator 的 Prerequired 和 unmanaged 基础架构
  • 托管集群 AWS 帐户中的 Prerequired 和 unmanaged 基础架构
  • 在管理 AWS 帐户中托管 control planes 管理的基础架构
  • 在托管集群 AWS 帐户中托管 control plane 管理的基础架构
  • 托管集群 AWS 帐户中的 Kubernetes 管理基础架构

Prerequired 表示托管 control plane 需要 AWS 基础架构才能正常工作。Unmanaged 意味着没有 Operator 或控制器为您创建基础架构。

任意 Amazon Web Services (AWS) 帐户取决于托管的 control plane 服务的供应商。

在自我管理的托管 control plane 中,集群服务提供商控制 AWS 帐户。集群服务提供商是托管集群 control plane 并负责运行时间的管理员。在托管的 control plane 中,AWS 帐户属于红帽。

在 HyperShift Operator 的预必需和非受管基础架构中,为管理集群 AWS 帐户应用以下基础架构要求:

  • 一个 S3 存储桶

    • OpenID Connect(OIDC)
  • 路由 53 托管区域

    • 托管集群的私有和公共条目的域

5.1.1.3. 管理 AWS 帐户的非受管基础架构要求

当您的基础架构在托管集群 Amazon Web Services (AWS) 帐户中预必需且非受管时,所有访问模式的基础架构要求如下:

  • 一个 VPC
  • 一个 DHCP 选项
  • 两个子网

    • 作为内部数据平面子网的专用子网
    • 允许从数据平面访问互联网的公共子网
  • 一个互联网网关
  • 一个弹性 IP
  • 一个 NAT 网关
  • 一个安全组 (worker 节点)
  • 两个路由表(一个私有和一个公共)
  • 两个 Route 53 托管区
  • 以下项目有足够的配额:

    • 公共托管集群的一个 Ingress 服务负载均衡器
    • 私有托管集群的一个私有链接端点
注意

要使私有链接网络正常工作,托管集群 AWS 帐户中的端点区必须与管理集群 AWS 帐户中的服务端点解析的实例区匹配。在 AWS 中,区域名称是别名,如 us-east-2b,它不一定映射到不同帐户中的同一区域。因此,要使私有链接正常工作,管理集群在其区域的所有区域中都有子网或 worker。

5.1.1.4. 管理 AWS 帐户的基础架构要求

当您的基础架构由管理 AWS 帐户中的托管 control plane 管理时,基础架构要求会因集群是公共、私有还是组合而异。

对于具有公共集群的帐户,基础架构要求如下:

  • 网络负载均衡器:负载均衡器 Kube API 服务器

    • Kubernetes 创建一个安全组
    • 对于 etcd (根据是否为高可用性,一个或三个)
    • 对于 OVN-Kube

对于带有私有集群的帐户,基础架构要求如下:

  • 网络负载均衡器:负载均衡器私有路由器
  • 端点服务(专用链接)

对于具有公共和私有集群的帐户,基础架构要求如下:

  • 网络负载均衡器:负载均衡器公共路由器
  • 网络负载均衡器:负载均衡器私有路由器
  • 端点服务(专用链接)
    • 对于 etcd (根据是否为高可用性,一个或三个)
    • 对于 OVN-Kube

5.1.1.5. 托管集群中的 AWS 帐户的基础架构要求

当您的基础架构由托管集群 Amazon Web Services (AWS) 帐户中托管的 control plane 管理时,基础架构要求会根据集群是公共、私有还是组合而有所不同。

对于具有公共集群的帐户,基础架构要求如下:

  • 节点池必须具有定义 RoleRolePolicy 的 EC2 实例。

对于带有私有集群的帐户,基础架构要求如下:

  • 每个可用区有一个私有链接端点
  • 节点池的 EC2 实例

对于具有公共和私有集群的帐户,基础架构要求如下:

  • 每个可用区有一个私有链接端点
  • 节点池的 EC2 实例

当 Kubernetes 在托管集群 Amazon Web Services (AWS) 帐户中管理您的基础架构时,基础架构要求如下:

  • 默认入口的网络负载均衡器
  • registry 的 S3 存储桶

5.1.2. Identity and Access Management (IAM) 权限

在托管 control plane 的上下文中,使用者负责创建 Amazon 资源名称 (ARN) 角色。consumer 是生成权限文件的自动化过程。消费者可以是 CLI 或 OpenShift Cluster Manager。托管 control plane 可以达到最低特权组件的原则,这意味着每个组件都使用自己的角色来运行或创建 Amazon Web Services (AWS) 对象,角色仅限于产品正常工作所需的内容。

托管的集群接收 ARN 角色作为输入,消费者为每个组件创建一个 AWS 权限配置。因此,组件可以通过 STS 和预配置的 OIDC IDP 进行身份验证。

以下角色由 control plane 上运行的托管 control plane 中的一些组件使用,并在数据平面上运行:

  • controlPlaneOperatorARN
  • imageRegistryARN
  • ingressARN
  • kubeCloudControllerARN
  • nodePoolManagementARN
  • storageARN
  • networkARN

以下示例显示了对托管集群的 IAM 角色的引用:

...
endpointAccess: Public
  region: us-east-2
  resourceTags:
  - key: kubernetes.io/cluster/example-cluster-bz4j5
    value: owned
rolesRef:
    controlPlaneOperatorARN: arn:aws:iam::820196288204:role/example-cluster-bz4j5-control-plane-operator
    imageRegistryARN: arn:aws:iam::820196288204:role/example-cluster-bz4j5-openshift-image-registry
    ingressARN: arn:aws:iam::820196288204:role/example-cluster-bz4j5-openshift-ingress
    kubeCloudControllerARN: arn:aws:iam::820196288204:role/example-cluster-bz4j5-cloud-controller
    networkARN: arn:aws:iam::820196288204:role/example-cluster-bz4j5-cloud-network-config-controller
    nodePoolManagementARN: arn:aws:iam::820196288204:role/example-cluster-bz4j5-node-pool
    storageARN: arn:aws:iam::820196288204:role/example-cluster-bz4j5-aws-ebs-csi-driver-controller
type: AWS
...
Copy to Clipboard Toggle word wrap

以下示例中显示了托管 control plane 使用的角色:

  • ingressARN

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "elasticloadbalancing:DescribeLoadBalancers",
                    "tag:GetResources",
                    "route53:ListHostedZones"
                ],
                "Resource": "\*"
            },
            {
                "Effect": "Allow",
                "Action": [
                    "route53:ChangeResourceRecordSets"
                ],
                "Resource": [
                    "arn:aws:route53:::PUBLIC_ZONE_ID",
                    "arn:aws:route53:::PRIVATE_ZONE_ID"
                ]
            }
        ]
    }
    Copy to Clipboard Toggle word wrap
  • imageRegistryARN

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "s3:CreateBucket",
                    "s3:DeleteBucket",
                    "s3:PutBucketTagging",
                    "s3:GetBucketTagging",
                    "s3:PutBucketPublicAccessBlock",
                    "s3:GetBucketPublicAccessBlock",
                    "s3:PutEncryptionConfiguration",
                    "s3:GetEncryptionConfiguration",
                    "s3:PutLifecycleConfiguration",
                    "s3:GetLifecycleConfiguration",
                    "s3:GetBucketLocation",
                    "s3:ListBucket",
                    "s3:GetObject",
                    "s3:PutObject",
                    "s3:DeleteObject",
                    "s3:ListBucketMultipartUploads",
                    "s3:AbortMultipartUpload",
                    "s3:ListMultipartUploadParts"
                ],
                "Resource": "\*"
            }
        ]
    }
    Copy to Clipboard Toggle word wrap
  • storageARN

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "ec2:AttachVolume",
                    "ec2:CreateSnapshot",
                    "ec2:CreateTags",
                    "ec2:CreateVolume",
                    "ec2:DeleteSnapshot",
                    "ec2:DeleteTags",
                    "ec2:DeleteVolume",
                    "ec2:DescribeInstances",
                    "ec2:DescribeSnapshots",
                    "ec2:DescribeTags",
                    "ec2:DescribeVolumes",
                    "ec2:DescribeVolumesModifications",
                    "ec2:DetachVolume",
                    "ec2:ModifyVolume"
                ],
                "Resource": "\*"
            }
        ]
    }
    Copy to Clipboard Toggle word wrap
  • networkARN

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "ec2:DescribeInstances",
                    "ec2:DescribeInstanceStatus",
                    "ec2:DescribeInstanceTypes",
                    "ec2:UnassignPrivateIpAddresses",
                    "ec2:AssignPrivateIpAddresses",
                    "ec2:UnassignIpv6Addresses",
                    "ec2:AssignIpv6Addresses",
                    "ec2:DescribeSubnets",
                    "ec2:DescribeNetworkInterfaces"
                ],
                "Resource": "\*"
            }
        ]
    }
    Copy to Clipboard Toggle word wrap
  • kubeCloudControllerARN

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Action": [
                    "ec2:DescribeInstances",
                    "ec2:DescribeImages",
                    "ec2:DescribeRegions",
                    "ec2:DescribeRouteTables",
                    "ec2:DescribeSecurityGroups",
                    "ec2:DescribeSubnets",
                    "ec2:DescribeVolumes",
                    "ec2:CreateSecurityGroup",
                    "ec2:CreateTags",
                    "ec2:CreateVolume",
                    "ec2:ModifyInstanceAttribute",
                    "ec2:ModifyVolume",
                    "ec2:AttachVolume",
                    "ec2:AuthorizeSecurityGroupIngress",
                    "ec2:CreateRoute",
                    "ec2:DeleteRoute",
                    "ec2:DeleteSecurityGroup",
                    "ec2:DeleteVolume",
                    "ec2:DetachVolume",
                    "ec2:RevokeSecurityGroupIngress",
                    "ec2:DescribeVpcs",
                    "elasticloadbalancing:AddTags",
                    "elasticloadbalancing:AttachLoadBalancerToSubnets",
                    "elasticloadbalancing:ApplySecurityGroupsToLoadBalancer",
                    "elasticloadbalancing:CreateLoadBalancer",
                    "elasticloadbalancing:CreateLoadBalancerPolicy",
                    "elasticloadbalancing:CreateLoadBalancerListeners",
                    "elasticloadbalancing:ConfigureHealthCheck",
                    "elasticloadbalancing:DeleteLoadBalancer",
                    "elasticloadbalancing:DeleteLoadBalancerListeners",
                    "elasticloadbalancing:DescribeLoadBalancers",
                    "elasticloadbalancing:DescribeLoadBalancerAttributes",
                    "elasticloadbalancing:DetachLoadBalancerFromSubnets",
                    "elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
                    "elasticloadbalancing:ModifyLoadBalancerAttributes",
                    "elasticloadbalancing:RegisterInstancesWithLoadBalancer",
                    "elasticloadbalancing:SetLoadBalancerPoliciesForBackendServer",
                    "elasticloadbalancing:AddTags",
                    "elasticloadbalancing:CreateListener",
                    "elasticloadbalancing:CreateTargetGroup",
                    "elasticloadbalancing:DeleteListener",
                    "elasticloadbalancing:DeleteTargetGroup",
                    "elasticloadbalancing:DescribeListeners",
                    "elasticloadbalancing:DescribeLoadBalancerPolicies",
                    "elasticloadbalancing:DescribeTargetGroups",
                    "elasticloadbalancing:DescribeTargetHealth",
                    "elasticloadbalancing:ModifyListener",
                    "elasticloadbalancing:ModifyTargetGroup",
                    "elasticloadbalancing:RegisterTargets",
                    "elasticloadbalancing:SetLoadBalancerPoliciesOfListener",
                    "iam:CreateServiceLinkedRole",
                    "kms:DescribeKey"
                ],
                "Resource": [
                    "\*"
                ],
                "Effect": "Allow"
            }
        ]
    }
    Copy to Clipboard Toggle word wrap
  • nodePoolManagementARN

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Action": [
                    "ec2:AllocateAddress",
                    "ec2:AssociateRouteTable",
                    "ec2:AttachInternetGateway",
                    "ec2:AuthorizeSecurityGroupIngress",
                    "ec2:CreateInternetGateway",
                    "ec2:CreateNatGateway",
                    "ec2:CreateRoute",
                    "ec2:CreateRouteTable",
                    "ec2:CreateSecurityGroup",
                    "ec2:CreateSubnet",
                    "ec2:CreateTags",
                    "ec2:DeleteInternetGateway",
                    "ec2:DeleteNatGateway",
                    "ec2:DeleteRouteTable",
                    "ec2:DeleteSecurityGroup",
                    "ec2:DeleteSubnet",
                    "ec2:DeleteTags",
                    "ec2:DescribeAccountAttributes",
                    "ec2:DescribeAddresses",
                    "ec2:DescribeAvailabilityZones",
                    "ec2:DescribeImages",
                    "ec2:DescribeInstances",
                    "ec2:DescribeInternetGateways",
                    "ec2:DescribeNatGateways",
                    "ec2:DescribeNetworkInterfaces",
                    "ec2:DescribeNetworkInterfaceAttribute",
                    "ec2:DescribeRouteTables",
                    "ec2:DescribeSecurityGroups",
                    "ec2:DescribeSubnets",
                    "ec2:DescribeVpcs",
                    "ec2:DescribeVpcAttribute",
                    "ec2:DescribeVolumes",
                    "ec2:DetachInternetGateway",
                    "ec2:DisassociateRouteTable",
                    "ec2:DisassociateAddress",
                    "ec2:ModifyInstanceAttribute",
                    "ec2:ModifyNetworkInterfaceAttribute",
                    "ec2:ModifySubnetAttribute",
                    "ec2:ReleaseAddress",
                    "ec2:RevokeSecurityGroupIngress",
                    "ec2:RunInstances",
                    "ec2:TerminateInstances",
                    "tag:GetResources",
                    "ec2:CreateLaunchTemplate",
                    "ec2:CreateLaunchTemplateVersion",
                    "ec2:DescribeLaunchTemplates",
                    "ec2:DescribeLaunchTemplateVersions",
                    "ec2:DeleteLaunchTemplate",
                    "ec2:DeleteLaunchTemplateVersions"
                ],
                "Resource": [
                    "\*"
                ],
                "Effect": "Allow"
            },
            {
                "Condition": {
                    "StringLike": {
                        "iam:AWSServiceName": "elasticloadbalancing.amazonaws.com"
                    }
                },
                "Action": [
                    "iam:CreateServiceLinkedRole"
                ],
                "Resource": [
                    "arn:*:iam::*:role/aws-service-role/elasticloadbalancing.amazonaws.com/AWSServiceRoleForElasticLoadBalancing"
                ],
                "Effect": "Allow"
            },
            {
                "Action": [
                    "iam:PassRole"
                ],
                "Resource": [
                    "arn:*:iam::*:role/*-worker-role"
                ],
                "Effect": "Allow"
            }
        ]
    }
    Copy to Clipboard Toggle word wrap
  • controlPlaneOperatorARN

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "ec2:CreateVpcEndpoint",
                    "ec2:DescribeVpcEndpoints",
                    "ec2:ModifyVpcEndpoint",
                    "ec2:DeleteVpcEndpoints",
                    "ec2:CreateTags",
                    "route53:ListHostedZones"
                ],
                "Resource": "\*"
            },
            {
                "Effect": "Allow",
                "Action": [
                    "route53:ChangeResourceRecordSets",
                    "route53:ListResourceRecordSets"
                ],
                "Resource": "arn:aws:route53:::%s"
            }
        ]
    }
    Copy to Clipboard Toggle word wrap

5.1.3. 创建 AWS 基础架构和 IAM 资源分离

默认情况下,hcp create cluster aws 命令使用托管集群创建云基础架构并应用它。您可以单独创建云基础架构部分,以便您可以使用 hcp create cluster aws 命令只创建集群,或者在应用前呈现它进行修改。

要单独创建云基础架构部分,您需要创建 Amazon Web Services (AWS) 基础架构,创建 AWS Identity and Access (IAM) 资源并创建集群。

5.1.3.1. 单独创建 AWS 基础架构

要创建 Amazon Web Services (AWS) 基础架构,您需要为集群创建 Virtual Private Cloud (VPC) 和其他资源。您可以使用 AWS 控制台或基础架构自动化和置备工具。有关使用 AWS 控制台的说明,请参阅 AWS 文档中的创建 VPC 和其他 VPC 资源

VPC 必须包含用于外部访问的私有和公共子网和资源,如网络地址转换(NAT)网关和互联网网关。除了 VPC 外,还需要集群入口的一个私有托管区。如果您要创建使用 PrivateLink (PrivatePublicAndPrivate 访问模式)的集群,则需要一个额外的托管区用于 PrivateLink。

使用以下示例配置为托管集群创建 AWS 基础架构:

---
apiVersion: v1
kind: Namespace
metadata:
  creationTimestamp: null
  name: clusters
spec: {}
status: {}
---
apiVersion: v1
data:
  .dockerconfigjson: xxxxxxxxxxx
kind: Secret
metadata:
  creationTimestamp: null
  labels:
    hypershift.openshift.io/safe-to-delete-with-cluster: "true"
  name: <pull_secret_name> 
1

  namespace: clusters
---
apiVersion: v1
data:
  key: xxxxxxxxxxxxxxxxx
kind: Secret
metadata:
  creationTimestamp: null
  labels:
    hypershift.openshift.io/safe-to-delete-with-cluster: "true"
  name: <etcd_encryption_key_name> 
2

  namespace: clusters
type: Opaque
---
apiVersion: v1
data:
  id_rsa: xxxxxxxxx
  id_rsa.pub: xxxxxxxxx
kind: Secret
metadata:
  creationTimestamp: null
  labels:
    hypershift.openshift.io/safe-to-delete-with-cluster: "true"
  name: <ssh-key-name> 
3

  namespace: clusters
---
apiVersion: hypershift.openshift.io/v1beta1
kind: HostedCluster
metadata:
  creationTimestamp: null
  name: <hosted_cluster_name> 
4

  namespace: clusters
spec:
  autoscaling: {}
  configuration: {}
  controllerAvailabilityPolicy: SingleReplica
  dns:
    baseDomain: <dns_domain> 
5

    privateZoneID: xxxxxxxx
    publicZoneID: xxxxxxxx
  etcd:
    managed:
      storage:
        persistentVolume:
          size: 8Gi
          storageClassName: gp3-csi
        type: PersistentVolume
    managementType: Managed
  fips: false
  infraID: <infra_id> 
6

  issuerURL: <issuer_url> 
7

  networking:
    clusterNetwork:
    - cidr: 10.132.0.0/14
    machineNetwork:
    - cidr: 10.0.0.0/16
    networkType: OVNKubernetes
    serviceNetwork:
    - cidr: 172.31.0.0/16
  olmCatalogPlacement: management
  platform:
    aws:
      cloudProviderConfig:
        subnet:
          id: <subnet_xxx> 
8

        vpc: <vpc_xxx> 
9

        zone: us-west-1b
      endpointAccess: Public
      multiArch: false
      region: us-west-1
      rolesRef:
        controlPlaneOperatorARN: arn:aws:iam::820196288204:role/<infra_id>-control-plane-operator
        imageRegistryARN: arn:aws:iam::820196288204:role/<infra_id>-openshift-image-registry
        ingressARN: arn:aws:iam::820196288204:role/<infra_id>-openshift-ingress
        kubeCloudControllerARN: arn:aws:iam::820196288204:role/<infra_id>-cloud-controller
        networkARN: arn:aws:iam::820196288204:role/<infra_id>-cloud-network-config-controller
        nodePoolManagementARN: arn:aws:iam::820196288204:role/<infra_id>-node-pool
        storageARN: arn:aws:iam::820196288204:role/<infra_id>-aws-ebs-csi-driver-controller
    type: AWS
  pullSecret:
    name: <pull_secret_name>
  release:
    image: quay.io/openshift-release-dev/ocp-release:4.16-x86_64
  secretEncryption:
    aescbc:
      activeKey:
        name: <etcd_encryption_key_name>
    type: aescbc
  services:
  - service: APIServer
    servicePublishingStrategy:
      type: LoadBalancer
  - service: OAuthServer
    servicePublishingStrategy:
      type: Route
  - service: Konnectivity
    servicePublishingStrategy:
      type: Route
  - service: Ignition
    servicePublishingStrategy:
      type: Route
  - service: OVNSbDb
    servicePublishingStrategy:
      type: Route
  sshKey:
    name: <ssh_key_name>
status:
  controlPlaneEndpoint:
    host: ""
    port: 0
---
apiVersion: hypershift.openshift.io/v1beta1
kind: NodePool
metadata:
  creationTimestamp: null
  name: <node_pool_name> 
10

  namespace: clusters
spec:
  arch: amd64
  clusterName: <hosted_cluster_name>
  management:
    autoRepair: true
    upgradeType: Replace
  nodeDrainTimeout: 0s
  platform:
    aws:
      instanceProfile: <instance_profile_name> 
11

      instanceType: m6i.xlarge
      rootVolume:
        size: 120
        type: gp3
      subnet:
        id: <subnet_xxx>
    type: AWS
  release:
    image: quay.io/openshift-release-dev/ocp-release:4.16-x86_64
  replicas: 2
status:
  replicas: 0
Copy to Clipboard Toggle word wrap
1
<pull_secret_name> 替换为 pull secret 的名称。
2
<etcd_encryption_key_name> 替换为 etcd 加密密钥的名称。
3
<ssh_key_name> 替换为 SSH 密钥的名称。
4
<hosted_cluster_name> 替换为托管集群的名称。
5
<dns_domain> 替换为您的基本 DNS 域,如 example.com
6
<infra_id> 替换为用于标识与托管集群关联的 IAM 资源的值。
7
<issuer_url> 替换为您的签发者 URL,其结尾是 infra_id 值。例如,https://example-hosted-us-west-1.s3.us-west-1.amazonaws.com/example-hosted-infra-id
8
<subnet_xxx> 替换为您的子网 ID。私有和公共子网都需要标记。对于公共子网,使用 kubernetes.io/role/elb=1。对于私有子网,使用 kubernetes.io/role/internal-elb=1
9
<vpc_xxx> 替换为您的 VPC ID。
10
<node_pool_name> 替换为 NodePool 资源的名称。
11
<instance_profile_name> 替换为 AWS 实例的名称。

5.1.3.2. 创建 AWS IAM 资源

在 Amazon Web Services (AWS) 中,您必须创建以下 IAM 资源:

5.1.3.3. 单独创建托管集群

您可以在 Amazon Web Services (AWS) 上单独创建托管集群。

要单独创建托管集群,请输入以下命令:

$ hcp create cluster aws \
    --infra-id <infra_id> \
1

    --name <hosted_cluster_name> \
2

    --sts-creds <path_to_sts_credential_file> \
3

    --pull-secret <path_to_pull_secret> \
4

    --generate-ssh \
5

    --node-pool-replicas 3
    --role-arn <role_name> 
6
Copy to Clipboard Toggle word wrap
1
<infra_id> 替换为您在 create infra aws 命令中指定的相同 ID。这个值标识与托管集群关联的 IAM 资源。
2
<hosted_cluster_name> 替换为托管集群的名称。
3
<path_to_sts_credential_file> 替换为您在 create infra aws 命令中指定的相同名称。
4
<path_to_pull_secret> 替换为包含有效 OpenShift Container Platform pull secret 的文件名称。
5
--generate-ssh 标志是可选的,但最好包括,它在 SSH 到您的 worker 时需要。为您生成 SSH 密钥,并作为 secret 存储在与托管集群相同的命名空间中。
6
<role_name> 替换为 Amazon Resource Name (ARN),例如 arn:aws:iam::820196288204:role/myrole。指定 Amazon Resource Name (ARN),例如 arn:aws:iam::820196288204:role/myrole。有关 ARN 角色的更多信息,请参阅"Identity and Access Management (IAM) 权限"。

您还可以在命令中添加 --render 标志,并将输出重定向到文件,您可以在其中编辑资源,然后再将它们应用到集群。

运行命令后,以下资源将应用到集群:

  • 一个命名空间
  • 带有 pull secret 的 secret
  • A HostedCluster
  • A NodePool
  • control plane 组件的三个 AWS STS secret
  • 如果指定了 --generate-ssh 标志,则一个 SSH 密钥 secret。

5.1.4. 将托管集群从单架构转换到多架构

您可以将单架构 64 位 AMD 托管的集群转换到 Amazon Web Services (AWS)上的多架构托管集群,以降低在集群中运行工作负载的成本。例如,您可以在迁移到 64 位 ARM 时在 64 位 AMD 上运行现有工作负载,您可以从中央 Kubernetes 集群管理这些工作负载。

单一架构托管的集群只能管理一个特定 CPU 架构的节点池。但是,一个多架构托管集群可以管理具有不同 CPU 架构的节点池。在 AWS 上,托管集群的多架构可以管理 64 位 AMD 和 64 位 ARM 节点池。

先决条件

  • 您已在带有 multicluster engine for Kubernetes Operator 的 Red Hat Advanced Cluster Management (RHACM) 上安装了 OpenShift Container Platform 管理集群。
  • 您有一个现有的单架构托管集群,它使用 OpenShift Container Platform 发行有效负载的 64 位 AMD 变体。
  • 一个现有节点池,它使用 OpenShift Container Platform 版本有效负载相同的 64 位 AMD 变体,并由现有的托管集群管理。
  • 确保安装了以下命令行工具:

    • oc
    • kubectl
    • hcp
    • skopeo

流程

  1. 运行以下命令,查看单架构托管的集群的现有 OpenShift Container Platform 发行镜像:

    $ oc get hostedcluster/<hosted_cluster_name> \
    1
    
      -o jsonpath='{.spec.release.image}'
    Copy to Clipboard Toggle word wrap
    1
    <hosted_cluster_name> 替换为托管集群的名称。

    输出示例

    quay.io/openshift-release-dev/ocp-release:<4.y.z>-x86_64 
    1
    Copy to Clipboard Toggle word wrap

    1
    <4.y.z> 替换为您使用的受支持 OpenShift Container Platform 版本。
  2. 在 OpenShift Container Platform 发行镜像中,如果使用摘要而不是标签,找到发行镜像的多架构标签版本:

    1. 运行以下命令,为 OpenShift Container Platform 版本设置 OCP_VERSION 环境变量:

      $ OCP_VERSION=$(oc image info quay.io/openshift-release-dev/ocp-release@sha256:ac78ebf77f95ab8ff52847ecd22592b545415e1ff6c7ff7f66bf81f158ae4f5e \
        -o jsonpath='{.config.config.Labels["io.openshift.release"]}')
      Copy to Clipboard Toggle word wrap
    2. 运行以下命令,为您的发行镜像的多架构标签版本设置 MULTI_ARCH_TAG 环境变量:

      $ MULTI_ARCH_TAG=$(skopeo inspect docker://quay.io/openshift-release-dev/ocp-release@sha256:ac78ebf77f95ab8ff52847ecd22592b545415e1ff6c7ff7f66bf81f158ae4f5e \
        | jq -r '.RepoTags' | sed 's/"//g' | sed 's/,//g' \
        | grep -w "$OCP_VERSION-multi$" | xargs)
      Copy to Clipboard Toggle word wrap
    3. 运行以下命令,为多架构发行镜像名称设置 IMAGE 环境变量:

      $ IMAGE=quay.io/openshift-release-dev/ocp-release:$MULTI_ARCH_TAG
      Copy to Clipboard Toggle word wrap
    4. 要查看多架构镜像摘要列表,请运行以下命令:

      $ oc image info $IMAGE
      Copy to Clipboard Toggle word wrap

      输出示例

      OS            DIGEST
      linux/amd64   sha256:b4c7a91802c09a5a748fe19ddd99a8ffab52d8a31db3a081a956a87f22a22ff8
      linux/ppc64le sha256:66fda2ff6bd7704f1ba72be8bfe3e399c323de92262f594f8e482d110ec37388
      linux/s390x   sha256:b1c1072dc639aaa2b50ec99b530012e3ceac19ddc28adcbcdc9643f2dfd14f34
      linux/arm64   sha256:7b046404572ac96202d82b6cb029b421dddd40e88c73bbf35f602ffc13017f21
      Copy to Clipboard Toggle word wrap

  3. 将托管集群从单架构转换为多架构:

    1. 通过确保使用与托管集群相同的 OpenShift Container Platform 版本,为托管集群设置多架构 OpenShift Container Platform 发行镜像。运行以下命令:

      $ oc patch -n clusters hostedclusters/<hosted_cluster_name> -p \
        '{"spec":{"release":{"image":"quay.io/openshift-release-dev/ocp-release:<4.x.y>-multi"}}}' \
      1
      
        --type=merge
      Copy to Clipboard Toggle word wrap
      1
      <4.y.z> 替换为您使用的受支持 OpenShift Container Platform 版本。
    2. 运行以下命令确认托管集群中设置了多架构镜像:

      $ oc get hostedcluster/<hosted_cluster_name> \
        -o jsonpath='{.spec.release.image}'
      Copy to Clipboard Toggle word wrap
  4. 运行以下命令,检查 HostedControlPlane 资源的状态是否为 Progressing

    $ oc get hostedcontrolplane -n <hosted_control_plane_namespace> -oyaml
    Copy to Clipboard Toggle word wrap

    输出示例

    #...
      - lastTransitionTime: "2024-07-28T13:07:18Z"
        message: HostedCluster is deploying, upgrading, or reconfiguring
        observedGeneration: 5
        reason: Progressing
        status: "True"
        type: Progressing
    #...
    Copy to Clipboard Toggle word wrap

  5. 运行以下命令,检查 HostedCluster 资源的状态是否为 Progressing

    $ oc get hostedcluster <hosted_cluster_name> \
      -n <hosted_cluster_namespace> -oyaml
    Copy to Clipboard Toggle word wrap

验证

  • 运行以下命令,验证节点池是否使用 HostedControlPlane 资源中的多架构发行镜像:

    $ oc get hostedcontrolplane -n clusters-example -oyaml
    Copy to Clipboard Toggle word wrap

    输出示例

    #...
    version:
        availableUpdates: null
        desired:
          image: quay.io/openshift-release-dev/ocp-release:<4.x.y>-multi 
    1
    
          url: https://access.redhat.com/errata/RHBA-2024:4855
          version: 4.16.5
        history:
        - completionTime: "2024-07-28T13:10:58Z"
          image: quay.io/openshift-release-dev/ocp-release:<4.x.y>-multi
          startedTime: "2024-07-28T13:10:27Z"
          state: Completed
          verified: false
          version: <4.x.y>
    Copy to Clipboard Toggle word wrap

    1
    <4.y.z> 替换为您使用的受支持 OpenShift Container Platform 版本。
    注意

    多架构 OpenShift Container Platform 发行镜像在 HostedClusterHostedControlPlane 资源和托管的 control plane pod 中更新。但是,您的现有节点池不会自动与多架构镜像转换,因为发行镜像转换在托管集群和节点池间分离。您必须在新的多架构托管集群中创建新节点池。

后续步骤

  • 在托管集群的多架构集群中创建节点池

5.1.5. 在托管集群的多架构集群中创建节点池

将托管集群从单架构转换为多架构后,根据 64 位 AMD 和 64 位 ARM 架构在计算机器上创建节点池。

流程

  1. 输入以下命令,根据 64 位 ARM 架构创建节点池:

    $ hcp create nodepool aws \
      --cluster-name <hosted_cluster_name> \
    1
    
      --name <nodepool_name> \
    2
    
      --node-count=<node_count> \
    3
    
      --arch arm64
    Copy to Clipboard Toggle word wrap
    1
    <hosted_cluster_name> 替换为托管集群的名称。
    2
    <nodepool_name> 替换为您的节点池名称。
    3
    <node_count> 替换为您的节点数的整数,例如 2
  2. 输入以下命令基于 64 位 AMD 架构创建节点池:

    $ hcp create nodepool aws \
      --cluster-name <hosted_cluster_name> \
    1
    
      --name <nodepool_name> \
    2
    
      --node-count=<node_count> \
    3
    
      --arch amd64
    Copy to Clipboard Toggle word wrap
    1
    <hosted_cluster_name> 替换为托管集群的名称。
    2
    <nodepool_name> 替换为您的节点池名称。
    3
    <node_count> 替换为您的节点数的整数,例如 2

验证

  • 输入以下命令验证节点池是否使用多架构发行镜像:

    $ oc get nodepool/<nodepool_name> -oyaml
    Copy to Clipboard Toggle word wrap

    64 位 AMD 节点池的输出示例

    #...
    spec:
      arch: amd64
    #...
      release:
        image: quay.io/openshift-release-dev/ocp-release:<4.x.y>-multi 
    1
    Copy to Clipboard Toggle word wrap

    1
    <4.y.z> 替换为您使用的受支持 OpenShift Container Platform 版本。

    64 位 ARM 节点池的输出示例

    #...
    spec:
      arch: arm64
    #...
      release:
        image: quay.io/openshift-release-dev/ocp-release:<4.x.y>-multi
    Copy to Clipboard Toggle word wrap

5.1.6. 为托管集群添加或更新 AWS 标签

作为集群管理员,您可以添加或更新 Amazon Web Services (AWS) 标签,而无需重新创建托管集群。标签(tag)是附加到 AWS 资源来管理和自动化的键值对。

您可能希望将标签用于以下目的:

  • 管理访问控制。
  • 跟踪计费或成本分析。
  • 管理云 IAM 条件权限。
  • 根据标签聚合资源。例如,您可以查询标签来计算资源使用量和计费成本。

您可以为几种不同类型的资源添加或更新标签,包括 EFS 访问点、负载均衡器资源、Amazon EBS 卷、IAM 用户和 AWS S3。

重要

在网络负载均衡器中,无法添加或更新标签。AWS 负载均衡器协调 HostedCluster 资源中的任何标签。如果您尝试添加或更新标签,负载均衡器会覆盖该标签。

另外,标签不能在由托管 control plane 创建的默认安全组资源上更新。

先决条件

  • 您必须在 AWS 上具有集群管理员权限。

流程

  1. 如果要为 EFS 访问点添加或更新标签,请完成第 1 步和 2 步。如果您要为其他类型的资源添加或更新标签,请仅完成第 2 步。

    1. aws-efs-csi-driver-operator 服务帐户中,添加两个注解,如下例所示。这些注解是必需的,以便集群中运行的 AWS EKS pod 身份 Webhook 可以正确地将 AWS 角色分配给 EFS Operator 使用的 pod。

      apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: <service_account_name>
        namespace: <project_name>
        annotations:
          eks.amazonaws.com/role-arn:<role_arn>
          eks.amazonaws.com/audience:sts.amazonaws.com
      Copy to Clipboard Toggle word wrap
    2. 删除 Operator pod 或推出 aws-efs-csi-driver-operator 部署重启。
  2. HostedCluster 资源中,在 resourceTags 字段中输入信息,如下例所示:

    HostedCluster 资源示例

    apiVersion: hypershift.openshift.io/v1beta1
    kind: HostedCluster
    metadata:
      #...
    spec:
      autoscaling: {}
      clusterID: <cluster_id>
      configuration: {}
      controllerAvailabilityPolicy: SingleReplica
      dns:
        #...
      etcd:
        #...
      fips: false
      infraID: <infra_id>
      infrastructureAvailabilityPolicy: SingleReplica
      issuerURL: https://<issuer_url>.s3.<region>.amazonaws.com
      networking:
        #...
      olmCatalogPlacement: management
      platform:
        aws:
          #...
          resourceTags:
          - key: kubernetes.io/cluster/<tag> 
    1
    
            value: owned
          rolesRef:
            #...
        type: AWS
    Copy to Clipboard Toggle word wrap

1
指定要添加到资源中的标签。

5.1.7. 在 AWS 中配置节点池容量块

创建托管集群后,您可以在 Amazon Web Services (AWS)上为图形处理单元(GPU)保留配置节点池容量块。

流程

  1. 运行以下命令,在 AWS 上创建 GPU 保留:

    重要

    GPU 保留的区域必须与托管集群区匹配。

    $ aws ec2 describe-capacity-block-offerings \
          --instance-type "p4d.24xlarge"\ 
    1
    
          --instance-count  "1" \ 
    2
    
          --start-date-range "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"  \ 
    3
    
          --end-date-range "$(date -u -d "2 day" +"%Y-%m-%dT%H:%M:%SZ")" \ 
    4
    
          --capacity-duration-hours 24 \ 
    5
    
          --output json
    Copy to Clipboard Toggle word wrap
    1
    定义 AWS 实例的类型,如 p4d.24xlarge
    2
    定义您的实例购买数量,例如 1。有效值为整数,范围从 164
    3
    定义起始日期范围,如 2025-07-21T10:14:39Z
    4
    定义结束日期范围,如 2025-07-22T10:16:36Z
    5
    定义容量块的持续时间(以小时为单位),例如 24
  2. 运行以下命令来购买最小费用容量块:

    $ aws ec2 purchase-capacity-block \
          --capacity-block-offering-id "${MIN_FEE_ID}" \ 
    1
    
          --instance-platform "Linux/UNIX"\ 
    2
    
          --tag-specifications 'ResourceType=capacity-reservation,Tags=[{Key=usage-cluster-type,Value=hypershift-hosted}]' \ 
    3
    
          --output json   > "${CR_OUTPUT_FILE}"
    Copy to Clipboard Toggle word wrap
    1
    定义容量块产品的 ID。
    2
    定义您的实例平台。
    3
    定义您的实例标签。
  3. 运行以下命令,创建一个环境变量来设置容量保留 ID:

    $ CB_RESERVATION_ID=$(jq -r '.CapacityReservation.CapacityReservationId' "${CR_OUTPUT_FILE}")
    Copy to Clipboard Toggle word wrap

    等待几分钟,以便 GPU 保留可用。

  4. 运行以下命令,添加节点池以使用 GPU 保留:

    $ hcp create nodepool aws \
      --cluster-name <hosted_cluster_name> \ 
    1
    
      --name <node_pool_name> \ 
    2
    
      --node-count 1 \ 
    3
    
      --instance-type p4d.24xlarge \ 
    4
    
      --arch amd64 \ 
    5
    
      --release-image <release_image> \ 
    6
    
      --render > /tmp/np.yaml
    Copy to Clipboard Toggle word wrap
    1
    <hosted_cluster_name> 替换为托管集群的名称。
    2
    <node_pool_name> 替换为节点池的名称。
    3
    定义节点池计数,例如 1
    4
    定义实例类型,如 p4d.24xlarge
    5
    定义构架类型,例如 amd64
    6
    <release_image> 替换为您要使用的发行镜像。
  5. 使用以下示例配置在 NodePool 资源中添加 capacityReservation 设置:

    # ...
    spec:
      arch: amd64
      clusterName: cb-np-hcp
      management:
        autoRepair: false
        upgradeType: Replace
      platform:
        aws:
          instanceProfile: cb-np-hcp-dqppw-worker
          instanceType: p4d.24xlarge
          rootVolume:
            size: 120
            type: gp3
          subnet:
            id: subnet-00000
          placement:
            capacityReservation:
              id: ${CB_RESERVATION_ID}
              marketType: CapacityBlocks
        type: AWS
    # ...
    Copy to Clipboard Toggle word wrap
  6. 运行以下命令来应用节点池配置:

    $ oc apply -f /tmp/np.yaml
    Copy to Clipboard Toggle word wrap

验证

  1. 运行以下命令验证您的新节点池是否已成功创建:

    $ oc get np -n clusters
    Copy to Clipboard Toggle word wrap

    输出示例

    NAMESPACE   NAME    CLUSTER     DESIRED NODES   CURRENT  NODES   AUTOSCALING     AUTOREPAIR   VERSION                               UPDATINGVERSION   UPDATINGCONFIG   MESSAGE
    clusters    cb-np   cb-np-hcp   1               1                False           False        4.20.0-0.nightly-2025-06-05-224220    False             False
    Copy to Clipboard Toggle word wrap

  2. 运行以下命令,验证新计算节点是否在托管集群中创建:

    $ oc get nodes
    Copy to Clipboard Toggle word wrap

    输出示例

    NAME                           STATUS   ROLES    AGE    VERSION
    ip-10-0-132-74.ec2.internal    Ready    worker   17m    v1.33.4
    ip-10-0-134-183.ec2.internal   Ready    worker   4h5m   v1.33.4
    Copy to Clipboard Toggle word wrap

5.1.7.1. 配置节点池容量块后销毁托管集群

配置节点池容量块后,您可以选择销毁托管集群并卸载 HyperShift Operator。

流程

  1. 要销毁托管集群,请运行以下命令:

    $ hcp destroy cluster aws \
      --name cb-np-hcp \
      --aws-creds $HOME/.aws/credentials \
      --namespace clusters \
      --region us-east-2
    Copy to Clipboard Toggle word wrap
  2. 要卸载 HyperShift Operator,请运行以下命令:

    $ hcp install render --format=yaml | oc delete -f -
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat