×

管理AWS基础设施和IAM权限的先决条件

要配置Amazon Web Services (AWS)上OpenShift Container Platform的托管控制平面,您必须满足以下基础设施要求

  • 您在创建托管集群之前配置了托管控制平面。

  • 您创建了AWS身份和访问管理(IAM)角色和AWS安全令牌服务(STS)凭据。

AWS的基础设施要求

当您在Amazon Web Services (AWS)上使用托管控制平面时,基础设施要求适合以下类别

  • 任意AWS账户中HyperShift操作符的必需和非托管基础设施

  • 托管集群AWS账户中的必需和非托管基础设施

  • 管理AWS账户中的托管控制平面管理的基础设施

  • 托管集群AWS账户中的托管控制平面管理的基础设施

  • 托管集群AWS账户中的Kubernetes管理的基础设施

必需意味着托管控制平面需要AWS基础设施才能正常工作。非托管意味着没有操作符或控制器为您创建基础设施。

AWS账户中HyperShift操作符的非托管基础设施

任意Amazon Web Services (AWS)账户取决于托管控制平面服务的提供商。

在自管理托管控制平面中,集群服务提供商控制AWS账户。集群服务提供商是托管集群控制平面的管理员,并负责正常运行时间。在托管托管控制平面中,AWS账户属于Red Hat。

在HyperShift操作符的必需和非托管基础设施中,以下基础设施要求适用于管理集群AWS账户

  • 一个S3存储桶

    • OpenID Connect (OIDC)

  • Route 53托管区域

    • 一个用于托管集群私有和公共条目的域名

托管集群AWS账户管理账户的非托管基础设施要求

当您的基础设施在托管集群Amazon Web Services (AWS)账户中是预先需要的且非托管的时,所有访问模式的基础设施要求如下:

  • 一个VPC

  • 一个DHCP选项

  • 两个子网

    • 一个作为内部数据平面子网的私有子网

    • 一个允许从数据平面访问互联网的公共子网

  • 一个互联网网关

  • 一个弹性IP

  • 一个NAT网关

  • 一个安全组(工作节点)

  • 两个路由表(一个私有,一个公共)

  • 两个Route 53托管区域

  • 以下项目的足够配额:

    • 一个用于公共托管集群的入口服务负载均衡器

    • 一个用于私有托管集群的私有链接端点

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

管理AWS账户的基础设施要求

当您的基础设施由管理AWS账户中的托管控制平面管理时,基础设施要求会根据您的集群是公共的、私有的还是两者兼而有之而有所不同。

对于拥有公共集群的账户,基础设施要求如下:

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

    • Kubernetes创建一个安全组

    • 用于etcd(一个或三个,取决于高可用性)

    • 用于OVN-Kube

对于拥有私有集群的账户,基础设施要求如下:

  • 网络负载均衡器:一个负载均衡器私有路由器

  • 端点服务(私有链接)

对于同时拥有公共和私有集群的账户,基础设施要求如下:

  • 网络负载均衡器:一个负载均衡器公共路由器

  • 网络负载均衡器:一个负载均衡器私有路由器

  • 端点服务(私有链接)

    • 用于etcd(一个或三个,取决于高可用性)

    • 用于OVN-Kube

托管集群中AWS账户的基础设施要求

当您的基础设施由托管集群Amazon Web Services (AWS)账户中的托管控制平面管理时,基础设施要求会根据您的集群是公共的、私有的还是两者兼而有之而有所不同。

对于拥有公共集群的账户,基础设施要求如下:

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

对于拥有私有集群的账户,基础设施要求如下:

  • 每个可用区一个私有链接端点

  • 用于节点池的EC2实例

对于同时拥有公共和私有集群的账户,基础设施要求如下:

  • 每个可用区一个私有链接端点

  • 用于节点池的EC2实例

托管集群AWS账户中的Kubernetes管理的基础设施

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

  • 一个用于默认入口的网络负载均衡器

  • 一个用于注册表的S3存储桶

身份和访问管理 (IAM) 权限

在托管控制平面的上下文中,使用者负责创建Amazon资源名称(ARN)角色。使用者是一个生成权限文件的自动化过程。使用者可能是CLI或OpenShift集群管理器。托管控制平面可以启用粒度以遵守最小权限原则,这意味着每个组件都使用其自身的角色来操作或创建Amazon Web Services (AWS)对象,并且角色仅限于产品正常运行所需的功能。

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

以下角色由托管控制平面中的一些组件使用,这些组件运行在控制平面并操作数据平面:

  • 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
...

托管控制平面使用的角色显示在以下示例中:

  • 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"
                ]
            }
        ]
    }
  • 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": "\*"
            }
        ]
    }
  • 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": "\*"
            }
        ]
    }
  • 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": "\*"
            }
        ]
    }
  • 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"
            }
        ]
    }
  • 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"
            }
        ]
    }
  • 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"
            }
        ]
    }

分别创建AWS基础设施和IAM资源

默认情况下,hcp create cluster aws命令会创建具有托管集群的云基础设施并应用它。您可以分别创建云基础设施部分,以便您可以仅使用hcp create cluster aws命令来创建集群,或者在应用之前对其进行修改。

要分别创建云基础设施部分,您需要创建Amazon Web Services (AWS)基础设施,创建AWS身份和访问(IAM)资源,并创建集群。

分别创建AWS基础设施

要创建Amazon Web Services (AWS)基础设施,您需要为您的集群创建一个虚拟私有云 (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
1 <pull_secret_name>替换为您拉取密钥的名称。
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实例的名称。

创建AWS IAM资源

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

  • IAM中的OpenID Connect (OIDC) 身份提供商,这是启用STS身份验证所必需的。

  • 七个角色角色,每个与提供程序交互的组件(例如 Kubernetes 控制器管理器、集群 API 提供程序和注册表)都有一个单独的角色。

  • 实例配置文件实例配置文件,这是分配给集群所有工作节点实例的配置文件。

单独创建托管集群

您可以在 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)
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 拉取密钥的文件名。
5 --generate-ssh标志是可选的,但如果您需要 SSH 到您的工作节点,最好包含它。系统会为您生成一个 SSH 密钥,并将其存储为与托管集群相同命名空间中的密钥。
6 <role_name>替换为 Amazon 资源名称 (ARN),例如arn:aws:iam::820196288204:role/myrole。指定 Amazon 资源名称 (ARN),例如arn:aws:iam::820196288204:role/myrole。有关 ARN 角色的更多信息,请参阅“身份和访问管理 (IAM) 权限”。

您还可以将--render标志添加到命令中,并将输出重定向到一个文件中,以便在将资源应用于集群之前对其进行编辑。

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

  • 一个命名空间

  • 包含您的拉取密钥的密钥

  • 一个HostedCluster

  • 一个NodePool

  • 三个用于控制平面组件的 AWS STS 密钥

  • 如果您指定了--generate-ssh标志,则会生成一个 SSH 密钥。

将托管集群从单架构迁移到多架构

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

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

先决条件
  • 您已在 Red Hat Advanced Cluster Management (RHACM) 上为 AWS 安装了带有 Kubernetes 运算符的多集群引擎的 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> -o jsonpath='{.spec.release.image}' (1)
    1 <hosted_cluster_name>替换为您的托管集群名称。
    示例输出:
    quay.io/openshift-release-dev/ocp-release:<4.y.z>-x86_64 (1)
    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"]}')
    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)
    3. 通过运行以下命令设置多架构发行版镜像名称的IMAGE环境变量:

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

      $ oc image info $IMAGE
      示例输出:
      OS            DIGEST
      linux/amd64   sha256:b4c7a91802c09a5a748fe19ddd99a8ffab52d8a31db3a081a956a87f22a22ff8
      linux/ppc64le sha256:66fda2ff6bd7704f1ba72be8bfe3e399c323de92262f594f8e482d110ec37388
      linux/s390x   sha256:b1c1072dc639aaa2b50ec99b530012e3ceac19ddc28adcbcdc9643f2dfd14f34
      linux/arm64   sha256:7b046404572ac96202d82b6cb029b421dddd40e88c73bbf35f602ffc13017f21
  3. 将托管集群从单架构迁移到多架构

    1. 在您的托管集群上将multiArch标志设置为true,以便托管集群可以创建 64 位 AMD 和 64 位 ARM 节点池。运行以下命令:

      $ oc patch -n clusters hostedclusters/<hosted_cluster_name> -p '{"spec":{"platform":{"aws":{"multiArch":true}}}}' --type=merge
    2. 通过运行以下命令确认您的托管集群上的multiArch标志是否设置为true

      $ oc get hostedcluster/<hosted_cluster_name> -o jsonpath='{.spec.platform.aws.multiArch}'
    3. 设置托管集群的多架构 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"}}}' --type=merge (1)
      1 <4.y.z>替换为您使用的受支持的 OpenShift Container Platform 版本。
    4. 通过运行以下命令确认多架构镜像是否已设置在您的托管集群中:

      $ oc get hostedcluster/<hosted_cluster_name> -o jsonpath='{.spec.release.image}'
  4. 通过运行以下命令检查HostedControlPlane资源的状态是否为Progressing

    $ oc get hostedcontrolplane -n <hosted_control_plane_namespace> -oyaml
    示例输出:
    #...
      - lastTransitionTime: "2024-07-28T13:07:18Z"
        message: HostedCluster is deploying, upgrading, or reconfiguring
        observedGeneration: 5
        reason: Progressing
        status: "True"
        type: Progressing
    #...
  5. 通过运行以下命令检查HostedCluster资源的状态是否为Progressing

    $ oc get hostedcluster <hosted_cluster_name> -n <hosted_cluster_namespace> -oyaml
验证
  • 通过运行以下命令验证节点池是否正在使用HostedControlPlane资源中的多架构发行版镜像:

    $ oc get hostedcontrolplane -n clusters-example -oyaml
    示例输出:
    #...
    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>
    1 <4.y.z>替换为您使用的受支持的 OpenShift Container Platform 版本。

    多架构 OpenShift Container Platform 发行版镜像已更新到您的HostedClusterHostedControlPlane资源和托管控制平面 Pod 中。但是,您的现有节点池不会自动迁移到多架构镜像,因为发行版镜像迁移在托管集群和节点池之间是解耦的。您必须在新的多架构托管集群上创建新的节点池。

后续步骤
  • 在多架构托管集群上创建节点池

在多架构托管集群上创建节点池

将托管集群从单架构迁移到多架构后,请在基于 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
    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
    1 <hosted_cluster_name>替换为您的托管集群名称。
    2 <nodepool_name>替换为您的节点池名称。
    3 <node_count>替换为您的节点计数的整数,例如2
验证
  • 通过输入以下命令验证节点池是否正在使用多架构发行版镜像:

    $ oc get nodepool/<nodepool_name> -oyaml
    64 位 AMD 节点池的示例输出:
    #...
    spec:
      arch: amd64
    #...
      release:
        image: quay.io/openshift-release-dev/ocp-release:<4.x.y>-multi (1)
    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