Chapter 2. Comprehensive guide to getting started with Red Hat OpenShift Service on AWS classic architecture
Create a Red Hat OpenShift Service on AWS classic architecture cluster, grant user access, deploy your first application, revoke user access, and delete your cluster.
If you need a quick start guide, see the Red Hat OpenShift Service on AWS classic architecture quick start guide.
You can create a Red Hat OpenShift Service on AWS classic architecture cluster that uses AWS Security Token Service (STS).
2.1. Prerequisites Copy linkLink copied to clipboard!
Before you get started with Red Hat OpenShift Service on AWS classic architecture, ensure that you meet the prerequisites.
- You reviewed the introduction to Red Hat OpenShift Service on AWS classic architecture, and the documentation on Red Hat OpenShift Service on AWS classic architecture architecture models and architecture concepts.
- You have read the documentation on the guidelines for planning your environment.
- You have reviewed the detailed AWS prerequisites for Red Hat OpenShift Service on AWS classic architecture with STS.
- You have the AWS service quotas required to run a Red Hat OpenShift Service on AWS classic architecture cluster.
2.1.1. Set up environment for cluster creation Copy linkLink copied to clipboard!
Before you create a Red Hat OpenShift Service on AWS classic architecture cluster, you must configure your environment.
You must complete the following tasks:
- Verify Red Hat OpenShift Service on AWS classic architecture prerequisites against your AWS and Red Hat accounts.
- Install and configure the required command-line interface (CLI) tools.
- Verify the configuration of the CLI tools.
2.1.1.1. Verify Red Hat OpenShift Service on AWS classic architecture prerequisites Copy linkLink copied to clipboard!
You can enable Red Hat OpenShift Service on AWS classic architecture in your AWS account by verifying prerequisites in the AWS Management Console.
Prerequisites
- You have a Red Hat account.
You have an AWS account.
NoteConsider using a dedicated AWS account to run production clusters. If you are using AWS Organizations, you can use an AWS account within your organization or create a new one.
Procedure
- Sign in to the AWS Management Console.
- Navigate to the ROSA service.
Click Get started.
The Verify ROSA prerequisites page opens.
Under ROSA enablement, ensure that a checkmark and
You previously enabled ROSAare displayed.If not, follow these steps:
-
Select the checkbox beside
I agree to share my contact information with Red Hat. Click Enable ROSA.
After a short wait, a checkmark and
You enabled ROSAmessage are displayed.
-
Select the checkbox beside
Under Service Quotas, ensure that a checkmark and
Your quotas meet the requirements for ROSAare displayed.If you see
Your quotas don’t meet the minimum requirements, take note of the quota type and the minimum listed in the error message. See the Amazon documentation on requesting a quota increase for guidance. It might take several hours for Amazon to approve your quota request.-
Under ELB service-linked role, ensure that a checkmark and
AWSServiceRoleForElasticLoadBalancing already existsare displayed. Click Continue to Red Hat.
The Get started with Red Hat OpenShift Service on AWS classic architecture (ROSA) page opens in a new tab. You have already completed Step 1 on this page, and can now continue with Step 2.
Verification
- Go to the OpenShift Cluster Manager to verify that your AWS account is associated with your Red Hat organization.
2.1.1.2. Install and configure the required CLI tools Copy linkLink copied to clipboard!
Several command-line interface (CLI) tools are required to deploy and work with your cluster.
Prerequisites
- You have an AWS account.
- You have a Red Hat account.
Procedure
Log in to your Red Hat and AWS accounts to access the download page for each required tool.
- Log in to your Red Hat account at console.redhat.com.
- Log in to your AWS account at aws.amazon.com.
Install and configure the latest AWS CLI (
aws).- Install the AWS CLI by following the AWS Command Line Interface documentation appropriate for your workstation.
Configure the AWS CLI by specifying your
aws_access_key_id,aws_secret_access_key, andregionin the.aws/credentialsfile. For more information, see AWS Configuration basics in the AWS documentation.NoteOptional: Use the
AWS_DEFAULT_REGIONenvironment variable to set the default AWS region.Query the AWS API to verify if the AWS CLI is installed and configured correctly:
$ aws sts get-caller-identity --output textFor example:
<aws_account_id> arn:aws:iam::<aws_account_id>:user/<username> <aws_user_id>
Install and configure the latest
rosaCLI.- Navigate to Downloads.
Find Red Hat OpenShift Service on AWS command line interface (
rosa) in the list of tools and click Download.The
rosa-linux.tar.gzfile is downloaded to your default download location.Extract the
rosabinary file from the downloaded archive. The following example extracts the binary from a Linux tar archive:$ tar xvf rosa-linux.tar.gzMove the
rosabinary file to a directory in your execution path. In the following example, the/usr/local/bindirectory is included in the path of the user:$ sudo mv rosa /usr/local/bin/rosaVerify that the
rosaCLI is installed correctly by querying therosaversion:$ rosa versionFor example:
1.2.47 Your <literal>rosa</literal> CLI is up to date.
Log in to the
rosaCLI using an offline access token.Run the login command:
$ rosa loginFor example:
To login to your Red Hat account, get an offline access token at https://console.redhat.com/openshift/token/rosa ? Copy the token and paste it here:- Navigate to the URL listed in the command output to view your offline access token.
Enter the offline access token at the command-line prompt to log in.
? Copy the token and paste it here: ******************* [full token length omitted]NoteIn the future you can specify the offline access token by using the
--token="<offline_access_token>"argument when you run therosa logincommand.Verify that you are logged in and confirm that your credentials are correct before proceeding:
$ rosa whoamiFor example:
AWS Account ID: <aws_account_number> AWS Default Region: us-east-1 AWS ARN: arn:aws:iam::<aws_account_number>:user/<aws_user_name> OCM API: https://api.openshift.com OCM Account ID: <red_hat_account_id> OCM Account Name: Your Name OCM Account Username: you@domain.com OCM Account Email: you@domain.com OCM Organization ID: <org_id> OCM Organization Name: Your organization OCM Organization External ID: <external_org_id>
Install and configure the latest OpenShift CLI (
oc).Use the
rosaCLI to download theocCLI.The following command downloads the latest version of the CLI to the current working directory:
$ rosa download openshift-clientExtract the
ocbinary file from the downloaded archive. The following example extracts the files from a Linux tar archive:$ tar xvf openshift-client-linux.tar.gzMove the
ocbinary to a directory in your execution path. In the following example, the/usr/local/bindirectory is included in the path of the user:$ sudo mv oc /usr/local/bin/ocVerify that the
ocCLI is installed correctly:$ rosa verify openshift-clientFor example:
I: Verifying whether OpenShift command-line tool is available... I: Current OpenShift Client Version: 4.17.3
Verification
Verify the installation of each CLI tool:
$ rosa version $ aws --version $ oc version
2.2. Creating a Red Hat OpenShift Service on AWS classic architecture cluster with STS Copy linkLink copied to clipboard!
Choose from one of the following methods to deploy a Red Hat OpenShift Service on AWS classic architecture cluster that uses the AWS Security Token Service (STS). In each scenario, you can deploy your cluster by using Red Hat OpenShift Cluster Manager or the rosa CLI (rosa):
- Creating a Red Hat OpenShift Service on AWS classic architecture cluster with STS using the default options: You can create a Red Hat OpenShift Service on AWS classic architecture cluster with STS quickly by using the default options and automatic STS resource creation.
-
Creating a Red Hat OpenShift Service on AWS classic architecture cluster with STS using customizations: You can create a Red Hat OpenShift Service on AWS classic architecture cluster with STS using customizations. You can also choose between the
autoandmanualmodes when creating the required STS resources.
2.3. Create a cluster administrator user for quick cluster access Copy linkLink copied to clipboard!
Before configuring an identity provider, you can create a user with cluster-admin privileges for immediate access to your Red Hat OpenShift Service on AWS classic architecture cluster.
The cluster administrator user is useful when you need quick access to a newly deployed cluster. However, consider configuring an identity provider and granting cluster administrator privileges to the identity provider users as required. For more information about setting up an identity provider for your Red Hat OpenShift Service on AWS classic architecture cluster, see Configuring an identity provider and granting cluster access.
Prerequisites
- You have an AWS account.
-
You installed and configured the latest
rosaCLI,rosa, on your workstation. -
You logged in to your Red Hat account using the
rosaCLI. - You created a Red Hat OpenShift Service on AWS classic architecture cluster.
Procedure
Create a cluster administrator user, replacing
<cluster_name>with the name of your cluster:$ rosa create admin --cluster=<cluster_name>Example output
W: It is recommended to add an identity provider to login to this cluster. See 'rosa create idp --help' for more information. I: Admin account has been added to cluster '<cluster_name>'. I: Please securely store this generated password. If you lose this password you can delete and recreate the cluster admin user. I: To login, run the following command: oc login https://api.example-cluster.wxyz.p1.openshiftapps.com:6443 --username cluster-admin --password d7Rca-Ba4jy-YeXhs-WU42J I: It may take up to a minute for the account to become active.NoteIt might take approximately one minute for the
cluster-adminuser to become active.Log in to the cluster through the CLI by running the command provided in the output of the preceding step, replacing
<api_url>and<cluster_admin_password>with the API URL and cluster administrator password for your environment:$ oc login <api_url> --username cluster-admin --password <cluster_admin_password>
Verification
Verify that you are logged in as the cluster administrator:
$ oc whoamiExample output
cluster-admin
2.4. Identity provider configuration and cluster access Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture includes a built-in OAuth server. After your Red Hat OpenShift Service on AWS classic architecture cluster is created, you must configure OAuth to use an identity provider.
You can then add members to your configured identity provider to grant them access to your cluster.
You can also grant the identity provider users with cluster-admin or dedicated-admin privileges as required.
2.4.1. Configure an identity provider Copy linkLink copied to clipboard!
You can configure different identity provider types for your Red Hat OpenShift Service on AWS classic architecture cluster. Supported types include GitHub, GitHub Enterprise, GitLab, Google, LDAP, OpenID Connect and htpasswd identity providers.
The htpasswd identity provider option is included only to enable the creation of a single, static administration user. htpasswd is not supported as a general-use identity provider for Red Hat OpenShift Service on AWS classic architecture.
The following procedure configures a GitHub identity provider as an example.
Prerequisites
- You have an AWS account.
-
You installed and configured the latest
rosaCLI on your workstation. -
You logged in to your Red Hat account using the
rosaCLI. - You created a Red Hat OpenShift Service on AWS classic architecture cluster.
- You have a GitHub user account.
Procedure
- Go to github.com and log in to your GitHub account.
- If you do not have an existing GitHub organization to use for identity provisioning for your Red Hat OpenShift Service on AWS classic architecture cluster, create one. Follow the steps in the GitHub documentation.
Configure a GitHub identity provider for your cluster that is restricted to the members of your GitHub organization.
Configure an identity provider using the interactive mode, replacing
<cluster_name>with the name of your cluster:$ rosa create idp --cluster=<cluster_name> --interactiveThe following example output prompts you to enter information about your GitHub organization, replacing
<github_org_name>with the name of your GitHub organization:Example output
I: Interactive mode enabled. Any optional fields can be left empty and a default will be selected. ? Type of identity provider: github ? Identity provider name: github-1 ? Restrict to members of: organizations ? GitHub organizations: <github_org_name> ? To use GitHub as an identity provider, you must first register the application: - Open the following URL: https://github.com/organizations/<github_org_name>/settings/applications/new?oauth_application%5Bcallback_url%5D=https%3A%2F%2Foauth-openshift.apps.<cluster_name>/<random_string>.p1.openshiftapps.com%2Foauth2callback%2Fgithub-1&oauth_application%5Bname%5D=<cluster_name>&oauth_application%5Burl%5D=https%3A%2F%2Fconsole-openshift-console.apps.<cluster_name>/<random_string>.p1.openshiftapps.com - Click on 'Register application' ...Follow the URL in the output and select Register application to register a new OAuth application in your GitHub organization. By registering the application, you enable the OAuth server that is built into Red Hat OpenShift Service on AWS classic architecture to authenticate members of your GitHub organization into your cluster.
NoteThe fields in the Register a new OAuth application GitHub form are automatically filled with the required values through the URL defined by the
rosaCLI.Use the information from your GitHub OAuth application page to populate the remaining
rosa create idpinteractive prompts, replacing<github_client_id>with the client ID for your GitHub OAuth application and<github_client_secret>with a client secret for your GitHub OAuth application. Specifyclaimas the mapping method:Continued example output
... ? Client ID: <github_client_id> ? Client Secret: [? for help] <github_client_secret> ? GitHub Enterprise Hostname (optional): ? Mapping method: claim I: Configuring IDP for cluster '<cluster_name>' I: Identity Provider 'github-1' has been created. It will take up to 1 minute for this configuration to be enabled. To add cluster administrators, see 'rosa grant user --help'. To login into the console, open https://console-openshift-console.apps.<cluster_name>.<random_string>.p1.openshiftapps.com and click on github-1.NoteIt might take approximately two minutes for the identity provider configuration to become active. If you have configured a
cluster-adminuser, you can watch the OAuth pods redeploy with the updated configuration by runningoc get pods -n openshift-authentication --watch.
Verification
Verify that the identity provider has been configured:
$ rosa list idps --cluster=<cluster_name>Example output
NAME TYPE AUTH URL github-1 GitHub https://oauth-openshift.apps.<cluster_name>.<random_string>.p1.openshiftapps.com/oauth2callback/github-1
2.4.2. Grant user access to a cluster Copy linkLink copied to clipboard!
You can grant a user access to your Red Hat OpenShift Service on AWS classic architecture cluster by adding them to your configured identity provider.
You can configure different types of identity providers for your Red Hat OpenShift Service on AWS classic architecture cluster. The following example procedure adds a user to a GitHub organization that is configured for identity provision to the cluster.
Prerequisites
- You have an AWS account.
-
You installed and configured the latest
rosaCLI on your workstation. -
You logged in to your Red Hat account using the
rosaCLI. - You created a Red Hat OpenShift Service on AWS classic architecture cluster.
- You have a GitHub user account.
- You have configured a GitHub identity provider for your cluster.
Procedure
- Go to github.com and log in to your GitHub account.
- Invite users who require access to the Red Hat OpenShift Service on AWS classic architecture cluster to your GitHub organization. Follow the steps in Inviting users to join your organization in the GitHub documentation.
Verification
Verify that the user was granted access:
$ rosa list users --cluster=<cluster_name>
2.4.3. Grant administrator privileges to a user Copy linkLink copied to clipboard!
After you have added a user to your configured identity provider, you can grant the user cluster-admin or dedicated-admin privileges for your Red Hat OpenShift Service on AWS classic architecture cluster.
Prerequisites
- You have an AWS account.
-
You installed and configured the latest ROSA command-line interface (CLI) (
rosa) on your workstation. -
You logged in to your Red Hat account using the
rosaCLI. - You created a Red Hat OpenShift Service on AWS classic architecture cluster.
- You have configured a GitHub identity provider for your cluster and added identity provider users.
Procedure
To configure
cluster-adminprivileges for an identity provider user, grant the usercluster-adminprivileges:$ rosa grant user cluster-admin --user=<idp_user_name> --cluster=<cluster_name>Example output
I: Granted role 'cluster-admins' to user '<idp_user_name>' on cluster '<cluster_name>'To configure
dedicated-adminprivileges for an identity provider user, grant the userdedicated-adminprivileges:$ rosa grant user dedicated-admin --user=<idp_user_name> --cluster=<cluster_name>Example output
I: Granted role 'dedicated-admins' to user '<idp_user_name>' on cluster '<cluster_name>'
Verification
Verify that the user is listed as a member of the appropriate group:
$ rosa list users --cluster=<cluster_name>Example output
ID GROUPS <idp_user_name> cluster-adminsOr for
dedicated-admin:ID GROUPS <idp_user_name> dedicated-admins
2.5. Access a cluster through the web console Copy linkLink copied to clipboard!
After creating a cluster administrator or adding a user to your identity provider, you can log in to your Red Hat OpenShift Service on AWS classic architecture cluster through the web console.
Prerequisites
- You have an AWS account.
-
You installed and configured the latest ROSA command-line interface (CLI) (
rosa) on your workstation. -
You logged in to your Red Hat account using the
rosaCLI. - You created a Red Hat OpenShift Service on AWS classic architecture cluster.
- You have created a cluster administrator user or added your user account to the configured identity provider.
Procedure
Obtain the console URL for your cluster:
$ rosa describe cluster -c <cluster_name> | grep ConsoleExample output
Console URL: https://console-openshift-console.apps.example-cluster.wxyz.p1.openshiftapps.comGo to the console URL in the output of the preceding step and log in.
-
If you created a
cluster-adminuser, log in by using the provided credentials. - If you configured an identity provider for your cluster, select the identity provider name in the Log in with… dialog and complete any authorization requests from your provider.
-
If you created a
Verification
- Verify that you can access the Red Hat OpenShift Service on AWS classic architecture web console and view cluster resources.
2.6. Deploy an application from the Developer Catalog Copy linkLink copied to clipboard!
From the Red Hat OpenShift Service on AWS classic architecture web console, you can deploy a test application from the Developer Catalog and expose it with a route.
Prerequisites
- You logged in to the Red Hat Hybrid Cloud Console.
- You created a Red Hat OpenShift Service on AWS classic architecture cluster.
- You configured an identity provider for your cluster.
- You added your user account to the configured identity provider.
Procedure
- Go to the Cluster List page in OpenShift Cluster Manager, click the options icon (⋮) next to your cluster, and select Open console. Log in to your Red Hat account with your configured identity provider credentials.
-
In the Administrator perspective, select Home
Projects Create Project, enter a name for your project, and click Create. Optional: Add a Display Name and Description. - Switch to the Developer perspective and select +Add. Verify that the selected Project is the one you created.
In the Developer Catalog dialog, select All services, then select Languages
JavaScript from the menu and click Node.js. NoteYou might need to click Clear All Filters to display the Node.js option.
- To open the Create Source-to-Image application page, click Create. In the Git section, click Try sample, add a unique name in the Name field, and confirm that Deployment and Create a route are selected.
Click Create to deploy the application. It takes a few minutes for the pods to deploy.
-
Optional: Monitor the deployment status in the Topology pane by selecting your Node.js app and reviewing its sidebar. Wait for the
nodejsbuild to complete and for thenodejspod to be in a Running state.
-
Optional: Monitor the deployment status in the Topology pane by selecting your Node.js app and reviewing its sidebar. Wait for the
Access the deployed application by clicking the route URL, which has a format similar to:
https://nodejs-<project>.<cluster_name>.<hash>.<region>.openshiftapps.com/A new browser tab opens displaying a message similar to:
Welcome to your Node.js application on OpenShift
Verification
Verify that the application is running:
$ oc get pods -n <project_name>Example output
NAME READY STATUS RESTARTS AGE nodejs-1-build 0/1 Completed 0 5m nodejs-5d9c6c7d9c-kghq2 1/1 Running 0 2m- Access the application route to verify it responds correctly.
-
Optional: In the Administrator perspective, navigate to Home
Projects, click the action menu for your project, and select Delete Project to clean up resources.
2.7. Revoke administrator privileges and user access Copy linkLink copied to clipboard!
You can revoke cluster-admin or dedicated-admin privileges from a user by using the ROSA command-line interface (CLI) (rosa).
To revoke cluster access from a user, you must remove the user from your configured identity provider.
2.7.1. Revoke administrator privileges from a user Copy linkLink copied to clipboard!
You can revoke cluster-admin or dedicated-admin privileges from a user by using the ROSA command-line interface (CLI) (rosa).
Prerequisites
-
You installed and configured the latest
rosaCLI,rosa, on your workstation. -
You logged in to your Red Hat account using the
rosaCLI. - You created a Red Hat OpenShift Service on AWS classic architecture cluster.
- You have configured a GitHub identity provider for your cluster and added an identity provider user.
-
You granted
cluster-adminordedicated-adminprivileges to a user.
Procedure
To revoke
cluster-adminprivileges from an identity provider user, revoke thecluster-adminprivilege:$ rosa revoke user cluster-admin --user=<idp_user_name> --cluster=<cluster_name>Example output
? Are you sure you want to revoke role cluster-admins from user <idp_user_name> in cluster <cluster_name>? Yes I: Revoked role 'cluster-admins' from user '<idp_user_name>' on cluster '<cluster_name>'To revoke
dedicated-adminprivileges from an identity provider user, revoke thededicated-adminprivilege:$ rosa revoke user dedicated-admin --user=<idp_user_name> --cluster=<cluster_name>Example output
? Are you sure you want to revoke role dedicated-admins from user <idp_user_name> in cluster <cluster_name>? Yes I: Revoked role 'dedicated-admins' from user '<idp_user_name>' on cluster '<cluster_name>'
Verification
Verify that the user is not listed as a member of the group:
$ rosa list users --cluster=<cluster_name>Example output
W: There are no users configured for cluster '<cluster_name>'
2.7.2. Revoke user access to a cluster Copy linkLink copied to clipboard!
You can revoke cluster access for an identity provider user by removing them from your configured identity provider.
You can configure different types of identity providers for your Red Hat OpenShift Service on AWS classic architecture cluster. The following example procedure revokes cluster access for a member of a GitHub organization that is configured for identity provision to the cluster.
Prerequisites
- You have a Red Hat OpenShift Service on AWS classic architecture cluster.
- You have a GitHub user account.
- You have configured a GitHub identity provider for your cluster and added an identity provider user.
Procedure
- Go to github.com and log in to your GitHub account.
- Remove the user from your GitHub organization. Follow the steps in Removing a member from your organization in the GitHub documentation.
Verification
Verify that the user no longer appears in the cluster users list:
$ rosa list users --cluster=<cluster_name>The revoked user should not be displayed in the output.
2.8. Delete a Red Hat OpenShift Service on AWS classic architecture cluster and the AWS IAM STS resources Copy linkLink copied to clipboard!
You can use the rosa CLI to delete a Red Hat OpenShift Service on AWS classic architecture cluster that uses AWS Security Token Service (STS), the AWS Identity and Access Management (IAM) account-wide roles, cluster-specific Operator roles, and the OpenID Connect (OIDC) provider.
To delete account-wide inline and Operator policies, use the AWS IAM Console or AWS CLI.
Account-wide IAM roles and policies might be used by other Red Hat OpenShift Service on AWS classic architecture clusters in the same AWS account. You must only remove the resources if they are not required by other clusters.
Prerequisites
-
You installed and configured the latest
rosaCLI on your workstation. -
You logged in to your Red Hat account using the
rosaCLI. - You created a Red Hat OpenShift Service on AWS classic architecture cluster.
Procedure
Delete a cluster and watch the logs, replacing
<cluster_name>with the name or ID of your cluster:$ rosa delete cluster --cluster=<cluster_name> --watchImportantYou must wait for the cluster deletion to complete before you remove the IAM roles, policies, and OIDC provider. The account-wide roles are required to delete the resources created by the installation program. The cluster-specific Operator roles are required to clean-up the resources created by the OpenShift Operators. The Operators use the OIDC provider to authenticate with AWS APIs.
After the cluster is deleted, delete the OIDC provider that the cluster Operators use to authenticate:
$ rosa delete oidc-provider -c <cluster_id> --mode autoNoteYou can use the
-yoption to automatically answer yes to the prompts.Delete the cluster-specific Operator IAM roles:
$ rosa delete operator-roles -c <cluster_id> --mode autoDelete the account-wide roles:
ImportantAccount-wide IAM roles and policies might be used by other Red Hat OpenShift Service on AWS classic architecture clusters in the same AWS account. You must only remove the resources if they are not required by other clusters.
$ rosa delete account-roles --prefix <prefix> --mode autoReplace
<prefix>with the prefix of the account-wide roles to delete. If you did not specify a custom prefix when you created the account-wide roles, specify the default prefix, depending on how they were created,HCP-ROSAorManagedOpenShift.Delete the account-wide and Operator IAM policies that you created for Red Hat OpenShift Service on AWS classic architecture deployments that use STS:
- Log in to the AWS IAM Console.
-
Go to Access management
Policies and select the checkbox for one of the account-wide policies. -
With the policy selected, click Actions
Delete to open the delete policy dialog. - Enter the policy name to confirm the deletion and select Delete to delete the policy.
- Repeat this step to delete each of the account-wide and Operator policies for the cluster.
Verification
Verify that the cluster has been deleted:
$ rosa list clustersThe deleted cluster should not appear in the output.