11.11.2.2.2. 개별적으로 AWS 리소스 생성
ccoctl 툴을 사용하여 AWS 리소스를 개별적으로 생성할 수 있습니다. 이 옵션은 서로 다른 사용자 또는 부서 간에 이러한 리소스를 생성하는 책임을 공유하는 조직에 유용할 수 있습니다.
그렇지 않으면 ccoctl aws create-all 명령을 사용하여 AWS 리소스를 자동으로 생성할 수 있습니다. 자세한 내용은 "단일 명령으로 AWS 리소스 생성"을 참조하십시오.
기본적으로 ccoctl은 명령이 실행되는 디렉터리에 오브젝트를 생성합니다. 다른 디렉터리에 오브젝트를 생성하려면 --output-dir 플래그를 사용합니다. 이 절차에서는 <path_to_ccoctl_output_dir>을 사용하여 이 디렉터리를 나타냅니다.
일부 ccoctl 명령은 AWS API를 호출하여 AWS 리소스를 생성하거나 수정합니다. --dry-run 플래그를 사용하여 API 호출을 방지할 수 있습니다. 이 플래그를 사용하면 로컬 파일 시스템에 JSON 파일이 생성됩니다. JSON 파일을 검토 및 수정한 다음 --cli-input-json 매개변수를 사용하여 AWS CLI 툴로 적용할 수 있습니다.
사전 요구 사항
-
ccoctl바이너리를 추출하고 준비합니다.
프로세스
다음 명령을 실행하여 클러스터의 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.private및serviceaccount-signer.public은 생성된 키 파일입니다.또한 이 명령은
/<path_to_ccoctl_output_dir>/tls/bound-service-account-signing-key.key에 설치하는 동안 클러스터가 필요한 개인 키를 생성합니다.다음 명령을 실행하여 AWS에서 OpenID Connect ID 공급자 및 S3 버킷을 생성합니다.
$ ccoctl aws create-identity-provider \ --name=<name> \1 --region=<aws_region> \2 --public-key-file=<path_to_ccoctl_output_dir>/serviceaccount-signer.public3 - 1
<name>은 추적을 위해 생성된 클라우드 리소스에 태그를 지정하는 데 사용되는 이름입니다.- 2
<aws-region>은 클라우드 리소스를 생성할 AWS 리전입니다.- 3
<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여기서
openid-configuration은 검색 문서이고keys.json은 JSON 웹 키 세트 파일입니다.이 명령은
/<path_to_ccoctl_output_dir>/manifests/cluster-authentication-02-config.yaml에 YAML 구성 파일도 생성합니다. 이 파일은 AWS IAM ID 공급자가 토큰을 신뢰하도록 클러스터가 생성하는 서비스 계정 토큰의 발급자 URL 필드를 설정합니다.
클러스터의 각 구성 요소에 대한 IAM 역할을 생성합니다.
다음 명령을 실행하여 설치 파일의 릴리스 이미지로
$RELEASE_IMAGE변수를 설정합니다.$ RELEASE_IMAGE=$(./openshift-install version | awk '/release image/ {print $3}')OpenShift Container Platform 릴리스 이미지에서
CredentialsRequest오브젝트 목록을 추출합니다.$ oc adm release extract \ --from=$RELEASE_IMAGE \ --credentials-requests \ --included \1 --install-config=<path_to_directory_with_installation_configuration>/install-config.yaml \2 --to=<path_to_directory_for_credentials_requests>3 ccoctl툴을 사용하여 다음 명령을 실행하여 모든CredentialsRequest오브젝트를 처리합니다.$ ccoctl aws create-iam-roles \ --name=<name> \ --region=<aws_region> \ --credentials-requests-dir=<path_to_credentials_requests_directory> \ --identity-provider-arn=arn:aws:iam::<aws_account_id>:oidc-provider/<name>-oidc.s3.<aws_region>.amazonaws.com참고GovCloud와 같은 대체 IAM API 끝점을 사용하는 AWS 환경의 경우
--region매개변수를 사용하여 리전을 지정해야 합니다.클러스터에서
TechPreviewNoUpgrade기능 세트에서 활성화한 기술 프리뷰 기능을 사용하는 경우--enable-tech-preview매개변수를 포함해야 합니다.각
CredentialsRequest오브젝트에 대해ccoctl은 지정된 OIDC ID 공급자와 연결된 신뢰 정책과 OpenShift Container Platform 릴리스 이미지의 각CredentialsRequest오브젝트에 정의된 권한 정책을 사용하여 IAM 역할을 생성합니다.
검증
OpenShift Container Platform 보안이 생성되었는지 확인하려면
<path_to_ccoctl_output_dir>/manifests디렉터리에 파일을 나열합니다.$ ls <path_to_ccoctl_output_dir>/manifests출력 예
cluster-authentication-02-config.yaml openshift-cloud-credential-operator-cloud-credential-operator-iam-ro-creds-credentials.yaml openshift-cloud-network-config-controller-cloud-credentials-credentials.yaml openshift-cluster-api-capa-manager-bootstrap-credentials-credentials.yaml openshift-cluster-csi-drivers-ebs-cloud-credentials-credentials.yaml openshift-image-registry-installer-cloud-credentials-credentials.yaml openshift-ingress-operator-cloud-credentials-credentials.yaml openshift-machine-api-aws-cloud-credentials-credentials.yamlAWS를 쿼리하여 IAM 역할이 생성되었는지 확인할 수 있습니다. 자세한 내용은 IAM 역할 나열에 대한 AWS 설명서를 참조하십시오.