18.5. Amazon Web Services Secure Token Service에서 수동 모드 사용

STS를 사용하는 수동 모드는 AWS(Amazon Web Services)에서 지원됩니다.

참고

이 인증 정보 전략은 새 OpenShift Container Platform 클러스터에 대해서만 지원되며 설치 중에 구성해야 합니다. 이 기능을 사용하기 위해 다른 인증 정보 전략을 사용하는 기존 클러스터를 재구성할 수 없습니다.

18.5.1. AWS Secure Token Service를 사용한 수동 모드 정보

STS를 사용하는 수동 모드에서 개별 OpenShift Container Platform 클러스터 구성 요소는 AWS STS(Secure Token Service)를 사용하여 단기적으로 제한된 권한 보안 인증 정보를 제공하는 구성 요소 IAM 역할을 할당합니다. 이러한 인증 정보는 AWS API 호출을 수행하는 각 구성 요소에 특정적인 IAM 역할과 연결됩니다.

새로운 인증 정보 및 새로고침된 인증 정보에 대한 요청은 AWS IAM 역할과 함께 적절하게 구성된 AWS IAM OIDC(OpenID Connect) ID 공급자를 사용하여 자동화됩니다. OpenShift Container Platform은 AWS IAM에서 신뢰하는 서비스 계정 토큰에 서명하고 Pod에 프로젝션하고 인증에 사용할 수 있습니다. 토큰은 1시간 후에 새로 고쳐집니다.

그림 18.1. STS 인증 흐름

STS를 사용하여 수동 모드를 사용하면 개별 OpenShift Container Platform 구성 요소에 제공되는 AWS 인증 정보의 내용이 변경됩니다.

수명이 긴 인증 정보를 사용하는 AWS 시크릿 형식

apiVersion: v1
kind: Secret
metadata:
  namespace: <target-namespace> 1
  name: <target-secret-name> 2
data:
  aws_access_key_id: <base64-encoded-access-key-id>
  aws_secret_access_key: <base64-encoded-secret-access-key>

1
구성 요소의 네임스페이스입니다.
2
구성 요소 시크릿의 이름입니다.

STS를 사용하는 AWS 시크릿 형식

apiVersion: v1
kind: Secret
metadata:
  namespace: <target-namespace> 1
  name: <target-secret-name> 2
stringData:
  credentials: |-
    [default]
    role_name: <operator-role-name> 3
    web_identity_token_file: <path-to-token> 4

1
구성 요소의 네임스페이스입니다.
2
구성 요소 시크릿의 이름입니다.
3
구성 요소의 IAM 역할입니다.
4
Pod 내의 서비스 계정 토큰 경로입니다. 관례상 이는 OpenShift Container Platform 구성 요소의 /var/run/secrets/openshift/serviceaccount/token입니다.

18.5.2. STS를 사용하여 수동 모드에 구성된 OpenShift Container Platform 클러스터 설치

STS를 사용하여 수동 모드에서 CCO(Cloud Credential Operator)를 사용하도록 구성된 클러스터를 설치하려면 다음을 수행합니다.

참고

STS를 사용할 때 클러스터가 수동 모드에서 작동하므로 필요한 권한으로 구성 요소에 대한 새 인증 정보를 생성할 수 없습니다. OpenShift Container Platform의 다른 마이너 버전으로 업그레이드할 때 종종 새로운 AWS 권한 요구 사항이 있습니다. STS를 사용하는 클러스터를 업그레이드하기 전에 클러스터 관리자는 AWS 권한이 기존 구성 요소에 충분하고 새 구성 요소에서 사용할 수 있는지 수동으로 확인해야 합니다.

18.5.2.1. Cloud Credential Operator 유틸리티 구성

STS를 사용하여 CCO(Cloud Credential Operator)가 수동 모드에서 작동하는 경우 클러스터 외부에서 클라우드 인증 정보를 생성하고 관리하려면 CCO 유틸리티(ccoctl) 바이너리를 추출하고 준비합니다.

참고

ccoctl은 Linux 환경에서 실행해야 하는 Linux 바이너리입니다.

절차

  1. OpenShift Container Platform 릴리스 이미지를 가져옵니다.

    $ RELEASE_IMAGE=$(./openshift-install version | awk '/release image/ {print $3}')
  2. OpenShift Container Platform 릴리스 이미지에서 CCO 컨테이너 이미지를 가져옵니다.

    $ CCO_IMAGE=$(oc adm release info --image-for='cloud-credential-operator' $RELEASE_IMAGE)
    참고

    $RELEASE_IMAGE 의 아키텍처가 ccoctl 툴을 사용할 환경의 아키텍처와 일치하는지 확인합니다.

  3. OpenShift Container Platform 릴리스 이미지 내의 CCO 컨테이너 이미지에서 ccoctl 바이너리를 추출합니다.

    $ oc image extract $CCO_IMAGE --file="/usr/bin/ccoctl" -a ~/.pull-secret
  4. ccoctl을 실행 가능하게 하려면 권한을 변경합니다.

    $ chmod 775 ccoctl

검증

  • ccoctl을 사용할 준비가 되었는지 확인하려면 도움말 파일을 표시합니다.

    $ ccoctl aws --help

    ccoctl aws --help의 출력 :

    Creating/updating/deleting cloud credentials objects for AWS cloud
    
    
    Usage:
      ccoctl aws [command]
    
    
    Available Commands:
      create-all               Create all the required credentials objects
      create-iam-roles         Create IAM roles
      create-identity-provider Create IAM identity provider
      create-key-pair          Create a key pair
      delete                   Delete credentials objects
    
    Flags:
      -h, --help   help for aws
    
    Use "ccoctl aws [command] --help" for more information about a command.

18.5.2.2. Cloud Credential Operator 유틸리티를 사용하여 AWS 리소스 생성

CCO 유틸리티(ccoctl)를 사용하여 필요한 AWS 리소스를 개별적으로 생성하거나 단일 명령으로 생성할 수 있습니다.

18.5.2.2.1. 개별적으로 AWS 리소스 생성

AWS 리소스를 수정하기 전에 ccoctl 툴에서 생성하는 JSON 파일을 검토해야 하거나 ccoctl 툴에서 AWS 리소스를 생성하는 프로세스에서 조직의 요구 사항을 자동으로 충족하지 않는 경우 AWS 리소스를 개별적으로 생성할 수 있습니다. 예를 들어 이 옵션은 다양한 사용자 또는 부서 간에 이러한 리소스를 만드는 책임을 공유하는 조직에 유용할 수 있습니다.

그렇지 않으면 ccoctl aws create-all 명령을 사용하여 AWS 리소스를 자동으로 생성할 수 있습니다.

참고

기본적으로 ccoctl은 명령이 실행되는 디렉터리에 오브젝트를 생성합니다. 다른 디렉터리에 오브젝트를 생성하려면 --output-dir 플래그를 사용합니다. 이 절차에서는 & lt;path_to_ccoctl_output_dir >을 사용하여 이 디렉터리를 참조합니다.

일부 ccoctl 명령은 AWS API를 호출하여 AWS 리소스를 생성하거나 수정합니다. --dry-run 플래그를 사용하여 API 호출을 방지할 수 있습니다. 이 플래그를 사용하면 로컬 파일 시스템에 JSON 파일이 생성됩니다. JSON 파일을 검토 및 수정한 다음 --cli-input-json 매개변수를 사용하여 AWS CLI 툴로 적용할 수 있습니다.

사전 요구 사항

  • ccoctl 바이너리를 추출하고 준비합니다.

절차

  1. 클러스터의 OpenID Connect 공급자를 설정하는 데 사용되는 공개 및 개인 RSA 키 파일을 생성합니다.

    $ ccoctl aws create-key-pair

    출력 예:

    2021/04/13 11:01:02 Generating RSA keypair
    2021/04/13 11:01:03 Writing private key to /<path_to_ccoctl_output_dir>/serviceaccount-signer.private
    2021/04/13 11:01:03 Writing public key to /<path_to_ccoctl_output_dir>/serviceaccount-signer.public
    2021/04/13 11:01:03 Copying signing key for use by installer

    여기서 serviceaccount-signer.privateserviceaccount-signer.public은 생성된 키 파일입니다.

    또한 이 명령은 /< path_to_ccoctl_output_dir>/tls/bound-service-account-signing-key.key 에 설치하는 동안 클러스터가 필요한 개인 키를 생성합니다.

  2. AWS에서 OpenID Connect ID 공급자 및 S3 버킷을 생성합니다.

    $ ccoctl aws create-identity-provider \
    --name=<name> \
    --region=<aws_region> \
    --public-key-file=<path_to_ccoctl_output_dir>/serviceaccount-signer.public

    다음과 같습니다.

    • <name>은 추적을 위해 생성된 클라우드 리소스에 태그를 지정하는 데 사용되는 이름입니다.
    • <AWS-region >은 클라우드 리소스가 생성될 AWS 리전입니다.
    • <path_to_ccoctl_output_dir >은 ccoctl aws create-key-pair 명령이 생성된 공개 키 파일의 경로입니다.

    출력 예:

    2021/04/13 11:16:09 Bucket <name>-oidc created
    2021/04/13 11:16:10 OpenID Connect discovery document in the S3 bucket <name>-oidc at .well-known/openid-configuration updated
    2021/04/13 11:16:10 Reading public key
    2021/04/13 11:16:10 JSON web key set (JWKS) in the S3 bucket <name>-oidc at keys.json updated
    2021/04/13 11:16:18 Identity Provider created with ARN: arn:aws:iam::<aws_account_id>:oidc-provider/<name>-oidc.s3.<aws_region>.amazonaws.com

    여기서 02-openid-configuration은 검색 문서이고 03-keys.json은 JSON 웹 키 집합 파일입니다.

    또한 이 명령은 /<path_to_ccoctl_output_dir>/manifests/cluster-authentication-02-config.yaml 에 YAML 구성 파일을 생성합니다. 이 파일은 AWS IAM ID 공급자가 토큰을 신뢰하도록 클러스터가 생성하는 서비스 계정 토큰의 발급자 URL 필드를 설정합니다.

  3. 클러스터의 각 구성 요소에 대한 IAM 역할을 생성합니다.

    1. OpenShift Container Platform 릴리스 이미지에서 CredentialsRequest 오브젝트 목록을 추출합니다.

      $ oc adm release extract \
      --credentials-requests \
      --cloud=aws \
      --to=<path_to_directory_with_list_of_credentials_requests>/credrequests 1
      --from=quay.io/<path_to>/ocp-release:<version>
      1
      credrequestsCredentialsRequest 오브젝트 목록이 저장되는 디렉터리입니다. 이 명령은 디렉터리가 없는 경우 해당 디렉터리를 생성합니다.
    2. ccoctl 툴을 사용하여 redrequests 디렉터리의 모든 CredentialsRequest 오브젝트를 처리합니다.

      $ ccoctl aws create-iam-roles \
      --name=<name> \
      --region=<aws_region> \
      --credentials-requests-dir=<path_to_directory_with_list_of_credentials_requests>/credrequests \
      --identity-provider-arn=arn:aws:iam::<aws_account_id>:oidc-provider/<name>-oidc.s3.<aws_region>.amazonaws.com
      참고

      GovCloud와 같은 대체 IAM API 끝점을 사용하는 AWS 환경의 경우 --region 매개변수를 사용하여 리전을 지정해야 합니다.

      CredentialsRequest 오브젝트에 대해 ccoctl 은 지정된 OIDC ID 공급자와 연결된 신뢰 정책과 OpenShift Container Platform 릴리스 이미지의 각 CredentialsRequest 오브젝트에 정의된 권한 정책을 사용하여 IAM 역할을 생성합니다.

검증

  • OpenShift Container Platform 보안이 생성되었는지 확인하려면 < path_to_ccoctl_output_dir>/manifests 디렉터리의 파일을 나열합니다.

    $ ll <path_to_ccoctl_output_dir>/manifests

    출력 예:

    total 24
    -rw-------. 1 <user> <user> 161 Apr 13 11:42 cluster-authentication-02-config.yaml
    -rw-------. 1 <user> <user> 379 Apr 13 11:59 openshift-cloud-credential-operator-cloud-credential-operator-iam-ro-creds-credentials.yaml
    -rw-------. 1 <user> <user> 353 Apr 13 11:59 openshift-cluster-csi-drivers-ebs-cloud-credentials-credentials.yaml
    -rw-------. 1 <user> <user> 355 Apr 13 11:59 openshift-image-registry-installer-cloud-credentials-credentials.yaml
    -rw-------. 1 <user> <user> 339 Apr 13 11:59 openshift-ingress-operator-cloud-credentials-credentials.yaml
    -rw-------. 1 <user> <user> 337 Apr 13 11:59 openshift-machine-api-aws-cloud-credentials-credentials.yaml

AWS를 쿼리하여 IAM 역할이 생성되었는지 확인할 수 있습니다. 자세한 내용은 IAM 역할 나열에 대한 AWS 설명서를 참조하십시오.

18.5.2.2.2. 단일 명령으로 AWS 리소스 생성

AWS 리소스를 수정하기 전에 ccoctl 툴에서 생성하는 JSON 파일을 검토할 필요가 없으며, ccoctl 툴에서 AWS 리소스를 생성하는 데 사용하는 프로세스가 조직의 요구 사항을 자동으로 충족하는 경우 ccoctl aws create-all 명령을 사용하여 AWS 리소스 생성을 자동화할 수 있습니다.

그렇지 않으면 AWS 리소스를 개별적으로 생성할 수 있습니다.

참고

기본적으로 ccoctl은 명령이 실행되는 디렉터리에 오브젝트를 생성합니다. 다른 디렉터리에 오브젝트를 생성하려면 --output-dir 플래그를 사용합니다. 이 절차에서는 & lt;path_to_ccoctl_output_dir >을 사용하여 이 디렉터리를 참조합니다.

사전 요구 사항

  • ccoctl 바이너리를 추출하고 준비합니다.

절차

  1. OpenShift Container Platform 릴리스 이미지에서 CredentialsRequest 오브젝트 목록을 추출합니다.

    $ oc adm release extract \
    --credentials-requests \
    --cloud=aws \
    --to=<path_to_directory_with_list_of_credentials_requests>/credrequests \ 1
    --from=quay.io/<path_to>/ocp-release:<version>
    1
    credrequestsCredentialsRequest 오브젝트 목록이 저장되는 디렉터리입니다. 이 명령은 디렉터리가 없는 경우 해당 디렉터리를 생성합니다.
  2. ccoctl 툴을 사용하여 redrequests 디렉터리의 모든 CredentialsRequest 오브젝트를 처리합니다.

    $ ccoctl aws create-all \
    --name=<name> \
    --region=<aws_region> \
    --credentials-requests-dir=<path_to_directory_with_list_of_credentials_requests>/credrequests

검증

  • OpenShift Container Platform 보안이 생성되었는지 확인하려면 < path_to_ccoctl_output_dir>/manifests 디렉터리의 파일을 나열합니다.

    $ ll <path_to_ccoctl_output_dir>/manifests

    출력 예:

    total 24
    -rw-------. 1 <user> <user> 161 Apr 13 11:42 cluster-authentication-02-config.yaml
    -rw-------. 1 <user> <user> 379 Apr 13 11:59 openshift-cloud-credential-operator-cloud-credential-operator-iam-ro-creds-credentials.yaml
    -rw-------. 1 <user> <user> 353 Apr 13 11:59 openshift-cluster-csi-drivers-ebs-cloud-credentials-credentials.yaml
    -rw-------. 1 <user> <user> 355 Apr 13 11:59 openshift-image-registry-installer-cloud-credentials-credentials.yaml
    -rw-------. 1 <user> <user> 339 Apr 13 11:59 openshift-ingress-operator-cloud-credentials-credentials.yaml
    -rw-------. 1 <user> <user> 337 Apr 13 11:59 openshift-machine-api-aws-cloud-credentials-credentials.yaml

AWS를 쿼리하여 IAM 역할이 생성되었는지 확인할 수 있습니다. 자세한 내용은 IAM 역할 나열에 대한 AWS 설명서를 참조하십시오.

18.5.2.3. 설치 프로그램 실행

사전 요구 사항

  • OpenShift Container Platform 릴리스 이미지를 가져옵니다.

절차

  1. 설치 프로그램이 포함된 디렉터리로 변경하고 install-config.yaml 파일을 생성합니다.

    $ openshift-install create install-config --dir <installation_directory>

    여기서 <installation_directory> 는 설치 프로그램이 파일을 생성하는 디렉터리입니다.

  2. install-config.yaml 구성 파일을 편집하여 credentialsMode 매개 변수가 Manual로 설정되도록 합니다.

    install-config.yaml 설정 파일 예

    apiVersion: v1
    baseDomain: cluster1.example.com
    credentialsMode: Manual 1
    compute:
    - architecture: amd64
      hyperthreading: Enabled
    ...

    1
    이 행은 credentialsMode 매개변수를 Manual로 설정하기 위해 추가됩니다.
  3. 필요한 OpenShift Container Platform 설치 매니페스트를 생성합니다.

    $ openshift-install create manifests
  4. ccoctl이 생성한 매니페스트를 설치 프로그램이 생성한 매니페스트 디렉터리에 복사합니다.

    $ cp /<path_to_ccoctl_output_dir>/manifests/* ./manifests/
  5. ccoctltls 디렉터리에 생성된 개인 키를 설치 디렉터리에 복사합니다.

    $ cp -a /<path_to_ccoctl_output_dir>/tls .
  6. OpenShift Container Platform 설치 프로그램을 실행합니다.

    $ ./openshift-install create cluster

18.5.2.4. 설치 확인

  1. OpenShift Container Platform 클러스터에 연결합니다.
  2. 클러스터에 root 인증 정보가 없는지 확인합니다.

    $ oc get secrets -n kube-system aws-creds

    출력은 다음과 유사해야 합니다.

    Error from server (NotFound): secrets "aws-creds" not found
  3. 구성 요소가 CCO에서 생성한 인증 정보를 사용하는 대신 시크릿 매니페스트에 지정된 IAM 역할을 가정하는지 확인합니다.

    이미지 레지스트리 Operator가 있는 명령 예

    $ oc get secrets -n openshift-image-registry installer-cloud-credentials -o json | jq -r .data.credentials | base64 --decode

    출력에 구성 요소에서 사용하는 역할 및 웹 ID 토큰이 표시되고 다음과 유사해야 합니다.

    이미지 레지스트리 Operator가 있는 출력 예

    [default]
    role_arn = arn:aws:iam::123456789:role/openshift-image-registry-installer-cloud-credentials
    web_identity_token_file = /var/run/secrets/openshift/serviceaccount/token