|
| 1 | +:_mod-docs-content-type: PROCEDURE |
| 2 | +[id="configuring-quay-sts-cco-s3-storage"] |
| 3 | += Configuring AWS S3 storage with STS and the Cloud Credential Operator |
| 4 | + |
| 5 | +[role="_abstract"] |
| 6 | +On STS-enabled {ocp} clusters on AWS, including {product-rosa} and Red Hat OpenShift Dedicated, you can configure {productname-ocp} to use your own S3 bucket without static AWS access keys. Set the IAM role ARN on the {productname} Operator subscription, set `objectstorage` to `unmanaged`, and configure `S3Storage` in the config bundle without `s3_access_key` or `s3_secret_key`. The Operator creates a Cloud Credential Operator (CCO) `CredentialRequest` and mounts short-lived credentials into the `quay-app` pods. |
| 7 | + |
| 8 | +[NOTE] |
| 9 | +==== |
| 10 | +This procedure requires {ocp} 4.14 or later on AWS with CCO in STS-compatible mode. It applies only when `objectstorage` is `unmanaged`. If `ROLEARN` is not set on the Operator subscription, existing installations are unchanged. |
| 11 | +==== |
| 12 | + |
| 13 | +.Prerequisites |
| 14 | + |
| 15 | +* An STS-enabled AWS cluster ({product-rosa}, OpenShift Dedicated, or self-managed {ocp} on AWS). |
| 16 | +* An IAM role with an OIDC trust policy for the `quay-app` service account and permissions to access your S3 bucket. |
| 17 | +* A `QuayRegistry` with `objectstorage` set to `unmanaged`. |
| 18 | +* Cluster administrator access to install the Operator and edit the `configBundleSecret`. |
| 19 | +
|
| 20 | +.Procedure |
| 21 | + |
| 22 | +. Get the cluster `serviceAccountIssuer` value: |
| 23 | ++ |
| 24 | +[source,terminal] |
| 25 | +---- |
| 26 | +$ oc get authentication.config.openshift.io cluster -o jsonpath='{.spec.serviceAccountIssuer}' | sed -e 's|^https://||' |
| 27 | +---- |
| 28 | ++ |
| 29 | +.Example output |
| 30 | +[source,terminal] |
| 31 | +---- |
| 32 | +oidc.op1.openshiftapps.com/1234567890 |
| 33 | +---- |
| 34 | + |
| 35 | +. Create or update the IAM role trust policy so the `quay-app` service account can assume the role. Replace the account ID, OIDC provider path, namespace, and registry name with your values: |
| 36 | ++ |
| 37 | +[source,json] |
| 38 | +---- |
| 39 | +{ |
| 40 | + "Version": "2012-10-17", |
| 41 | + "Statement": [ |
| 42 | + { |
| 43 | + "Effect": "Allow", |
| 44 | + "Principal": { |
| 45 | + "Federated": "arn:aws:iam::<aws_account_id>:oidc-provider/<serviceAccountIssuer>" |
| 46 | + }, |
| 47 | + "Action": "sts:AssumeRoleWithWebIdentity", |
| 48 | + "Condition": { |
| 49 | + "StringEquals": { |
| 50 | + "<serviceAccountIssuer>:sub": "system:serviceaccount:<quay_namespace>:<registry_name>-quay-app" |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | + ] |
| 55 | +} |
| 56 | +---- |
| 57 | + |
| 58 | +. Attach an IAM policy that grants the S3 permissions required by {productname}, including `s3:GetObject`, `s3:PutObject`, `s3:DeleteObject`, `s3:ListBucket`, `s3:GetBucketLocation`, `s3:ListBucketMultipartUploads`, `s3:AbortMultipartUpload`, and `s3:ListMultipartUploadParts`. |
| 59 | + |
| 60 | +. Install or upgrade the {productname} Operator and set the **Role ARN** field to your IAM role ARN. The Operator exposes this field when AWS token authentication is enabled on the cluster. Alternatively, set the `ROLEARN` environment variable on the Operator subscription. |
| 61 | + |
| 62 | +. Configure your `QuayRegistry` with unmanaged object storage: |
| 63 | ++ |
| 64 | +[source,yaml] |
| 65 | +---- |
| 66 | +apiVersion: quay.redhat.com/v1 |
| 67 | +kind: QuayRegistry |
| 68 | +metadata: |
| 69 | + name: <registry_name> |
| 70 | + namespace: <quay_namespace> |
| 71 | +spec: |
| 72 | + components: |
| 73 | + - kind: objectstorage |
| 74 | + managed: false |
| 75 | + configBundleSecret: <config_bundle_secret_name> |
| 76 | +---- |
| 77 | + |
| 78 | +. Update the `config.yaml` file in your `configBundleSecret` to use `S3Storage` without static credentials: |
| 79 | ++ |
| 80 | +[source,yaml] |
| 81 | +---- |
| 82 | +# ... |
| 83 | +DISTRIBUTED_STORAGE_CONFIG: |
| 84 | + default: |
| 85 | + - S3Storage |
| 86 | + - host: s3.<region>.amazonaws.com |
| 87 | + s3_bucket: <s3_bucket_name> |
| 88 | + s3_region: <region> |
| 89 | + storage_path: /datastorage/registry |
| 90 | +DISTRIBUTED_STORAGE_DEFAULT_LOCATIONS: [] |
| 91 | +DISTRIBUTED_STORAGE_PREFERENCE: |
| 92 | + - default |
| 93 | +# ... |
| 94 | +---- |
| 95 | ++ |
| 96 | +[IMPORTANT] |
| 97 | +==== |
| 98 | +Do not set `s3_access_key` or `s3_secret_key` in the config bundle when using the Operator STS path. If static AWS keys are present while `ROLEARN` is set, the Operator sets `RolloutBlocked` with reason `ConflictingCredentials`. |
| 99 | +==== |
| 100 | + |
| 101 | +. Wait for the Operator to create and provision the CCO `CredentialRequest`. Verify the request and secret: |
| 102 | ++ |
| 103 | +[source,terminal] |
| 104 | +---- |
| 105 | +$ oc get credentialsrequest -n <quay_namespace> |
| 106 | +$ oc get secret <registry_name>-quay-app-aws -n <quay_namespace> |
| 107 | +---- |
| 108 | + |
| 109 | +. Verify the `QuayRegistry` is available and not blocked: |
| 110 | ++ |
| 111 | +[source,terminal] |
| 112 | +---- |
| 113 | +$ oc get quayregistry <registry_name> -n <quay_namespace> -o jsonpath='{.status.conditions[?(@.type=="Available")].status}{"\n"}' |
| 114 | +---- |
| 115 | + |
| 116 | +. Push and pull an image to confirm S3 access through STS credentials. |
| 117 | + |
| 118 | +[id="sts-cco-troubleshooting"] |
| 119 | +== Troubleshooting |
| 120 | + |
| 121 | +If rollout is blocked, check `QuayRegistry` conditions: |
| 122 | + |
| 123 | +* `CredentialRequestNotProvisioned` — CCO has not yet provisioned credentials, or the IAM role or trust policy is misconfigured. Verify the `CredentialRequest` status and IAM role configuration. |
| 124 | +* `ConflictingCredentials` — Remove `s3_access_key` and `s3_secret_key` from `DISTRIBUTED_STORAGE_CONFIG` in the config bundle. |
| 125 | + |
| 126 | +[role="_additional-resources"] |
| 127 | +.Additional resources |
| 128 | + |
| 129 | +* link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/configure_red_hat_quay/index#config-fields-storage-aws-sts-cco[AWS S3 storage with Operator STS and CCO] |
| 130 | +* link:https://docs.redhat.com/en/documentation/red_hat_openshift_service_on_aws/4/html/authentication_and_authorization/assuming-an-aws-iam-role-for-a-service-account[Assuming an AWS IAM role for a service account on {product-rosa}] |
0 commit comments