Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 11. Tutorial: Using AWS Controllers for Kubernetes on Red Hat OpenShift Service on AWS
AWS Controllers for Kubernetes (ACK) lets you define and use AWS service resources directly from Red Hat OpenShift Service on AWS. With ACK, you can take advantage of AWS-managed services for your applications without needing to define resources outside of the cluster or run services that provide supporting capabilities such as databases or message queues within the cluster.
You can install various ACK Operators directly from OperatorHub. This makes it easy to get started and use the Operators with your applications. This controller is a component of the AWS Controller for Kubernetes project, which is currently in developer preview.
Use this tutorial to deploy the ACK S3 Operator. You can also adapt it for any other ACK Operator in the OperatorHub of your cluster.
11.1. Prerequisites Link kopierenLink in die Zwischenablage kopiert!
- A Red Hat OpenShift Service on AWS cluster
-
A user account with
cluster-admin
privileges -
The OpenShift CLI (
oc
) -
The Amazon Web Services (AWS) CLI (
aws
)
11.2. Setting up your environment Link kopierenLink in die Zwischenablage kopiert!
Configure the following environment variables, changing the cluster name to suit your cluster:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure all fields output correctly before moving to the next section:
echo "Cluster: ${ROSA_CLUSTER_NAME}, Region: ${REGION}, OIDC Endpoint: ${OIDC_ENDPOINT}, AWS Account ID: ${AWS_ACCOUNT_ID}"
$ echo "Cluster: ${ROSA_CLUSTER_NAME}, Region: ${REGION}, OIDC Endpoint: ${OIDC_ENDPOINT}, AWS Account ID: ${AWS_ACCOUNT_ID}"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
11.3. Preparing your AWS Account Link kopierenLink in die Zwischenablage kopiert!
Create an AWS Identity Access Management (IAM) trust policy for the ACK Operator:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an AWS IAM role for the ACK Operator to assume with the
AmazonS3FullAccess
policy attached:NoteYou can find the recommended policy in each project’s GitHub repository, for example https://github.com/aws-controllers-k8s/s3-controller/blob/main/config/iam/recommended-policy-arn.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
11.4. Installing the ACK S3 Controller Link kopierenLink in die Zwischenablage kopiert!
Create a project to install the ACK S3 Operator into:
oc new-project ack-system
$ oc new-project ack-system
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a file with the ACK S3 Operator configuration:
NoteACK_WATCH_NAMESPACE
is purposefully left blank so the controller can properly watch all namespaces in the cluster.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use the file from the previous step to create a ConfigMap:
oc -n ack-system create configmap \ --from-env-file=${SCRATCH}/config.txt ack-${ACK_SERVICE}-user-config
$ oc -n ack-system create configmap \ --from-env-file=${SCRATCH}/config.txt ack-${ACK_SERVICE}-user-config
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Install the ACK S3 Operator from OperatorHub:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Annotate the ACK S3 Operator service account with the AWS IAM role to assume and restart the deployment:
oc -n ack-system annotate serviceaccount ${ACK_SERVICE_ACCOUNT} \ eks.amazonaws.com/role-arn=${ROLE_ARN} && \ oc -n ack-system rollout restart deployment ack-${ACK_SERVICE}-controller
$ oc -n ack-system annotate serviceaccount ${ACK_SERVICE_ACCOUNT} \ eks.amazonaws.com/role-arn=${ROLE_ARN} && \ oc -n ack-system rollout restart deployment ack-${ACK_SERVICE}-controller
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the ACK S3 Operator is running:
oc -n ack-system get pods
$ oc -n ack-system get pods
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE ack-s3-controller-585f6775db-s4lfz 1/1 Running 0 51s
NAME READY STATUS RESTARTS AGE ack-s3-controller-585f6775db-s4lfz 1/1 Running 0 51s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
11.5. Validating the deployment Link kopierenLink in die Zwischenablage kopiert!
Deploy an S3 bucket resource:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the S3 bucket was created in AWS:
aws s3 ls | grep ${CLUSTER_NAME}-bucket
$ aws s3 ls | grep ${CLUSTER_NAME}-bucket
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
2023-10-04 14:51:45 mrmc-test-maz-bucket
2023-10-04 14:51:45 mrmc-test-maz-bucket
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
11.6. Cleaning up Link kopierenLink in die Zwischenablage kopiert!
Delete the S3 bucket resource:
oc -n ack-system delete bucket.s3.services.k8s.aws/${CLUSTER-NAME}-bucket
$ oc -n ack-system delete bucket.s3.services.k8s.aws/${CLUSTER-NAME}-bucket
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the ACK S3 Operator and the AWS IAM roles:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the
ack-system
project:oc delete project ack-system
$ oc delete project ack-system
Copy to Clipboard Copied! Toggle word wrap Toggle overflow