Tutorials
Red Hat OpenShift Service on AWS tutorials
Abstract
Chapter 1. Tutorials overview Copy linkLink copied to clipboard!
Use the step-by-step tutorials from Red Hat experts to get the most out of your Managed OpenShift cluster.
This content is authored by Red Hat experts but has not yet been tested on every supported configuration.
Chapter 2. Tutorial: Verifying permissions for a Red Hat OpenShift Service on AWS classic architecture STS deployment Copy linkLink copied to clipboard!
To proceed with the deployment of a Red Hat OpenShift Service on AWS classic architecture cluster, an account must support the required roles and permissions. AWS Service Control Policies (SCPs) cannot block the API calls made by the installer or Operator roles.
Details about the IAM resources required for an STS-enabled installation of Red Hat OpenShift Service on AWS classic architecture can be found here: About IAM resources for Red Hat OpenShift Service on AWS classic architecture clusters that use STS.
This guide is validated for Red Hat OpenShift Service on AWS classic architecture v4.11.X.
2.1. Prerequisites Copy linkLink copied to clipboard!
2.2. Verifying Red Hat OpenShift Service on AWS classic architecture permissions Copy linkLink copied to clipboard!
To verify the permissions required for Red Hat OpenShift Service on AWS classic architecture, we can run the script included in the following section without ever creating any AWS resources.
The script uses the rosa, aws, and jq CLI commands to create files in the working directory that will be used to verify permissions in the account connected to the current AWS configuration.
The AWS Policy Simulator is used to verify the permissions of each role policy against the API calls extracted by jq; results are then stored in a text file appended with .results.
This script is designed to verify the permissions for the current account and region.
2.3. Usage Instructions Copy linkLink copied to clipboard!
To use the script, run the following commands in a
bashterminal (the -p option defines a prefix for the roles):Copy to Clipboard Copied! Toggle word wrap Toggle overflow After the script completes, review each results file to ensure that none of the required API calls are blocked:
for file in $(ls *.results); do echo $file; cat $file; done
$ for file in $(ls *.results); do echo $file; cat $file; doneCopy to Clipboard Copied! Toggle word wrap Toggle overflow The output will look similar to the following:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf any actions are blocked, review the error provided by AWS and consult with your Administrator to determine if SCPs are blocking the required API calls.
Chapter 3. Tutorial: Deploying Red Hat OpenShift Service on AWS classic architecture with a Custom DNS Resolver Copy linkLink copied to clipboard!
A custom DHCP option set enables you to customize your VPC with your own DNS server, domain name, and more. Red Hat OpenShift Service on AWS classic architecture clusters support using custom DHCP option sets. By default, Red Hat OpenShift Service on AWS classic architecture clusters require setting the "domain name servers" option to AmazonProvidedDNS to ensure successful cluster creation and operation. Customers who want to use custom DNS servers for DNS resolution must do additional configuration to ensure successful Red Hat OpenShift Service on AWS classic architecture cluster creation and operation.
In this tutorial, we will configure our DNS server to forward DNS lookups for specific DNS zones (further detailed below) to an Amazon Route 53 Inbound Resolver.
This tutorial uses the open-source BIND DNS server (named) to demonstrate the configuration necessary to forward DNS lookups to an Amazon Route 53 Inbound Resolver located in the VPC you plan to deploy a Red Hat OpenShift Service on AWS classic architecture cluster into. Refer to the documentation of your preferred DNS server for how to configure zone forwarding.
3.1. Prerequisites Copy linkLink copied to clipboard!
-
ROSA CLI (
rosa) -
AWS CLI (
aws) - A manually created AWS VPC
- A DHCP option set configured to point to a custom DNS server and set as the default for your VPC
3.2. Setting up your environment Copy linkLink copied to clipboard!
You can use environment variables to ensure consistency across the commands within this lab.
Procedure
In your terminal, configure the following environment variables:
export VPC_ID=<vpc_ID> export REGION=<region> export VPC_CIDR=<vpc_CIDR>
$ export VPC_ID=<vpc_ID> $ export REGION=<region> $ export VPC_CIDR=<vpc_CIDR>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<vpc_ID>- Replace with the ID of the VPC you want to install your cluster into.
<region>- Replace with the AWS region you want to install your cluster into.
<vpc_CIDR>- Replace with the CIDR range of your VPC.
Ensure all fields output correctly before moving to the next section:
echo "VPC ID: ${VPC_ID}, VPC CIDR Range: ${VPC_CIDR}, Region: ${REGION}"$ echo "VPC ID: ${VPC_ID}, VPC CIDR Range: ${VPC_CIDR}, Region: ${REGION}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.3. Create an Amazon Route 53 Inbound Resolver Copy linkLink copied to clipboard!
Use the following procedure to deploy an Amazon Route 53 Inbound Resolver in the VPC we plan to deploy the cluster into.
In this example, we deploy the Amazon Route 53 Inbound Resolver into the same VPC the cluster will use. If you want to deploy it into a separate VPC, you must manually associate the private hosted zone(s) detailed below once cluster creation is started. You cannot associate the zone before the cluster creation process begins. Failure to associate the private hosted zone during the cluster creation process will result in cluster creation failures.
Procedure
Create a security group and allow access to ports
53/tcpand53/udpfrom the VPC:SG_ID=$(aws ec2 create-security-group --group-name rosa-inbound-resolver --description "Security group for ROSA inbound resolver" --vpc-id ${VPC_ID} --region ${REGION} --output text) aws ec2 authorize-security-group-ingress --group-id ${SG_ID} --protocol tcp --port 53 --cidr ${VPC_CIDR} --region ${REGION} aws ec2 authorize-security-group-ingress --group-id ${SG_ID} --protocol udp --port 53 --cidr ${VPC_CIDR} --region ${REGION}$ SG_ID=$(aws ec2 create-security-group --group-name rosa-inbound-resolver --description "Security group for ROSA inbound resolver" --vpc-id ${VPC_ID} --region ${REGION} --output text) $ aws ec2 authorize-security-group-ingress --group-id ${SG_ID} --protocol tcp --port 53 --cidr ${VPC_CIDR} --region ${REGION} $ aws ec2 authorize-security-group-ingress --group-id ${SG_ID} --protocol udp --port 53 --cidr ${VPC_CIDR} --region ${REGION}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an Amazon Route 53 Inbound Resolver in your VPC:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe above command attaches Amazon Route 53 Inbound Resolver endpoints to all subnets in the provided VPC using dynamically allocated IP addresses. If you prefer to manually specify the subnets and/or IP addresses, run the following command instead:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<subnet_ID>with the subnet IDs and<endpoint_IP>with the static IP addresses you want inbound resolver endpoints added to.Get the IP addresses of your inbound resolver endpoints to configure in your DNS server configuration:
aws route53resolver list-resolver-endpoint-ip-addresses \ --resolver-endpoint-id ${RESOLVER_ID} \ --region=${REGION} \ --query 'IpAddresses[*].Ip'$ aws route53resolver list-resolver-endpoint-ip-addresses \ --resolver-endpoint-id ${RESOLVER_ID} \ --region=${REGION} \ --query 'IpAddresses[*].Ip'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
[ "10.0.45.253", "10.0.23.131", "10.0.148.159" ][ "10.0.45.253", "10.0.23.131", "10.0.148.159" ]Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.4. Configure your DNS server Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture clusters require you to configure DNS server to forward the necessary private hosted zones to your Amazon Route 53 Inbound Resolver:
-
<domain-prefix>.<unique-ID>.p1.openshiftapps.com
This Amazon Route 53 private hosted zones is created during cluster creation. The domain-prefix is a customer-specified value, but the unique-ID is randomly generated during cluster creation and cannot be preselected. As such, you must wait for the cluster creation process to begin before configuring forwarding for the p1.openshiftapps.com private hosted zone.
Procedure
- Create your cluster.
Once your cluster has begun the creation process, locate the newly created private hosted zone:
aws route53 list-hosted-zones-by-vpc \ --vpc-id ${VPC_ID} \ --vpc-region ${REGION} \ --query 'HostedZoneSummaries[*].Name' \ --output table$ aws route53 list-hosted-zones-by-vpc \ --vpc-id ${VPC_ID} \ --vpc-region ${REGION} \ --query 'HostedZoneSummaries[*].Name' \ --output tableCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
---------------------------------------------- | ListHostedZonesByVPC | +--------------------------------------------+ | domain-prefix.agls.p3.openshiftapps.com. | +--------------------------------------------+
---------------------------------------------- | ListHostedZonesByVPC | +--------------------------------------------+ | domain-prefix.agls.p3.openshiftapps.com. | +--------------------------------------------+Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIt may take a few minutes for the cluster creation process to create the private hosted zones in Route 53. If you do not see an
p1.openshiftapps.comdomain, wait a few minutes and run the command again.Once you know the unique ID of the cluster domain, configure your DNS server to forward all DNS requests for
<domain-prefix>.<unique-ID>.p1.openshiftapps.comto your Amazon Route 53 Inbound Resolver endpoints. For BIND DNS servers, edit your/etc/named.conffile in your favorite text editor and add a new zone using the below example:Example
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
<domain-prefix>with your cluster domain prefix and<unique-ID>with your unique ID collected above. -
Replace with the IP addresses of your inbound resolver endpoints collected above, ensuring that following each IP address there is a
;.
-
Replace
Chapter 4. Tutorial: Using AWS WAF and Amazon CloudFront to protect Red Hat OpenShift Service on AWS classic architecture workloads Copy linkLink copied to clipboard!
AWS WAF is a web application firewall that lets you monitor the HTTP and HTTPS requests that are forwarded to your protected web application resources.
You can use an Amazon CloudFront to add a Web Application Firewall (WAF) to your Red Hat OpenShift Service on AWS classic architecture workloads. Using an external solution protects Red Hat OpenShift Service on AWS classic architecture resources from experiencing denial of service due to handling the WAF.
WAFv1, WAF classic, is no longer supported. Use WAFv2.
4.1. Prerequisites Copy linkLink copied to clipboard!
- A Red Hat OpenShift Service on AWS classic architecture cluster.
-
You have access to the OpenShift CLI (
oc). -
You have access to the AWS CLI (
aws).
4.2. Setting up your environment Copy linkLink copied to clipboard!
You can use environment variables to ensure consistency across the commands within this lab.
Procedure
In your terminal, configure the following environment variables:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the
DOMAINvalueapps.example.comwith the custom domain you want to use for theIngressController.NoteThe "Cluster" output from the previous command might be the name of your cluster, the internal ID of your cluster, or the cluster’s domain prefix. If you prefer to use another identifier, you can manually set this value by running the following command:
export CLUSTER=my-custom-value
$ export CLUSTER=my-custom-valueCopy to Clipboard Copied! Toggle word wrap Toggle overflow
4.3. Setting up the secondary ingress controller Copy linkLink copied to clipboard!
It is necessary to configure a secondary ingress controller to segment your external WAF-protected traffic from your standard (and default) cluster ingress controller.
Prerequisites
A publicly trusted SAN or wildcard certificate for your custom domain, such as
CN=*.apps.example.comImportantAmazon CloudFront uses HTTPS to communicate with your cluster’s secondary ingress controller. As explained in the Amazon CloudFront documentation, you cannot use a self-signed certificate for HTTPS communication between CloudFront and your cluster. Amazon CloudFront verifies that the certificate was issued by a trusted certificate authority.
Procedure
Create a new TLS secret from a private key and a public certificate, where
fullchain.pemis your full wildcard certificate chain (including any intermediaries) andprivkey.pemis your wildcard certificate’s private key.Example
oc -n openshift-ingress create secret tls waf-tls --cert=fullchain.pem --key=privkey.pem
$ oc -n openshift-ingress create secret tls waf-tls --cert=fullchain.pem --key=privkey.pemCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new
IngressControllerresource:For example
waf-ingress-controller.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
-
domain: apps.example.com:: Replace with the custom domain you want to use for theIngressController. -
routeSelector:: Filters the set of routes serviced by the Ingress Controller. In this tutorial, we will use thewafroute selector, but if no value was to be provided, no filtering would occur.
-
Apply the
IngressController:Example
oc apply -f waf-ingress-controller.yaml
$ oc apply -f waf-ingress-controller.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that your IngressController has successfully created an external load balancer:
oc -n openshift-ingress get service/router-cloudfront-waf
$ oc -n openshift-ingress get service/router-cloudfront-wafCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE router-cloudfront-waf LoadBalancer 172.30.16.141 a68a838a7f26440bf8647809b61c4bc8-4225395f488830bd.elb.us-east-1.amazonaws.com 80:30606/TCP,443:31065/TCP 2m19s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE router-cloudfront-waf LoadBalancer 172.30.16.141 a68a838a7f26440bf8647809b61c4bc8-4225395f488830bd.elb.us-east-1.amazonaws.com 80:30606/TCP,443:31065/TCP 2m19sCopy to Clipboard Copied! Toggle word wrap Toggle overflow
4.3.1. Configure the AWS WAF Copy linkLink copied to clipboard!
The AWS WAF service is a web application firewall that lets you monitor, protect, and control the HTTP and HTTPS requests that are forwarded to your protected web application resources, like Red Hat OpenShift Service on AWS classic architecture.
Procedure
Create a AWS WAF rules file to apply to our web ACL:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This will enable the Core (Common) and SQL AWS Managed Rule Sets.
Create an AWS WAF Web ACL using the rules we specified above:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.4. Configure Amazon CloudFront Copy linkLink copied to clipboard!
You can use the aws CLI tool as well as the OpenShift CLI (oc) tool to configure Amazon Cloudfront.
Procedure
Retrieve the newly created custom ingress controller’s NLB hostname:
NLB=$(oc -n openshift-ingress get service router-cloudfront-waf \ -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')$ NLB=$(oc -n openshift-ingress get service router-cloudfront-waf \ -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Import your certificate into Amazon Certificate Manager, where
cert.pemis your wildcard certificate,fullchain.pemis your wildcard certificate’s chain andprivkey.pemis your wildcard certificate’s private key.NoteRegardless of what region your cluster is deployed, you must import this certificate to
us-east-1as Amazon CloudFront is a global AWS service.Example
aws acm import-certificate --certificate file://cert.pem \ --certificate-chain file://fullchain.pem \ --private-key file://privkey.pem \ --region us-east-1
$ aws acm import-certificate --certificate file://cert.pem \ --certificate-chain file://fullchain.pem \ --private-key file://privkey.pem \ --region us-east-1Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Log into the AWS console to create a CloudFront distribution.
Configure the CloudFront distribution by using the following information:
NoteIf an option is not specified in the table below, leave them the default (which may be blank).
Expand Option Value Origin domain
Output from the previous command [a]
Name
rosa-waf-ingress [b]
Viewer protocol policy
Redirect HTTP to HTTPS
Allowed HTTP methods
GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
Cache policy
CachingDisabled
Origin request policy
AllViewer
Web Application Firewall (WAF)
Enable security protections
Use existing WAF configuration
true
Choose a web ACL
cloudfront-wafAlternate domain name (CNAME)
*.apps.example.com [c]
Custom SSL certificate
Select the certificate you imported from the step above [d]
-
Run
echo ${NLB}to get the origin domain. - If you have multiple clusters, ensure the origin name is unique.
- This should match the wildcard domain you used to create the custom ingress controller.
- This should match the alternate domain name entered above.
-
Run
Retrieve the Amazon CloudFront Distribution endpoint:
aws cloudfront list-distributions --query "DistributionList.Items[?Origins.Items[?DomainName=='${NLB}']].DomainName" --output text$ aws cloudfront list-distributions --query "DistributionList.Items[?Origins.Items[?DomainName=='${NLB}']].DomainName" --output textCopy to Clipboard Copied! Toggle word wrap Toggle overflow Update the DNS of your custom wildcard domain with a CNAME to the Amazon CloudFront Distribution endpoint from the step above.
Example
*.apps.example.com CNAME d1b2c3d4e5f6g7.cloudfront.net
*.apps.example.com CNAME d1b2c3d4e5f6g7.cloudfront.netCopy to Clipboard Copied! Toggle word wrap Toggle overflow
4.5. Deploy a sample application Copy linkLink copied to clipboard!
You can use the OpenShift CLI (oc) tool to deploy your application.
Procedure
Create a new project for your sample application by running the following command:
oc new-project hello-world
$ oc new-project hello-worldCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy a hello world application:
oc -n hello-world new-app --image=docker.io/openshift/hello-openshift
$ oc -n hello-world new-app --image=docker.io/openshift/hello-openshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a route for the application specifying your custom domain name:
Example
oc -n hello-world create route edge --service=hello-openshift hello-openshift-tls \ --hostname hello-openshift.${DOMAIN}$ oc -n hello-world create route edge --service=hello-openshift hello-openshift-tls \ --hostname hello-openshift.${DOMAIN}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Label the route to admit it to your custom ingress controller:
oc -n hello-world label route.route.openshift.io/hello-openshift-tls route=waf
$ oc -n hello-world label route.route.openshift.io/hello-openshift-tls route=wafCopy to Clipboard Copied! Toggle word wrap Toggle overflow
4.6. Test the WAF Copy linkLink copied to clipboard!
Use the curl command to test the WAF app.
Procedure
Test that the app is accessible behind Amazon CloudFront:
Example
curl "https://hello-openshift.${DOMAIN}"$ curl "https://hello-openshift.${DOMAIN}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Hello OpenShift!
Hello OpenShift!Copy to Clipboard Copied! Toggle word wrap Toggle overflow Test that the WAF denies a bad request:
Example
curl -X POST "https://hello-openshift.${DOMAIN}" \ -F "user='<script><alert>Hello></alert></script>'"$ curl -X POST "https://hello-openshift.${DOMAIN}" \ -F "user='<script><alert>Hello></alert></script>'"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The expected result is a
403 ERROR, which means the AWS WAF is protecting your application.
Chapter 5. Tutorial: Using AWS WAF and AWS ALBs to protect Red Hat OpenShift Service on AWS classic architecture workloads Copy linkLink copied to clipboard!
AWS WAF is a web application firewall that lets you monitor the HTTP and HTTPS requests that are forwarded to your protected web application resources.
You can use an AWS Application Load Balancer (ALB) to add a Web Application Firewall (WAF) to your Red Hat OpenShift Service on AWS classic architecture workloads. Using an external solution protects Red Hat OpenShift Service on AWS classic architecture resources from experiencing denial of service due to handling the WAF.
It is recommended that you use the more flexible CloudFront method unless you absolutely must use an ALB based solution.
5.1. Prerequisites Copy linkLink copied to clipboard!
Multiple availability zone (AZ) Red Hat OpenShift Service on AWS classic architecture cluster.
NoteAWS ALBs require at least two public subnets across AZs, per the AWS documentation. For this reason, only multiple AZ Red Hat OpenShift Service on AWS classic architecture clusters can be used with ALBs.
-
You have access to the OpenShift CLI (
oc). -
You have access to the AWS CLI (
aws).
5.1.1. Setting up your environment Copy linkLink copied to clipboard!
You can use environment variables to ensure consistency across the commands within this lab.
Procedure
Configure the following environment variables:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.1.2. AWS VPC and subnets Copy linkLink copied to clipboard!
This section only applies to clusters that were deployed into existing VPCs. If you did not deploy your cluster into an existing VPC, skip this section and proceed to the installation section below.
You need to tag your subnets and VPCs before using these resources in this tutorial.
Procedure
Set the below variables to the proper values for your Red Hat OpenShift Service on AWS classic architecture deployment:
export VPC_ID=<vpc-id> export PUBLIC_SUBNET_IDS=(<space-separated-list-of-ids>) export PRIVATE_SUBNET_IDS=(<space-separated-list-of-ids>)
$ export VPC_ID=<vpc-id> $ export PUBLIC_SUBNET_IDS=(<space-separated-list-of-ids>) $ export PRIVATE_SUBNET_IDS=(<space-separated-list-of-ids>)Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
VPC_ID=<vpc-id>-
Replace with the VPC ID of the cluster, for example:
export VPC_ID=vpc-04c429b7dbc4680ba. PUBLIC_SUBNET_IDS=(<space-separated-list-of-ids>)-
Replace with a space-separated list of the private subnet IDs of the cluster, making sure to preserve the
(). For example:export PUBLIC_SUBNET_IDS=(subnet-056fd6861ad332ba2 subnet-08ce3b4ec753fe74c subnet-071aa28228664972f). PRIVATE_SUBNET_IDS=(<space-separated-list-of-ids>)-
Replace with a space-separated list of the private subnet IDs of the cluster, making sure to preserve the
(). For example:export PRIVATE_SUBNET_IDS=(subnet-0b933d72a8d72c36a subnet-0817eb72070f1d3c2 subnet-0806e64159b66665a).
Add a tag to your cluster’s VPC with the cluster identifier:
aws ec2 create-tags --resources ${VPC_ID} \ --tags Key=kubernetes.io/cluster/${CLUSTER},Value=shared --region ${REGION}$ aws ec2 create-tags --resources ${VPC_ID} \ --tags Key=kubernetes.io/cluster/${CLUSTER},Value=shared --region ${REGION}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a tag to your public subnets:
aws ec2 create-tags \ --resources ${PUBLIC_SUBNET_IDS} \ --tags Key=kubernetes.io/role/elb,Value='1' \ Key=kubernetes.io/cluster/${CLUSTER},Value=shared \ --region ${REGION}$ aws ec2 create-tags \ --resources ${PUBLIC_SUBNET_IDS} \ --tags Key=kubernetes.io/role/elb,Value='1' \ Key=kubernetes.io/cluster/${CLUSTER},Value=shared \ --region ${REGION}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a tag to your private subnets:
aws ec2 create-tags \ --resources ${PRIVATE_SUBNET_IDS} \ --tags Key=kubernetes.io/role/internal-elb,Value='1' \ Key=kubernetes.io/cluster/${CLUSTER},Value=shared \ --region ${REGION}$ aws ec2 create-tags \ --resources ${PRIVATE_SUBNET_IDS} \ --tags Key=kubernetes.io/role/internal-elb,Value='1' \ Key=kubernetes.io/cluster/${CLUSTER},Value=shared \ --region ${REGION}Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2. Deploy the AWS Load Balancer Operator Copy linkLink copied to clipboard!
The AWS Load Balancer Operator is used to used to install, manage and configure an instance of aws-load-balancer-controller in a Red Hat OpenShift Service on AWS classic architecture cluster. To deploy ALBs in Red Hat OpenShift Service on AWS classic architecture, we need to first deploy the AWS Load Balancer Operator.
Procedure
Create a new project to deploy the AWS Load Balancer Operator into by running the following command:
oc new-project aws-load-balancer-operator
$ oc new-project aws-load-balancer-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create an AWS IAM policy for the AWS Load Balancer Controller if one does not already exist by running the following command:
NoteThe policy is sourced from the upstream AWS Load Balancer Controller policy. This is required by the operator to function.
POLICY_ARN=$(aws iam list-policies --query \ "Policies[?PolicyName=='aws-load-balancer-operator-policy'].{ARN:Arn}" \ --output text)$ POLICY_ARN=$(aws iam list-policies --query \ "Policies[?PolicyName=='aws-load-balancer-operator-policy'].{ARN:Arn}" \ --output text)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an AWS IAM trust policy for AWS Load Balancer Operator:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an AWS IAM role for the AWS Load Balancer Operator:
ROLE_ARN=$(aws iam create-role --role-name "${CLUSTER}-alb-operator" \ --assume-role-policy-document "file://${SCRATCH}/trust-policy.json" \ --query Role.Arn --output text)$ ROLE_ARN=$(aws iam create-role --role-name "${CLUSTER}-alb-operator" \ --assume-role-policy-document "file://${SCRATCH}/trust-policy.json" \ --query Role.Arn --output text)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Attach the AWS Load Balancer Operator policy to the IAM role we created previously by running the following command:
aws iam attach-role-policy --role-name "${CLUSTER}-alb-operator" \ --policy-arn ${POLICY_ARN}$ aws iam attach-role-policy --role-name "${CLUSTER}-alb-operator" \ --policy-arn ${POLICY_ARN}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a secret for the AWS Load Balancer Operator to assume our newly created AWS IAM role:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Install the AWS Load Balancer Operator:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy an instance of the AWS Load Balancer Controller using the operator:
NoteIf you get an error here wait a minute and try again, it means the Operator has not completed installing yet.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the that the operator and controller pods are both running:
oc -n aws-load-balancer-operator get pods
$ oc -n aws-load-balancer-operator get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow You should see the following, if not wait a moment and retry:
NAME READY STATUS RESTARTS AGE aws-load-balancer-controller-cluster-6ddf658785-pdp5d 1/1 Running 0 99s aws-load-balancer-operator-controller-manager-577d9ffcb9-w6zqn 2/2 Running 0 2m4s
NAME READY STATUS RESTARTS AGE aws-load-balancer-controller-cluster-6ddf658785-pdp5d 1/1 Running 0 99s aws-load-balancer-operator-controller-manager-577d9ffcb9-w6zqn 2/2 Running 0 2m4sCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.3. Deploy a sample application Copy linkLink copied to clipboard!
You can use the OpenShift CLI (oc) tool to run a sample application to verify this tutorial.
Procedure
Create a new project for our sample application:
oc new-project hello-world
$ oc new-project hello-worldCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy a hello world application:
oc new-app -n hello-world --image=docker.io/openshift/hello-openshift
$ oc new-app -n hello-world --image=docker.io/openshift/hello-openshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow Convert the pre-created service resource to a NodePort service type:
oc -n hello-world patch service hello-openshift -p '{"spec":{"type":"NodePort"}}'$ oc -n hello-world patch service hello-openshift -p '{"spec":{"type":"NodePort"}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy an AWS ALB using the AWS Load Balancer Operator:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Curl the AWS ALB Ingress endpoint to verify the hello world application is accessible:
NoteAWS ALB provisioning takes a few minutes. If you receive an error that says
curl: (6) Could not resolve host, please wait and try again.INGRESS=$(oc -n hello-world get ingress hello-openshift-alb -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') curl "http://${INGRESS}"$ INGRESS=$(oc -n hello-world get ingress hello-openshift-alb -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') $ curl "http://${INGRESS}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Hello OpenShift!
Hello OpenShift!Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.4. Configure the AWS WAF Copy linkLink copied to clipboard!
The AWS WAF service is a web application firewall that lets you monitor, protect, and control the HTTP and HTTPS requests that are forwarded to your protected web application resources, like Red Hat OpenShift Service on AWS classic architecture.
Procedure
Create a AWS WAF rules file to apply to our web ACL:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This will enable the Core (Common) and SQL AWS Managed Rule Sets.
Create an AWS WAF Web ACL using the rules we specified above:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Annotate the Ingress resource with the AWS WAF Web ACL ARN:
oc annotate -n hello-world ingress.networking.k8s.io/hello-openshift-alb \ alb.ingress.kubernetes.io/wafv2-acl-arn=${WAF_ARN}$ oc annotate -n hello-world ingress.networking.k8s.io/hello-openshift-alb \ alb.ingress.kubernetes.io/wafv2-acl-arn=${WAF_ARN}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Wait for 10 seconds for the rules to propagate and test that the app still works:
curl "http://${INGRESS}"$ curl "http://${INGRESS}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Hello OpenShift!
Hello OpenShift!Copy to Clipboard Copied! Toggle word wrap Toggle overflow Test that the WAF denies a bad request:
curl -X POST "http://${INGRESS}" \ -F "user='<script><alert>Hello></alert></script>'"$ curl -X POST "http://${INGRESS}" \ -F "user='<script><alert>Hello></alert></script>'"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteActivation of the AWS WAF integration can sometimes take several minutes. If you do not receive a
403 Forbiddenerror, please wait a few seconds and try again.The expected result is a
403 Forbiddenerror, which means the AWS WAF is protecting your application.
Chapter 6. Tutorial: Deploying OpenShift API for Data Protection on a Red Hat OpenShift Service on AWS classic architecture cluster Copy linkLink copied to clipboard!
This content is authored by Red Hat experts, but has not yet been tested on every supported configuration.
The following tutorial shows you how to deploy the OpenShift API for data protection on your Red Hat OpenShift Service on AWS classic architecture cluster.
6.1. Prerequisites Copy linkLink copied to clipboard!
6.2. Setting up your environment Copy linkLink copied to clipboard!
You can use environment variables to ensure consistency across the commands within this lab.
Procedure
Prepare the environment variables:
NoteChange the cluster name to match your Red Hat OpenShift Service on AWS classic architecture cluster and ensure you are logged into the cluster as an Administrator. Ensure all fields are outputted correctly before moving on.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.3. Prepare AWS Account Copy linkLink copied to clipboard!
Before deploying OpenShift API for data protection, you must set up your AWS account.
Procedure
Create an IAM Policy to allow for S3 Access:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an IAM Role trust policy for the cluster:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Attach the IAM Policy to the IAM Role:
aws iam attach-role-policy --role-name "${ROLE_NAME}" \ --policy-arn ${POLICY_ARN}$ aws iam attach-role-policy --role-name "${ROLE_NAME}" \ --policy-arn ${POLICY_ARN}Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.4. Deploy OADP on the cluster Copy linkLink copied to clipboard!
You need to use the OpenShift CLI (oc) tool to deploy OADP to your cluster.
Procedure
Create a namespace for OADP:
oc create namespace openshift-adp
$ oc create namespace openshift-adpCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a credentials secret:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<aws_region>- Replace with the AWS region to use for the Security Token Service (STS) endpoint.
Deploy the OADP Operator:
NoteThere is currently an issue with version 1.1 of the Operator with backups that have a
PartiallyFailedstatus. This does not seem to affect the backup and restore process, but it should be noted as there are issues with it.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Wait for the Operator to be ready:
watch oc -n openshift-adp get pods
$ watch oc -n openshift-adp get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE openshift-adp-controller-manager-546684844f-qqjhn 1/1 Running 0 22s
NAME READY STATUS RESTARTS AGE openshift-adp-controller-manager-546684844f-qqjhn 1/1 Running 0 22sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create Cloud Storage:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check your application’s storage default storage class by running the following command with your desired namespace:
oc get pvc -n <namespace>
$ oc get pvc -n <namespace>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE applog Bound pvc-351791ae-b6ab-4e8b-88a4-30f73caf5ef8 1Gi RWO gp3-csi 4d19h mysql Bound pvc-16b8e009-a20a-4379-accc-bc81fedd0621 1Gi RWO gp3-csi 4d19h
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE applog Bound pvc-351791ae-b6ab-4e8b-88a4-30f73caf5ef8 1Gi RWO gp3-csi 4d19h mysql Bound pvc-16b8e009-a20a-4379-accc-bc81fedd0621 1Gi RWO gp3-csi 4d19hCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc get storageclass
$ oc get storageclassCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE gp2 kubernetes.io/aws-ebs Delete WaitForFirstConsumer true 4d21h gp2-csi ebs.csi.aws.com Delete WaitForFirstConsumer true 4d21h gp3 ebs.csi.aws.com Delete WaitForFirstConsumer true 4d21h gp3-csi (default) ebs.csi.aws.com Delete WaitForFirstConsumer true 4d21h
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE gp2 kubernetes.io/aws-ebs Delete WaitForFirstConsumer true 4d21h gp2-csi ebs.csi.aws.com Delete WaitForFirstConsumer true 4d21h gp3 ebs.csi.aws.com Delete WaitForFirstConsumer true 4d21h gp3-csi (default) ebs.csi.aws.com Delete WaitForFirstConsumer true 4d21hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Using either gp3-csi, gp2-csi, gp3 or gp2 will work. If the application(s) that are being backed up are all using PV’s with CSI, include the CSI plugin in the OADP DPA configuration.
CSI only: Deploy a Data Protection Application:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf you run this command for CSI volumes, you can skip the next step.
Non-CSI volumes: Deploy a Data Protection Application:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note-
In OADP 1.1.x Red Hat OpenShift Service on AWS classic architecture STS environments, the container image backup and restore (
spec.backupImages) value must be set tofalseas it is not supported. -
The Restic feature (
restic.enable=false) is disabled and not supported in Red Hat OpenShift Service on AWS classic architecture STS environments. -
The DataMover feature (
dataMover.enable=false) is disabled and not supported in Red Hat OpenShift Service on AWS classic architecture STS environments.
-
In OADP 1.1.x Red Hat OpenShift Service on AWS classic architecture STS environments, the container image backup and restore (
6.5. Perform a backup Copy linkLink copied to clipboard!
You can perform a back up by using the OpenShift CLI (oc) tool.
The following sample hello-world application has no attached persistent volumes. Either DPA configuration will work.
Procedure
Create a workload to back up:
oc create namespace hello-world oc new-app -n hello-world --image=docker.io/openshift/hello-openshift
$ oc create namespace hello-world $ oc new-app -n hello-world --image=docker.io/openshift/hello-openshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow Expose the route:
oc expose service/hello-openshift -n hello-world
$ oc expose service/hello-openshift -n hello-worldCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check that the application is working:
curl `oc get route/hello-openshift -n hello-world -o jsonpath='{.spec.host}'`$ curl `oc get route/hello-openshift -n hello-world -o jsonpath='{.spec.host}'`Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Hello OpenShift!
Hello OpenShift!Copy to Clipboard Copied! Toggle word wrap Toggle overflow Back up the workload:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Wait until the backup is done:
watch "oc -n openshift-adp get backup hello-world -o json | jq .status"
$ watch "oc -n openshift-adp get backup hello-world -o json | jq .status"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the demo workload:
oc delete ns hello-world
$ oc delete ns hello-worldCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restore from the backup:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Wait for the Restore to finish:
watch "oc -n openshift-adp get restore hello-world -o json | jq .status"
$ watch "oc -n openshift-adp get restore hello-world -o json | jq .status"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check that the workload is restored:
oc -n hello-world get pods
$ oc -n hello-world get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE hello-openshift-9f885f7c6-kdjpj 1/1 Running 0 90s
NAME READY STATUS RESTARTS AGE hello-openshift-9f885f7c6-kdjpj 1/1 Running 0 90sCopy to Clipboard Copied! Toggle word wrap Toggle overflow curl `oc get route/hello-openshift -n hello-world -o jsonpath='{.spec.host}'`$ curl `oc get route/hello-openshift -n hello-world -o jsonpath='{.spec.host}'`Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Hello OpenShift!
Hello OpenShift!Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.6. Cleaning up Copy linkLink copied to clipboard!
Clean up your AWS resources after completing this lab tutorial.
Procedure
Delete the workload:
oc delete ns hello-world
$ oc delete ns hello-worldCopy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the backup and restore resources from the cluster if they are no longer required:
oc delete backups.velero.io hello-world oc delete restores.velero.io hello-world
$ oc delete backups.velero.io hello-world $ oc delete restores.velero.io hello-worldCopy to Clipboard Copied! Toggle word wrap Toggle overflow To delete the backup/restore and remote objects in s3:
velero backup delete hello-world velero restore delete hello-world
$ velero backup delete hello-world $ velero restore delete hello-worldCopy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the Data Protection Application:
oc -n openshift-adp delete dpa ${CLUSTER_NAME}-dpa$ oc -n openshift-adp delete dpa ${CLUSTER_NAME}-dpaCopy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the Cloud Storage:
oc -n openshift-adp delete cloudstorage ${CLUSTER_NAME}-oadp$ oc -n openshift-adp delete cloudstorage ${CLUSTER_NAME}-oadpCopy to Clipboard Copied! Toggle word wrap Toggle overflow WarningIf this command hangs, you might need to delete the finalizer:
oc -n openshift-adp patch cloudstorage ${CLUSTER_NAME}-oadp -p '{"metadata":{"finalizers":null}}' --type=merge$ oc -n openshift-adp patch cloudstorage ${CLUSTER_NAME}-oadp -p '{"metadata":{"finalizers":null}}' --type=mergeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the Operator if it is no longer required:
oc -n openshift-adp delete subscription oadp-operator
$ oc -n openshift-adp delete subscription oadp-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the namespace for the Operator:
oc delete ns redhat-openshift-adp
$ oc delete ns redhat-openshift-adpCopy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the Custom Resource Definitions from the cluster if you no longer wish to have them:
for CRD in `oc get crds | grep velero | awk '{print $1}'`; do oc delete crd $CRD; done $ for CRD in `oc get crds | grep -i oadp | awk '{print $1}'`; do oc delete crd $CRD; done$ for CRD in `oc get crds | grep velero | awk '{print $1}'`; do oc delete crd $CRD; done $ for CRD in `oc get crds | grep -i oadp | awk '{print $1}'`; do oc delete crd $CRD; doneCopy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the AWS S3 Bucket:
aws s3 rm s3://${CLUSTER_NAME}-oadp --recursive aws s3api delete-bucket --bucket ${CLUSTER_NAME}-oadp$ aws s3 rm s3://${CLUSTER_NAME}-oadp --recursive $ aws s3api delete-bucket --bucket ${CLUSTER_NAME}-oadpCopy to Clipboard Copied! Toggle word wrap Toggle overflow Detach the Policy from the role:
aws iam detach-role-policy --role-name "${ROLE_NAME}" \ --policy-arn "${POLICY_ARN}"$ aws iam detach-role-policy --role-name "${ROLE_NAME}" \ --policy-arn "${POLICY_ARN}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the role:
aws iam delete-role --role-name "${ROLE_NAME}"$ aws iam delete-role --role-name "${ROLE_NAME}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 7. Tutorial: AWS Load Balancer Operator on Red Hat OpenShift Service on AWS classic architecture Copy linkLink copied to clipboard!
This content is authored by Red Hat experts, but has not yet been tested on every supported configuration.
Load Balancers created by the AWS Load Balancer Operator cannot be used for OpenShift Routes, and should only be used for individual services or ingress resources that do not need the full layer 7 capabilities of an OpenShift Route.
The AWS Load Balancer Controller manages AWS Elastic Load Balancers for a Red Hat OpenShift Service on AWS classic architecture cluster. The controller provisions AWS Application Load Balancers (ALB) when you create Kubernetes Ingress resources and AWS Network Load Balancers (NLB) when implementing Kubernetes Service resources with a type of LoadBalancer.
Compared with the default AWS in-tree load balancer provider, this controller is developed with advanced annotations for both ALBs and NLBs. Some advanced use cases are:
- Using native Kubernetes Ingress objects with ALBs
Integrate ALBs with the AWS Web Application Firewall (WAF) service
NoteWAFv1, WAF classic, is no longer supported. Use WAFv2.
- Specify custom NLB source IP ranges
- Specify custom NLB internal IP addresses
The AWS Load Balancer Operator is used to used to install, manage and configure an instance of aws-load-balancer-controller in a Red Hat OpenShift Service on AWS classic architecture cluster.
7.1. Prerequisites Copy linkLink copied to clipboard!
AWS ALBs require a multi-AZ cluster, as well as three public subnets split across three AZs in the same VPC as the cluster. This makes ALBs unsuitable for many PrivateLink clusters. AWS NLBs do not have this restriction.
- A multi-AZ Red Hat OpenShift Service on AWS classic architecture cluster
- BYO VPC cluster
- AWS CLI
- OC CLI
7.1.1. Setting up your environment Copy linkLink copied to clipboard!
You can use environment variables to ensure consistency across the commands within this lab.
Procedure
Prepare the environment variables:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.1.2. AWS VPC and subnets Copy linkLink copied to clipboard!
Before installing the AWS Load Balancer Operator, you must tag your VPC and its subnets.
This section only applies to clusters that were deployed into existing VPCs. If you did not deploy your cluster into an existing VPC, skip this section and proceed to the installation section below.
Procedure
Set the below variables to the proper values for your cluster deployment:
export VPC_ID=<vpc-id> export PUBLIC_SUBNET_IDS=<public-subnets> export PRIVATE_SUBNET_IDS=<private-subnets> export CLUSTER_NAME=$(oc get infrastructure cluster -o=jsonpath="{.status.infrastructureName}")$ export VPC_ID=<vpc-id> $ export PUBLIC_SUBNET_IDS=<public-subnets> $ export PRIVATE_SUBNET_IDS=<private-subnets> $ export CLUSTER_NAME=$(oc get infrastructure cluster -o=jsonpath="{.status.infrastructureName}")Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a tag to your cluster’s VPC with the cluster name:
aws ec2 create-tags --resources ${VPC_ID} --tags Key=kubernetes.io/cluster/${CLUSTER_NAME},Value=owned --region ${REGION}$ aws ec2 create-tags --resources ${VPC_ID} --tags Key=kubernetes.io/cluster/${CLUSTER_NAME},Value=owned --region ${REGION}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a tag to your public subnets:
aws ec2 create-tags \ --resources ${PUBLIC_SUBNET_IDS} \ --tags Key=kubernetes.io/role/elb,Value='' \ --region ${REGION}$ aws ec2 create-tags \ --resources ${PUBLIC_SUBNET_IDS} \ --tags Key=kubernetes.io/role/elb,Value='' \ --region ${REGION}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a tag to your private subnets:
aws ec2 create-tags \ --resources "${PRIVATE_SUBNET_IDS}" \ --tags Key=kubernetes.io/role/internal-elb,Value='' \ --region ${REGION}$ aws ec2 create-tags \ --resources "${PRIVATE_SUBNET_IDS}" \ --tags Key=kubernetes.io/role/internal-elb,Value='' \ --region ${REGION}Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.2. Installation Copy linkLink copied to clipboard!
You can use the OpenShift CLI (oc) tool to install the AWS Load Balancer Operator.
Procedure
Create an AWS IAM policy for the AWS Load Balancer Controller:
NoteThe policy is sourced from the upstream AWS Load Balancer Controller policy plus permission to create tags on subnets. This is required by the Operator to function.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an AWS IAM trust policy for AWS Load Balancer Operator:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an AWS IAM role for the AWS Load Balancer Operator:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a secret for the AWS Load Balancer Operator to assume our newly created AWS IAM role:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Install the AWS Load Balancer Operator:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy an instance of the AWS Load Balancer Controller using the Operator:
NoteIf you get an error here wait a minute and try again, it means the Operator has not completed installing yet.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the that the Operator and controller pods are both running:
oc -n aws-load-balancer-operator get pods
$ oc -n aws-load-balancer-operator get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow You should see the following, if not wait a moment and retry:
NAME READY STATUS RESTARTS AGE aws-load-balancer-controller-cluster-6ddf658785-pdp5d 1/1 Running 0 99s aws-load-balancer-operator-controller-manager-577d9ffcb9-w6zqn 2/2 Running 0 2m4s
NAME READY STATUS RESTARTS AGE aws-load-balancer-controller-cluster-6ddf658785-pdp5d 1/1 Running 0 99s aws-load-balancer-operator-controller-manager-577d9ffcb9-w6zqn 2/2 Running 0 2m4sCopy to Clipboard Copied! Toggle word wrap Toggle overflow
7.3. Validating the deployment Copy linkLink copied to clipboard!
You can validate your load balancer Operators using the OpenShift CLI (oc) tool.
Procedure
Create a new project:
oc new-project hello-world
$ oc new-project hello-worldCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy a hello world application:
oc new-app -n hello-world --image=docker.io/openshift/hello-openshift
$ oc new-app -n hello-world --image=docker.io/openshift/hello-openshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure a NodePort service for the AWS ALB to connect to:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy an AWS ALB using the AWS Load Balancer Operator:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Curl the AWS ALB Ingress endpoint to verify the hello world application is accessible:
NoteAWS ALB provisioning takes a few minutes. If you receive an error that says
curl: (6) Could not resolve host, please wait and try again.INGRESS=$(oc -n hello-world get ingress hello-openshift-alb \ -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') curl "http://${INGRESS}"$ INGRESS=$(oc -n hello-world get ingress hello-openshift-alb \ -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') $ curl "http://${INGRESS}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
Hello OpenShift!
Hello OpenShift!Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy an AWS NLB for your hello world application:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Test the AWS NLB endpoint:
NoteNLB provisioning takes a few minutes. If you receive an error that says
curl: (6) Could not resolve host, please wait and try again.NLB=$(oc -n hello-world get service hello-openshift-nlb \ -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') curl "http://${NLB}"$ NLB=$(oc -n hello-world get service hello-openshift-nlb \ -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') $ curl "http://${NLB}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Hello OpenShift!
Hello OpenShift!Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.4. Cleaning up Copy linkLink copied to clipboard!
Clean up your AWS resources after completing this lab tutorial.
Procedure
Delete the hello world application namespace (and all the resources in the namespace):
oc delete project hello-world
$ oc delete project hello-worldCopy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the AWS Load Balancer Operator and the AWS IAM roles:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the AWS IAM policy:
aws iam delete-policy --policy-arn $POLICY_ARN
$ aws iam delete-policy --policy-arn $POLICY_ARNCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 8. Tutorial: Configuring Microsoft Entra ID (formerly Azure Active Directory) as an identity provider Copy linkLink copied to clipboard!
You can configure Microsoft Entra ID (formerly Azure Active Directory) as the cluster identity provider in Red Hat OpenShift Service on AWS classic architecture.
This tutorial guides you to complete the following tasks:
- Register a new application in Entra ID for authentication.
- Configure the application registration in Entra ID to include optional and group claims in tokens.
- Configure the Red Hat OpenShift Service on AWS classic architecture cluster to use Entra ID as the identity provider.
- Grant additional permissions to individual groups.
8.1. Prerequisites Copy linkLink copied to clipboard!
- You created a set of security groups and assigned users by following the Microsoft documentation.
8.2. Registering a new application in Entra ID for authentication Copy linkLink copied to clipboard!
To register your application in Entra ID, first create the OAuth callback URL, then register your application.
Procedure
Create the cluster’s OAuth callback URL by changing the specified variables and running the following command:
NoteRemember to save this callback URL; it will be required later in the process.
domain=$(rosa describe cluster -c <cluster_name> | grep "DNS" | grep -oE '\S+.openshiftapps.com') echo "OAuth callback URL: https://oauth.${domain}/oauth2callback/AAD"$ domain=$(rosa describe cluster -c <cluster_name> | grep "DNS" | grep -oE '\S+.openshiftapps.com') echo "OAuth callback URL: https://oauth.${domain}/oauth2callback/AAD"Copy to Clipboard Copied! Toggle word wrap Toggle overflow The "AAD" directory at the end of the OAuth callback URL must match the OAuth identity provider name that you will set up later in this process.
Create the Entra ID application by logging in to the Azure portal, and select the App registrations blade. Then, select New registration to create a new application.
-
Name the application, for example
openshift-auth. - Select Web from the Redirect URI dropdown and enter the value of the OAuth callback URL you retrieved in the previous step.
After providing the required information, click Register to create the application.
Select the Certificates & secrets sub-blade and select New client secret.
Complete the requested details and store the generated client secret value. This secret is required later in this process.
ImportantAfter initial setup, you cannot see the client secret. If you did not record the client secret, you must generate a new one.
Select the Overview sub-blade and note the
Application (client) IDandDirectory (tenant) ID. You will need these values in a future step.
8.3. Configuring the application registration in Entra ID to include optional and group claims Copy linkLink copied to clipboard!
To ensure that Red Hat OpenShift Service on AWS classic architecture has enough information to create the user’s account, you must configure Entra ID to give two optional claims: email and preferred_username. For more information about optional claims in Entra ID, see the Microsoft documentation.
In addition to individual user authentication, Red Hat OpenShift Service on AWS classic architecture provides group claim functionality. This functionality allows an OpenID Connect (OIDC) identity provider, such as Entra ID, to offer a user’s group membership for use within Red Hat OpenShift Service on AWS classic architecture.
8.3.1. Configuring optional claims Copy linkLink copied to clipboard!
You can configure the optional claims in Entra ID.
Procedure
Click the Token configuration sub-blade and select the Add optional claim button.
Select the ID radio button.
Select the email claim checkbox.
Select the
preferred_usernameclaim checkbox. Then, click Add to configure the email and preferred_username claims your Entra ID application.
A dialog box appears at the top of the page. Follow the prompt to enable the necessary Microsoft Graph permissions.
8.3.2. Configuring group claims (optional) Copy linkLink copied to clipboard!
Configure Entra ID to offer a groups claim.
Procedure
From the Token configuration sub-blade, click Add groups claim.
To configure group claims for your Entra ID application, select Security groups and then click the Add.
NoteIn this example, the group claim includes all of the security groups that a user is a member of. In a real production environment, ensure that the groups that the group claim only includes groups that apply to Red Hat OpenShift Service on AWS classic architecture.
8.4. Configuring the Red Hat OpenShift Service on AWS classic architecture cluster to use Entra ID as the identity provider Copy linkLink copied to clipboard!
You must configure Red Hat OpenShift Service on AWS classic architecture to use Entra ID as its identity provider. Although Red Hat OpenShift Service on AWS classic architecture offers the ability to configure identity providers by using OpenShift Cluster Manager, use the ROSA CLI to configure the cluster’s OAuth provider to use Entra ID as its identity provider. Before configuring the identity provider, set the necessary variables for the identity provider configuration.
Procedure
Create the variables by running the following command:
CLUSTER_NAME=example-cluster IDP_NAME=AAD APP_ID=yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy CLIENT_SECRET=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx TENANT_ID=zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz
$ CLUSTER_NAME=example-cluster $ IDP_NAME=AAD $ APP_ID=yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy $ CLIENT_SECRET=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx $ TENANT_ID=zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzzCopy to Clipboard Copied! Toggle word wrap Toggle overflow where:
example-cluster- Replace this with the name of your cluster.
AAD- Replace this value with the name you used in the OAuth callback URL that you generated earlier in this process.
yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy- Replace this with the Application (client) ID.
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx- Replace this with the Client Secret.
zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz- Replace this with the Directory (tenant) ID.
Configure the cluster’s OAuth provider by running the following command. If you enabled group claims, ensure that you use the
--group-claims groupsargument.If you enabled group claims, run the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you did not enable group claims, run the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow After a few minutes, the cluster authentication Operator reconciles your changes, and you can log in to the cluster by using Entra ID.
8.5. Granting additional permissions to individual users and groups Copy linkLink copied to clipboard!
When your first log in, you might notice that you have very limited permissions. By default, Red Hat OpenShift Service on AWS classic architecture only grants you the ability to create new projects, or namespaces, in the cluster. Other projects are restricted from view.
You must grant these additional abilities to individual users and groups.
8.6. Granting additional permissions to individual users Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture includes a significant number of preconfigured roles, including the cluster-admin role that grants full access and control over the cluster.
Procedure
Grant a user access to the
cluster-adminrole by running the following command:rosa grant user cluster-admin --user=<USERNAME> --cluster=${CLUSTER_NAME}$ rosa grant user cluster-admin --user=<USERNAME> --cluster=${CLUSTER_NAME}Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<USERNAME>- Provide the Entra ID username that you want to have cluster admin permissions.
8.7. Granting additional permissions to individual groups Copy linkLink copied to clipboard!
If you opted to enable group claims, the cluster OAuth provider automatically creates or updates the user’s group memberships by using the group ID. The cluster OAuth provider does not automatically create RoleBindings and ClusterRoleBindings for the groups that are created; you are responsible for creating those bindings by using your own processes.
To grant an automatically generated group access to the cluster-admin role, you must create a ClusterRoleBinding to the group ID.
Procedure
Create the
ClusterRoleBindingby running the following command:oc create clusterrolebinding cluster-admin-group --clusterrole=cluster-admin --group=<GROUP_ID>
$ oc create clusterrolebinding cluster-admin-group --clusterrole=cluster-admin --group=<GROUP_ID>Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<GROUP-ID>- Provide the Entra ID group ID that you want to have cluster admin permissions.
Now, any user in the specified group automatically receives
cluster-adminaccess.
Chapter 9. Tutorial: Using AWS Secrets Manager CSI on Red Hat OpenShift Service on AWS classic architecture with STS Copy linkLink copied to clipboard!
The AWS Secrets and Configuration Provider (ASCP) provides a way to expose AWS Secrets as Kubernetes storage volumes. With the ASCP, you can store and manage your secrets in Secrets Manager and then retrieve them through your workloads running on Red Hat OpenShift Service on AWS classic architecture.
9.1. Prerequisites Copy linkLink copied to clipboard!
Ensure that you have the following resources and tools before starting this process:
- A Red Hat OpenShift Service on AWS classic architecture cluster deployed with STS
- Helm 3
-
awsCLI -
ocCLI -
jqCLI
9.1.1. Additional environment requirements Copy linkLink copied to clipboard!
Before creating your application, you need to gain access to your Red Hat OpenShift Service on AWS classic architecture cluster.
Procedure
Log in to your Red Hat OpenShift Service on AWS classic architecture cluster by running the following command:
oc login --token=<your-token> --server=<your-server-url>
$ oc login --token=<your-token> --server=<your-server-url>Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can find your login token by accessing your cluster in pull secret from Red Hat OpenShift Cluster Manager.
Validate that your cluster has STS by running the following command:
oc get authentication.config.openshift.io cluster -o json \ | jq .spec.serviceAccountIssuer
$ oc get authentication.config.openshift.io cluster -o json \ | jq .spec.serviceAccountIssuerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
"https://xxxxx.cloudfront.net/xxxxx"
"https://xxxxx.cloudfront.net/xxxxx"Copy to Clipboard Copied! Toggle word wrap Toggle overflow If your output is different, do not proceed. See Red Hat documentation on creating an STS cluster before continuing this process.
Set the
SecurityContextConstraintspermission to allow the CSI driver to run by running the following command:oc new-project csi-secrets-store oc adm policy add-scc-to-user privileged \ system:serviceaccount:csi-secrets-store:secrets-store-csi-driver oc adm policy add-scc-to-user privileged \ system:serviceaccount:csi-secrets-store:csi-secrets-store-provider-aws$ oc new-project csi-secrets-store $ oc adm policy add-scc-to-user privileged \ system:serviceaccount:csi-secrets-store:secrets-store-csi-driver $ oc adm policy add-scc-to-user privileged \ system:serviceaccount:csi-secrets-store:csi-secrets-store-provider-awsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create environment variables to use later in this process by running the following command:
export REGION=$(oc get infrastructure cluster -o=jsonpath="{.status.platformStatus.aws.region}") export OIDC_ENDPOINT=$(oc get authentication.config.openshift.io cluster \ -o jsonpath='{.spec.serviceAccountIssuer}' | sed 's|^https://||') export AWS_ACCOUNT_ID=`aws sts get-caller-identity --query Account --output text` export AWS_PAGER=""$ export REGION=$(oc get infrastructure cluster -o=jsonpath="{.status.platformStatus.aws.region}") $ export OIDC_ENDPOINT=$(oc get authentication.config.openshift.io cluster \ -o jsonpath='{.spec.serviceAccountIssuer}' | sed 's|^https://||') $ export AWS_ACCOUNT_ID=`aws sts get-caller-identity --query Account --output text` $ export AWS_PAGER=""Copy to Clipboard Copied! Toggle word wrap Toggle overflow
9.2. Deploying the AWS Secrets and Configuration Provider Copy linkLink copied to clipboard!
Procedure
Use Helm to register the secrets store CSI driver by running the following command:
helm repo add secrets-store-csi-driver \ https://kubernetes-sigs.github.io/secrets-store-csi-driver/charts$ helm repo add secrets-store-csi-driver \ https://kubernetes-sigs.github.io/secrets-store-csi-driver/chartsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Update your Helm repositories by running the following command:
helm repo update
$ helm repo updateCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install the secrets store CSI driver by running the following command:
helm upgrade --install -n csi-secrets-store \ csi-secrets-store-driver secrets-store-csi-driver/secrets-store-csi-driver$ helm upgrade --install -n csi-secrets-store \ csi-secrets-store-driver secrets-store-csi-driver/secrets-store-csi-driverCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the AWS provider by running the following command:
oc -n csi-secrets-store apply -f \ https://raw.githubusercontent.com/rh-mobb/documentation/main/content/misc/secrets-store-csi/aws-provider-installer.yaml$ oc -n csi-secrets-store apply -f \ https://raw.githubusercontent.com/rh-mobb/documentation/main/content/misc/secrets-store-csi/aws-provider-installer.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check that both Daemonsets are running by running the following command:
oc -n csi-secrets-store get ds \ csi-secrets-store-provider-aws \ csi-secrets-store-driver-secrets-store-csi-driver$ oc -n csi-secrets-store get ds \ csi-secrets-store-provider-aws \ csi-secrets-store-driver-secrets-store-csi-driverCopy to Clipboard Copied! Toggle word wrap Toggle overflow Label the Secrets Store CSI Driver to allow use with the restricted pod security profile by running the following command:
oc label csidriver.storage.k8s.io/secrets-store.csi.k8s.io security.openshift.io/csi-ephemeral-volume-profile=restricted
$ oc label csidriver.storage.k8s.io/secrets-store.csi.k8s.io security.openshift.io/csi-ephemeral-volume-profile=restrictedCopy to Clipboard Copied! Toggle word wrap Toggle overflow
9.3. Creating a Secret and IAM Access Policies Copy linkLink copied to clipboard!
Use the AWS CLI to create your AWS secret and IAM access policies.
Procedure
Create a secret in Secrets Manager by running the following command:
SECRET_ARN=$(aws --region "$REGION" secretsmanager create-secret \ --name MySecret --secret-string \ '{"username":"shadowman", "password":"hunter2"}' \ --query ARN --output text); echo $SECRET_ARN$ SECRET_ARN=$(aws --region "$REGION" secretsmanager create-secret \ --name MySecret --secret-string \ '{"username":"shadowman", "password":"hunter2"}' \ --query ARN --output text); echo $SECRET_ARNCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create an IAM Access Policy document by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an IAM Access Policy by running the following command:
POLICY_ARN=$(aws --region "$REGION" --query Policy.Arn \ --output text iam create-policy \ --policy-name openshift-access-to-mysecret-policy \ --policy-document file://policy.json); echo $POLICY_ARN
$ POLICY_ARN=$(aws --region "$REGION" --query Policy.Arn \ --output text iam create-policy \ --policy-name openshift-access-to-mysecret-policy \ --policy-document file://policy.json); echo $POLICY_ARNCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create an IAM Role trust policy document by running the following command:
NoteThe trust policy is locked down to the default service account of a namespace you create later in this process.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an IAM role by running the following command:
ROLE_ARN=$(aws iam create-role --role-name openshift-access-to-mysecret \ --assume-role-policy-document file://trust-policy.json \ --query Role.Arn --output text); echo $ROLE_ARN
$ ROLE_ARN=$(aws iam create-role --role-name openshift-access-to-mysecret \ --assume-role-policy-document file://trust-policy.json \ --query Role.Arn --output text); echo $ROLE_ARNCopy to Clipboard Copied! Toggle word wrap Toggle overflow Attach the role to the policy by running the following command:
aws iam attach-role-policy --role-name openshift-access-to-mysecret \ --policy-arn $POLICY_ARN$ aws iam attach-role-policy --role-name openshift-access-to-mysecret \ --policy-arn $POLICY_ARNCopy to Clipboard Copied! Toggle word wrap Toggle overflow
9.4. Create an application to use this secret Copy linkLink copied to clipboard!
You can create your application using the secret that you created.
Procedure
Create an OpenShift project by running the following command:
oc new-project my-application
$ oc new-project my-applicationCopy to Clipboard Copied! Toggle word wrap Toggle overflow Annotate the default service account to use the STS Role by running the following command:
oc annotate -n my-application serviceaccount default \ eks.amazonaws.com/role-arn=$ROLE_ARN$ oc annotate -n my-application serviceaccount default \ eks.amazonaws.com/role-arn=$ROLE_ARNCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a secret provider class to access our secret by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a deployment by using our secret in the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the pod has the secret mounted by running the following command:
oc exec -it my-application -- cat /mnt/secrets-store/MySecret
$ oc exec -it my-application -- cat /mnt/secrets-store/MySecretCopy to Clipboard Copied! Toggle word wrap Toggle overflow
9.5. Clean up Copy linkLink copied to clipboard!
Clean up your AWS resources after completing this lab tutorial.
Procedure
Delete the application by running the following command:
oc delete project my-application
$ oc delete project my-applicationCopy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the secrets store csi driver by running the following command:
helm delete -n csi-secrets-store csi-secrets-store-driver
$ helm delete -n csi-secrets-store csi-secrets-store-driverCopy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the security context constraints by running the following command:
oc adm policy remove-scc-from-user privileged \ system:serviceaccount:csi-secrets-store:secrets-store-csi-driver; oc adm policy remove-scc-from-user privileged \ system:serviceaccount:csi-secrets-store:csi-secrets-store-provider-aws$ oc adm policy remove-scc-from-user privileged \ system:serviceaccount:csi-secrets-store:secrets-store-csi-driver; oc adm policy remove-scc-from-user privileged \ system:serviceaccount:csi-secrets-store:csi-secrets-store-provider-awsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the AWS provider by running the following command:
oc -n csi-secrets-store delete -f \ https://raw.githubusercontent.com/rh-mobb/documentation/main/content/misc/secrets-store-csi/aws-provider-installer.yaml
$ oc -n csi-secrets-store delete -f \ https://raw.githubusercontent.com/rh-mobb/documentation/main/content/misc/secrets-store-csi/aws-provider-installer.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Delete AWS Roles and Policies by running the following command:
aws iam detach-role-policy --role-name openshift-access-to-mysecret \ --policy-arn $POLICY_ARN; aws iam delete-role --role-name openshift-access-to-mysecret; aws iam delete-policy --policy-arn $POLICY_ARN$ aws iam detach-role-policy --role-name openshift-access-to-mysecret \ --policy-arn $POLICY_ARN; aws iam delete-role --role-name openshift-access-to-mysecret; aws iam delete-policy --policy-arn $POLICY_ARNCopy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the Secrets Manager secret by running the following command:
aws secretsmanager --region $REGION delete-secret --secret-id $SECRET_ARN
$ aws secretsmanager --region $REGION delete-secret --secret-id $SECRET_ARNCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 10. Tutorial: Using AWS Controllers for Kubernetes on Red Hat OpenShift Service on AWS classic architecture Copy linkLink copied to clipboard!
AWS Controllers for Kubernetes (ACK) lets you define and use AWS service resources directly from Red Hat OpenShift Service on AWS classic architecture. 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 the software catalog. 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 software catalog of your cluster.
10.1. Prerequisites Copy linkLink copied to clipboard!
- A Red Hat OpenShift Service on AWS classic architecture cluster
-
A user account with
cluster-adminprivileges -
The OpenShift CLI (
oc) -
The Amazon Web Services (AWS) CLI (
aws)
10.2. Setting up your environment Copy linkLink copied to clipboard!
You can use environment variables to ensure consistency across the commands within this lab.
Procedure
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
10.3. Preparing your AWS Account Copy linkLink copied to clipboard!
Before using your AWS controllers, you must prepare your AWS account.
Procedure
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
AmazonS3FullAccesspolicy 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
10.4. Installing the ACK S3 Controller Copy linkLink copied to clipboard!
Use the OpenShift CLI (oc) to create a project for your ACK S3 Controller.
Procedure
Create a project to install the ACK S3 Operator into:
oc new-project ack-system
$ oc new-project ack-systemCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a file with the ACK S3 Operator configuration:
NoteACK_WATCH_NAMESPACEis 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-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install the ACK S3 Operator from the software catalog:
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}-controllerCopy 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 podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example
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 51sCopy to Clipboard Copied! Toggle word wrap Toggle overflow
10.5. Validating the deployment Copy linkLink copied to clipboard!
After installing your controller, you can verify the installation by using the OpenShift CLI (oc) tool.
Procedure
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}-bucketCopy 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-bucketCopy to Clipboard Copied! Toggle word wrap Toggle overflow
10.6. Cleaning up Copy linkLink copied to clipboard!
Clean up your AWS resources after completing this lab tutorial.
Procedure
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}-bucketCopy 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-systemproject:oc delete project ack-system
$ oc delete project ack-systemCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 11. Tutorial: Deploying the External DNS Operator on Red Hat OpenShift Service on AWS classic architecture Copy linkLink copied to clipboard!
The External DNS Operator deploys and manages ExternalDNS to provide the name resolution for services and routes from the external DNS provider, like Amazon Route 53, to Red Hat OpenShift Service on AWS classic architecture clusters. In this tutorial, we will deploy and configure the External DNS Operator with a secondary ingress controller to manage DNS records in Amazon Route 53.
The External DNS Operator does not support STS using IAM Roles for Service Accounts (IRSA) and uses long-lived Identity Access Management (IAM) credentials instead. This tutorial will be updated when the Operator supports STS.
11.1. Prerequisites Copy linkLink copied to clipboard!
A Red Hat OpenShift Service on AWS classic architecture cluster
NoteRed Hat OpenShift Service on AWS is not supported at this time.
-
A user account with
cluster-adminprivileges -
The OpenShift CLI (
oc) -
The Amazon Web Services (AWS) CLI (
aws) -
A unique domain, such as
apps.example.com - An Amazon Route 53 public hosted zone for the above domain
11.2. Setting up your environment Copy linkLink copied to clipboard!
You can use environment variables to ensure consistency across the commands within this lab.
Procedure
In your terminal, configure the following environment variables:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
apps.example.com-
Replace with the custom domain you want to use for the
IngressController.
Ensure all fields output correctly before moving to the next section:
echo "Cluster: ${CLUSTER}, Region: ${REGION}, AWS Account ID: ${AWS_ACCOUNT_ID}"$ echo "Cluster: ${CLUSTER}, Region: ${REGION}, AWS Account ID: ${AWS_ACCOUNT_ID}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe "Cluster" output from the previous command may be the name of your cluster, the internal ID of your cluster, or the cluster’s domain prefix. If you prefer to use another identifier, you can manually set this value by running the following command:
export CLUSTER=my-custom-value
$ export CLUSTER=my-custom-valueCopy to Clipboard Copied! Toggle word wrap Toggle overflow
11.3. Secondary ingress controller setup Copy linkLink copied to clipboard!
Use the following procedure to deploy a secondary ingress controller using a custom domain.
Prerequisites
-
A unique domain, such as
apps.example.com -
A wildcard or SAN TLS certificate configured with the custom domain selected above (
CN=*.apps.example.com)
Procedure
Create a new TLS secret from a private key and a public certificate, where
fullchain.pemis your full wildcard certificate chain (including any intermediaries) andprivkey.pemis your wildcard certificate’s private key:oc -n openshift-ingress create secret tls external-dns-tls --cert=fullchain.pem --key=privkey.pem
$ oc -n openshift-ingress create secret tls external-dns-tls --cert=fullchain.pem --key=privkey.pemCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new
IngressControllerresource:Copy to Clipboard Copied! Toggle word wrap Toggle overflow WarningThis
IngressControllerexample will create an internet accessible Network Load Balancer (NLB) in your AWS account. To provision an internal NLB instead, set the.spec.endpointPublishingStrategy.loadBalancer.scopeparameter toInternalbefore creating theIngressControllerresource.Verify that your custom domain IngressController has successfully created an external load balancer:
oc -n openshift-ingress get service/router-external-dns-ingress
$ oc -n openshift-ingress get service/router-external-dns-ingressCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE router-external-dns-ingress LoadBalancer 172.30.71.250 a4838bb991c6748439134ab89f132a43-aeae124077b50c01.elb.us-east-1.amazonaws.com 80:32227/TCP,443:30310/TCP 43s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE router-external-dns-ingress LoadBalancer 172.30.71.250 a4838bb991c6748439134ab89f132a43-aeae124077b50c01.elb.us-east-1.amazonaws.com 80:32227/TCP,443:30310/TCP 43sCopy to Clipboard Copied! Toggle word wrap Toggle overflow
11.4. Preparing your AWS account Copy linkLink copied to clipboard!
You need to use the aws CLI to prepare your environment to deploy the External DNS Operator.
Procedure
Retrieve the Amazon Route 53 public hosted zone ID:
export ZONE_ID=$(aws route53 list-hosted-zones-by-name --output json \ --dns-name "${DOMAIN}." --query 'HostedZones[0]'.Id --out text | sed 's/\/hostedzone\///')$ export ZONE_ID=$(aws route53 list-hosted-zones-by-name --output json \ --dns-name "${DOMAIN}." --query 'HostedZones[0]'.Id --out text | sed 's/\/hostedzone\///')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Prepare a document with the necessary DNS changes to enable DNS resolution for the canonical domain of the Ingress Controller:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The External DNS Operator uses this canonical domain as the target for CNAME records.
Submit your changes to Amazon Route 53 for propagation:
aws route53 change-resource-record-sets \ --hosted-zone-id ${ZONE_ID} \ --change-batch file://${SCRATCH}/create-cname.jsonaws route53 change-resource-record-sets \ --hosted-zone-id ${ZONE_ID} \ --change-batch file://${SCRATCH}/create-cname.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create an AWS IAM Policy document that allows the
External DNSOperator to update only the custom domain public hosted zone:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an AWS IAM user:
aws iam create-user --user-name "${CLUSTER}-external-dns-operator"$ aws iam create-user --user-name "${CLUSTER}-external-dns-operator"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Attach the policy:
aws iam attach-user-policy --user-name "${CLUSTER}-external-dns-operator" --policy-arn $POLICY_ARN$ aws iam attach-user-policy --user-name "${CLUSTER}-external-dns-operator" --policy-arn $POLICY_ARNCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThis will be changed to STS using IRSA in the future.
Create AWS keys for the IAM user:
SECRET_ACCESS_KEY=$(aws iam create-access-key --user-name "${CLUSTER}-external-dns-operator")$ SECRET_ACCESS_KEY=$(aws iam create-access-key --user-name "${CLUSTER}-external-dns-operator")Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create static credentials:
cat << EOF > "${SCRATCH}/credentials" [default] aws_access_key_id = $(echo $SECRET_ACCESS_KEY | jq -r '.AccessKey.AccessKeyId') aws_secret_access_key = $(echo $SECRET_ACCESS_KEY | jq -r '.AccessKey.SecretAccessKey') EOF$ cat << EOF > "${SCRATCH}/credentials" [default] aws_access_key_id = $(echo $SECRET_ACCESS_KEY | jq -r '.AccessKey.AccessKeyId') aws_secret_access_key = $(echo $SECRET_ACCESS_KEY | jq -r '.AccessKey.SecretAccessKey') EOFCopy to Clipboard Copied! Toggle word wrap Toggle overflow
11.5. Installing the External DNS Operator Copy linkLink copied to clipboard!
With your environment prepared and you are logged into your cluster, you can use OpenShift CLI (oc) to install the External DNS Operator from the Red Hat software catalog.
Procedure
Create a new project:
oc new-project external-dns-operator
$ oc new-project external-dns-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install the
External DNSOperator from the software catalog:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Wait until the
External DNSOperator is running:oc rollout status deploy external-dns-operator --timeout=300s
$ oc rollout status deploy external-dns-operator --timeout=300sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a secret from the AWS IAM user credentials:
oc -n external-dns-operator create secret generic external-dns \ --from-file "${SCRATCH}/credentials"$ oc -n external-dns-operator create secret generic external-dns \ --from-file "${SCRATCH}/credentials"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the
ExternalDNScontroller:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Wait until the controller is running:
oc rollout status deploy external-dns-${DOMAIN} --timeout=300s$ oc rollout status deploy external-dns-${DOMAIN} --timeout=300sCopy to Clipboard Copied! Toggle word wrap Toggle overflow
11.6. Deploying a sample application Copy linkLink copied to clipboard!
Now that the ExternalDNS controller is running, you can deploy a sample application to confirm that the custom domain is configured and trusted when you expose a new route.
Procedure
Create a new project for your sample application:
oc new-project hello-world
$ oc new-project hello-worldCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy a hello world application:
oc new-app -n hello-world --image=docker.io/openshift/hello-openshift
$ oc new-app -n hello-world --image=docker.io/openshift/hello-openshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a route for the application specifying your custom domain name:
oc -n hello-world create route edge --service=hello-openshift hello-openshift-tls \ --hostname hello-openshift.${DOMAIN}$ oc -n hello-world create route edge --service=hello-openshift hello-openshift-tls \ --hostname hello-openshift.${DOMAIN}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check if the DNS record was created automatically by ExternalDNS:
NoteIt can take a few minutes for the record to appear in Amazon Route 53.
aws route53 list-resource-record-sets --hosted-zone-id ${ZONE_ID} \ --query "ResourceRecordSets[?Type == 'CNAME']" | grep hello-openshift$ aws route53 list-resource-record-sets --hosted-zone-id ${ZONE_ID} \ --query "ResourceRecordSets[?Type == 'CNAME']" | grep hello-openshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: You can also view the TXT records that indicate they were created by ExternalDNS:
aws route53 list-resource-record-sets --hosted-zone-id ${ZONE_ID} \ --query "ResourceRecordSets[?Type == 'TXT']" | grep ${DOMAIN}$ aws route53 list-resource-record-sets --hosted-zone-id ${ZONE_ID} \ --query "ResourceRecordSets[?Type == 'TXT']" | grep ${DOMAIN}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Curl the newly created DNS record to your sample application to verify the hello world application is accessible:
curl https://hello-openshift.${DOMAIN}$ curl https://hello-openshift.${DOMAIN}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Hello OpenShift!
Hello OpenShift!Copy to Clipboard Copied! Toggle word wrap Toggle overflow
While wildcard certificates provide simplicity by securing all first-level subdomains of a given domain with a single certificate, other use cases can require the use of individual certificates per domain.
Learn how to use the cert-manager Operator for Red Hat OpenShift and Let’s Encrypt to dynamically issue certificates for routes created using a custom domain.
12.1. Prerequisites Copy linkLink copied to clipboard!
- A Red Hat OpenShift Service on AWS classic architecture cluster
-
A user account with
cluster-adminprivileges -
The OpenShift CLI (
oc) -
The Amazon Web Services (AWS) CLI (
aws) -
A unique domain, such as
*.apps.example.com - An Amazon Route 53 public hosted zone for the above domain
12.2. Setting up your environment Copy linkLink copied to clipboard!
You can use environment variables to ensure consistency across the commands within this lab.
Procedure
In your terminal, configure the following environment variables:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
DOMAIN=apps.example.com-
replace with the custom domain you want to use for the
IngressController. EMAIL=email@example.com- replace with the e-mail you want Let’s Encrypt to use to send notifications about your certificates.
Ensure all fields output correctly before moving to the next section:
echo "Cluster: ${CLUSTER}, Region: ${REGION}, OIDC Endpoint: ${OIDC_ENDPOINT}, AWS Account ID: ${AWS_ACCOUNT_ID}"$ echo "Cluster: ${CLUSTER}, Region: ${REGION}, OIDC Endpoint: ${OIDC_ENDPOINT}, AWS Account ID: ${AWS_ACCOUNT_ID}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe "Cluster" output from the previous command may be the name of your cluster, the internal ID of your cluster, or the cluster’s domain prefix. If you prefer to use another identifier, you can manually set this value by running the following command:
export CLUSTER=my-custom-value
$ export CLUSTER=my-custom-valueCopy to Clipboard Copied! Toggle word wrap Toggle overflow
12.3. Preparing your AWS account Copy linkLink copied to clipboard!
When cert-manager requests a certificate from Let’s Encrypt (or another ACME certificate issuer), Let’s Encrypt servers validate that you control the domain name in that certificate using challenges. For this tutorial, you are using a DNS-01 challenge that proves that you control the DNS for your domain name by putting a specific value in a TXT record under that domain name. This is all done automatically by cert-manager. To allow cert-manager permission to modify the Amazon Route 53 public hosted zone for your domain, you need to create an Identity Access Management (IAM) role with specific policy permissions and a trust relationship to allow access to the pod.
The public hosted zone that is used in this tutorial is in the same AWS account as the Red Hat OpenShift Service on AWS classic architecture cluster. If your public hosted zone is in a different account, a few additional steps for Cross Account Access are required.
Procedure
Retrieve the Amazon Route 53 public hosted zone ID:
NoteThis command looks for a public hosted zone that matches the custom domain you specified earlier as the
DOMAINenvironment variable. You can manually specify the Amazon Route 53 public hosted zone by runningexport ZONE_ID=<zone_ID>, replacing<zone_ID>with your specific Amazon Route 53 public hosted zone ID.export ZONE_ID=$(aws route53 list-hosted-zones-by-name --output json \ --dns-name "${DOMAIN}." --query 'HostedZones[0]'.Id --out text | sed 's/\/hostedzone\///')$ export ZONE_ID=$(aws route53 list-hosted-zones-by-name --output json \ --dns-name "${DOMAIN}." --query 'HostedZones[0]'.Id --out text | sed 's/\/hostedzone\///')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an AWS IAM policy document for the cert-manager Operator that provides the ability to update only the specified public hosted zone:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the IAM policy using the file you created in the previous step:
POLICY_ARN=$(aws iam create-policy --policy-name "${CLUSTER}-cert-manager-policy" \ --policy-document file://${SCRATCH}/cert-manager-policy.json \ --query 'Policy.Arn' --output text)$ POLICY_ARN=$(aws iam create-policy --policy-name "${CLUSTER}-cert-manager-policy" \ --policy-document file://${SCRATCH}/cert-manager-policy.json \ --query 'Policy.Arn' --output text)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an AWS IAM trust policy for the cert-manager Operator:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an IAM role for the cert-manager Operator using the trust policy you created in the previous step:
ROLE_ARN=$(aws iam create-role --role-name "${CLUSTER}-cert-manager-operator" \ --assume-role-policy-document "file://${SCRATCH}/trust-policy.json" \ --query Role.Arn --output text)$ ROLE_ARN=$(aws iam create-role --role-name "${CLUSTER}-cert-manager-operator" \ --assume-role-policy-document "file://${SCRATCH}/trust-policy.json" \ --query Role.Arn --output text)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Attach the permissions policy to the role:
aws iam attach-role-policy --role-name "${CLUSTER}-cert-manager-operator" \ --policy-arn ${POLICY_ARN}$ aws iam attach-role-policy --role-name "${CLUSTER}-cert-manager-operator" \ --policy-arn ${POLICY_ARN}Copy to Clipboard Copied! Toggle word wrap Toggle overflow
12.4. Installing the cert-manager Operator Copy linkLink copied to clipboard!
You can use the OpenShift CLI (oc) tool to install your cert-manager Operator.
Procedure
Create a project to install the cert-manager Operator into:
oc new-project cert-manager-operator
$ oc new-project cert-manager-operatorCopy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantDo not attempt to use more than one cert-manager Operator in your cluster. If you have a community cert-manager Operator installed in your cluster, you must uninstall it before installing the cert-manager Operator for Red Hat OpenShift.
Install the cert-manager Operator for Red Hat OpenShift:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIt takes a few minutes for this Operator to install and complete its set up.
Verify that the cert-manager Operator is running:
oc -n cert-manager-operator get pods
$ oc -n cert-manager-operator get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE cert-manager-operator-controller-manager-84b8799db5-gv8mx 2/2 Running 0 12s
NAME READY STATUS RESTARTS AGE cert-manager-operator-controller-manager-84b8799db5-gv8mx 2/2 Running 0 12sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Annotate the service account used by the cert-manager pods with the AWS IAM role you created earlier:
oc -n cert-manager annotate serviceaccount cert-manager eks.amazonaws.com/role-arn=${ROLE_ARN}$ oc -n cert-manager annotate serviceaccount cert-manager eks.amazonaws.com/role-arn=${ROLE_ARN}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the existing cert-manager controller pod by running the following command:
oc -n cert-manager delete pods -l app.kubernetes.io/name=cert-manager
$ oc -n cert-manager delete pods -l app.kubernetes.io/name=cert-managerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Patch the Operator’s configuration to use external nameservers to prevent DNS-01 challenge resolution issues:
oc patch certmanager.operator.openshift.io/cluster --type merge \ -p '{"spec":{"controllerConfig":{"overrideArgs":["--dns01-recursive-nameservers-only","--dns01-recursive-nameservers=1.1.1.1:53"]}}}'$ oc patch certmanager.operator.openshift.io/cluster --type merge \ -p '{"spec":{"controllerConfig":{"overrideArgs":["--dns01-recursive-nameservers-only","--dns01-recursive-nameservers=1.1.1.1:53"]}}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
ClusterIssuerresource to use Let’s Encrypt by running the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the
ClusterIssuerresource is ready:oc get clusterissuer.cert-manager.io/letsencrypt-production
$ oc get clusterissuer.cert-manager.io/letsencrypt-productionCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY AGE letsencrypt-production True 47s
NAME READY AGE letsencrypt-production True 47sCopy to Clipboard Copied! Toggle word wrap Toggle overflow
12.5. Creating a custom domain Ingress Controller Copy linkLink copied to clipboard!
You can create the custom domain Ingress Controller by using the OpenShift CLI (oc) tool.
Procedure
Create and configure a certificate resource to provision a certificate for the custom domain Ingress Controller:
NoteThe following example uses a single domain certificate. SAN and wildcard certificates are also supported.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the certificate has been issued:
NoteIt takes a few minutes for this certificate to be issued by Let’s Encrypt. If it takes longer than 5 minutes, run
oc -n openshift-ingress describe certificate.cert-manager.io/custom-domain-ingress-certto see any issues reported by cert-manager.oc -n openshift-ingress get certificate.cert-manager.io/custom-domain-ingress-cert
$ oc -n openshift-ingress get certificate.cert-manager.io/custom-domain-ingress-certCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY SECRET AGE custom-domain-ingress-cert True custom-domain-ingress-cert-tls 9m53s
NAME READY SECRET AGE custom-domain-ingress-cert True custom-domain-ingress-cert-tls 9m53sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new
IngressControllerresource:Copy to Clipboard Copied! Toggle word wrap Toggle overflow WarningThis
IngressControllerexample will create an internet accessible Network Load Balancer (NLB) in your AWS account. To provision an internal NLB instead, set the.spec.endpointPublishingStrategy.loadBalancer.scopeparameter toInternalbefore creating theIngressControllerresource.Verify that your custom domain IngressController has successfully created an external load balancer:
oc -n openshift-ingress get service/router-custom-domain-ingress
$ oc -n openshift-ingress get service/router-custom-domain-ingressCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE router-custom-domain-ingress LoadBalancer 172.30.174.34 a309962c3bd6e42c08cadb9202eca683-1f5bbb64a1f1ec65.elb.us-east-1.amazonaws.com 80:31342/TCP,443:31821/TCP 7m28s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE router-custom-domain-ingress LoadBalancer 172.30.174.34 a309962c3bd6e42c08cadb9202eca683-1f5bbb64a1f1ec65.elb.us-east-1.amazonaws.com 80:31342/TCP,443:31821/TCP 7m28sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Prepare a document with the necessary DNS changes to enable DNS resolution for your custom domain Ingress Controller:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Submit your changes to Amazon Route 53 for propagation:
aws route53 change-resource-record-sets \ --hosted-zone-id ${ZONE_ID} \ --change-batch file://${SCRATCH}/create-cname.json$ aws route53 change-resource-record-sets \ --hosted-zone-id ${ZONE_ID} \ --change-batch file://${SCRATCH}/create-cname.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteWhile the wildcard CNAME record avoids the need to create a new record for every new application you deploy using the custom domain Ingress Controller, the certificate that each of these applications use is not a wildcard certificate.
12.6. Configuring dynamic certificates for custom domain routes Copy linkLink copied to clipboard!
You can expose cluster applications on any first-level subdomains of the specified domain, but the connection will not be secured with a TLS certificate that matches the domain of the application. To ensure these cluster applications have valid certificates for each domain name, configure cert-manager to dynamically issue a certificate to every new route created under this domain.
Procedure
Create the necessary OpenShift resources cert-manager requires to manage certificates for OpenShift routes.
This step creates a new deployment (and therefore a pod) that specifically monitors annotated routes in the cluster. If the
issuer-kindandissuer-nameannotations are found in a new route, it requests the Issuer (ClusterIssuer in this case) for a new certificate that is unique to this route and which will honor the hostname that was specified while creating the route.NoteIf the cluster does not have access to GitHub, you can save the raw contents locally and run
oc apply -f localfilename.yaml -n cert-manager.oc -n cert-manager apply -f https://github.com/cert-manager/openshift-routes/releases/latest/download/cert-manager-openshift-routes.yaml
$ oc -n cert-manager apply -f https://github.com/cert-manager/openshift-routes/releases/latest/download/cert-manager-openshift-routes.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow The following additional OpenShift resources are also created in this step:
-
ClusterRole- grants permissions to watch and update the routes across the cluster -
ServiceAccount- uses permissions to run the newly created pod -
ClusterRoleBinding- binds these two resources
-
Ensure that the new
cert-manager-openshift-routespod is running successfully:oc -n cert-manager get pods
$ oc -n cert-manager get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example result
NAME READY STATUS RESTARTS AGE cert-manager-866d8f788c-9kspc 1/1 Running 0 4h21m cert-manager-cainjector-6885c585bd-znws8 1/1 Running 0 4h41m cert-manager-openshift-routes-75b6bb44cd-f8kd5 1/1 Running 0 6s cert-manager-webhook-8498785dd9-bvfdf 1/1 Running 0 4h41m
NAME READY STATUS RESTARTS AGE cert-manager-866d8f788c-9kspc 1/1 Running 0 4h21m cert-manager-cainjector-6885c585bd-znws8 1/1 Running 0 4h41m cert-manager-openshift-routes-75b6bb44cd-f8kd5 1/1 Running 0 6s cert-manager-webhook-8498785dd9-bvfdf 1/1 Running 0 4h41mCopy to Clipboard Copied! Toggle word wrap Toggle overflow
12.7. Deploying a sample application Copy linkLink copied to clipboard!
Now, that dynamic certificates are configured, you can deploy a sample application to confirm that certificates are provisioned and trusted when you expose a new route.
Procedure
Create a new project for your sample application:
oc new-project hello-world
$ oc new-project hello-worldCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy a hello world application:
oc -n hello-world new-app --image=docker.io/openshift/hello-openshift
$ oc -n hello-world new-app --image=docker.io/openshift/hello-openshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a route to expose the application from outside the cluster:
oc -n hello-world create route edge --service=hello-openshift hello-openshift-tls --hostname hello.${DOMAIN}$ oc -n hello-world create route edge --service=hello-openshift hello-openshift-tls --hostname hello.${DOMAIN}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the certificate for the route is untrusted:
curl -I https://hello.${DOMAIN}$ curl -I https://hello.${DOMAIN}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Annotate the route to trigger cert-manager to provision a certificate for the custom domain:
oc -n hello-world annotate route hello-openshift-tls cert-manager.io/issuer-kind=ClusterIssuer cert-manager.io/issuer-name=letsencrypt-production
$ oc -n hello-world annotate route hello-openshift-tls cert-manager.io/issuer-kind=ClusterIssuer cert-manager.io/issuer-name=letsencrypt-productionCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIt takes 2-3 minutes for the certificate to be created. The renewal of the certificate will automatically be managed by the cert-manager Operator as it approaches expiration.
Verify the certificate for the route is now trusted:
curl -I https://hello.${DOMAIN}$ curl -I https://hello.${DOMAIN}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
12.8. Troubleshooting dynamic certificate provisioning Copy linkLink copied to clipboard!
The validation process usually takes 2-3 minutes to complete while creating certificates.
If annotating your route does not trigger certificate creation during the certificate create step, run oc describe against each of the certificate,certificaterequest,order, and challenge resources to view the events or reasons that can help identify the cause of the issue.
Procedure
Run the following command to trigger certificate creation:
oc get certificate,certificaterequest,order,challenge
$ oc get certificate,certificaterequest,order,challengeCopy to Clipboard Copied! Toggle word wrap Toggle overflow For troubleshooting, you can refer to this helpful guide in debugging certificates.
You can also use the cmctl CLI tool for various certificate management activities, such as checking the status of certificates and testing renewals.
Chapter 13. Tutorial: Assigning a consistent egress IP for external traffic Copy linkLink copied to clipboard!
This tutorial teaches you how to configure a set of predictable IP addresses for egress cluster traffic. You can assign a consistent IP address for traffic that leaves your cluster such as security groups which require an IP-based configuration to meet security standards.
By default, Red Hat OpenShift Service on AWS classic architecture uses the OVN-Kubernetes container network interface (CNI) to assign random IP addresses from a pool. This can make configuring security lockdowns unpredictable or open.
See Configuring an egress IP address for more information.
13.1. Prerequisites Copy linkLink copied to clipboard!
- A Red Hat OpenShift Service on AWS classic architecture cluster deployed with OVN-Kubernetes
-
The OpenShift CLI (
oc) -
The ROSA CLI (
rosa) -
jq
13.2. Setting your environment variables Copy linkLink copied to clipboard!
You may set environment variables to make it easier to reuse values.
Procedure
Set your environment variables by running the following command:
NoteReplace the value of the
ROSA_MACHINE_POOL_NAMEvariable to target a different machine pool.export ROSA_CLUSTER_NAME=$(oc get infrastructure cluster -o=jsonpath="{.status.infrastructureName}" | sed 's/-[a-z0-9]\{5\}$//') export ROSA_MACHINE_POOL_NAME=worker$ export ROSA_CLUSTER_NAME=$(oc get infrastructure cluster -o=jsonpath="{.status.infrastructureName}" | sed 's/-[a-z0-9]\{5\}$//') $ export ROSA_MACHINE_POOL_NAME=workerCopy to Clipboard Copied! Toggle word wrap Toggle overflow
13.3. Ensuring capacity Copy linkLink copied to clipboard!
The number of IP addresses assigned to each node is limited for each public cloud provider.
Procedure
Verify sufficient capacity by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.4. Creating the egress IP rules Copy linkLink copied to clipboard!
Before creating the egress IP rules, identify which egress IPs you will use.
The egress IPs that you select should exist as a part of the subnets in which the worker nodes are provisioned.
Procedure
Reserve the egress IPs that you requested to avoid conflicts with the AWS Virtual Private Cloud (VPC) Dynamic Host Configuration Protocol (DHCP) service.
Request explicit IP reservations on the AWS documentation for CIDR reservations page.
13.5. Assigning an egress IP to a namespace Copy linkLink copied to clipboard!
You can assign an egress IP to a namespace on your cluster by using the OpenShift CLI (oc) tool.
Procedure
Create a new project by running the following command:
oc new-project demo-egress-ns
$ oc new-project demo-egress-nsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the egress rule for all pods within the namespace by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.6. Assigning an egress IP to a pod Copy linkLink copied to clipboard!
Create an egress rule to assign an egress IP to a specified pod.
Procedure
Create a new project by running the following command:
oc new-project demo-egress-pod
$ oc new-project demo-egress-podCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the egress rule for the pod by running the following command:
Notespec.namespaceSelectoris a mandatory field.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.6.1. Labeling the nodes Copy linkLink copied to clipboard!
You can label your nodes by using the OpenShift CLI (oc) tool.
Procedure
Obtain your pending egress IP assignments by running the following command:
oc get egressips
$ oc get egressipsCopy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
NAME EGRESSIPS ASSIGNED NODE ASSIGNED EGRESSIPS demo-egress-ns 10.10.100.253 demo-egress-pod 10.10.100.254
NAME EGRESSIPS ASSIGNED NODE ASSIGNED EGRESSIPS demo-egress-ns 10.10.100.253 demo-egress-pod 10.10.100.254Copy to Clipboard Copied! Toggle word wrap Toggle overflow The egress IP rule that you created only applies to nodes with the
k8s.ovn.org/egress-assignablelabel. Make sure that the label is only on a specific machine pool.Assign the label to your machine pool using the following command:
WarningIf you rely on node labels for your machine pool, this command will replace those labels. Be sure to input your desired labels into the
--labelsfield to ensure your node labels remain.rosa update machinepool ${ROSA_MACHINE_POOL_NAME} \ --cluster="${ROSA_CLUSTER_NAME}" \ --labels "k8s.ovn.org/egress-assignable="$ rosa update machinepool ${ROSA_MACHINE_POOL_NAME} \ --cluster="${ROSA_CLUSTER_NAME}" \ --labels "k8s.ovn.org/egress-assignable="Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.6.2. Reviewing the egress IPs Copy linkLink copied to clipboard!
You can list all of the egress IPs by using OpenShift CLI (oc) tool.
Procedure
Review the egress IP assignments by running the following command:
oc get egressips
$ oc get egressipsCopy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
NAME EGRESSIPS ASSIGNED NODE ASSIGNED EGRESSIPS demo-egress-ns 10.10.100.253 ip-10-10-156-122.ec2.internal 10.10.150.253 demo-egress-pod 10.10.100.254 ip-10-10-156-122.ec2.internal 10.10.150.254
NAME EGRESSIPS ASSIGNED NODE ASSIGNED EGRESSIPS demo-egress-ns 10.10.100.253 ip-10-10-156-122.ec2.internal 10.10.150.253 demo-egress-pod 10.10.100.254 ip-10-10-156-122.ec2.internal 10.10.150.254Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.6.3. Deploying a sample application Copy linkLink copied to clipboard!
To test the egress IP rule, create a service that is restricted to the egress IP addresses which we have specified. This simulates an external service that is expecting a small subset of IP addresses.
Procedure
Run the
echoservercommand to replicate a request:oc -n default run demo-service --image=gcr.io/google_containers/echoserver:1.4
$ oc -n default run demo-service --image=gcr.io/google_containers/echoserver:1.4Copy to Clipboard Copied! Toggle word wrap Toggle overflow Expose the pod as a service and limit the ingress to the egress IP addresses you specified by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the load balancer hostname and save it as an environment variable by running the following command:
export LOAD_BALANCER_HOSTNAME=$(oc get svc -n default demo-service -o json | jq -r '.status.loadBalancer.ingress[].hostname')
$ export LOAD_BALANCER_HOSTNAME=$(oc get svc -n default demo-service -o json | jq -r '.status.loadBalancer.ingress[].hostname')Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.6.4. Testing the namespace egress Copy linkLink copied to clipboard!
You can test the namespace egress by using the OpenShift CLI (oc) tool.
Procedure
Start an interactive shell to test the namespace egress rule:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Send a request to the load balancer and ensure that you can successfully connect:
curl -s http://$LOAD_BALANCER_HOSTNAME
$ curl -s http://$LOAD_BALANCER_HOSTNAMECopy to Clipboard Copied! Toggle word wrap Toggle overflow Check the output for a successful connection:
NoteThe
client_addressis the internal IP address of the load balancer not your egress IP. You can verify that you have configured the client address correctly by connecting with your service limited to.spec.loadBalancerSourceRanges.For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Exit the pod by running the following command:
exit
$ exitCopy to Clipboard Copied! Toggle word wrap Toggle overflow
13.6.5. Testing the pod egress Copy linkLink copied to clipboard!
You can test your pod’s egress by using the OpenShift CLI (oc) tool.
Procedure
Start an interactive shell to test the pod egress rule:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Send a request to the load balancer by running the following command:
curl -s http://$LOAD_BALANCER_HOSTNAME
$ curl -s http://$LOAD_BALANCER_HOSTNAMECopy to Clipboard Copied! Toggle word wrap Toggle overflow Check the output for a successful connection:
NoteThe
client_addressis the internal IP address of the load balancer not your egress IP. You can verify that you have configured the client address correctly by connecting with your service limited to.spec.loadBalancerSourceRanges.For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Exit the pod by running the following command:
exit
$ exitCopy to Clipboard Copied! Toggle word wrap Toggle overflow
13.6.6. Optional: Testing blocked egress Copy linkLink copied to clipboard!
You can test if the egress is blocked by using OpenShift CLI (oc) tool.
Procedure
Test that the traffic is successfully blocked when the egress rules do not apply by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Send a request to the load balancer by running the following command:
curl -s http://$LOAD_BALANCER_HOSTNAME
$ curl -s http://$LOAD_BALANCER_HOSTNAMECopy to Clipboard Copied! Toggle word wrap Toggle overflow - If the command is unsuccessful, egress is successfully blocked.
Exit the pod by running the following command:
exit
$ exitCopy to Clipboard Copied! Toggle word wrap Toggle overflow
13.7. Cleaning up your cluster Copy linkLink copied to clipboard!
Before moving to a different tutorial, you can clean up your cluster environment with a few commands.
Procedure
Clean up your cluster by running the following commands:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Clean up the assigned node labels by running the following command:
WarningIf you rely on node labels for your machine pool, this command replaces those labels. Input your desired labels into the
--labelsfield to ensure your node labels remain.rosa update machinepool ${ROSA_MACHINE_POOL_NAME} \ --cluster="${ROSA_CLUSTER_NAME}" \ --labels ""$ rosa update machinepool ${ROSA_MACHINE_POOL_NAME} \ --cluster="${ROSA_CLUSTER_NAME}" \ --labels ""Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 14. Tutorial: Updating component routes with custom domains and TLS certificates Copy linkLink copied to clipboard!
This guide demonstrates how to modify the hostname and TLS certificate of the Web console, OAuth server, and Downloads component routes in Red Hat OpenShift Service on AWS classic architecture version 4.14 and above.{fn-supported-versions}
The changes that we make to the component routes{fn-term-component-routes} in this guide are described in greater detail in the customizing the internal OAuth server URL, console route, and download route OpenShift Container Platform documentation.
14.1. Prerequisites Copy linkLink copied to clipboard!
-
ROSA CLI (
rosa) version 1.2.37 or higher -
AWS CLI (
aws) A Red Hat OpenShift Service on AWS classic architecture cluster version 4.14 or higher
NoteRed Hat OpenShift Service on AWS is not supported at this time.
-
OpenShift CLI (
oc) -
jqCLI -
Access to the cluster as a user with the
cluster-adminrole. - OpenSSL (for generating the demonstration SSL/TLS certificates)
14.2. Setting up your environment Copy linkLink copied to clipboard!
You can use environment variables to ensure consistency across the commands within this lab.
Procedure
-
Log in to your cluster using an account with
cluster-adminprivileges. Configure an environment variable for your cluster name:
export CLUSTER_NAME=$(oc get infrastructure cluster -o=jsonpath="{.status.infrastructureName}" | sed 's/-[a-z0-9]\{5\}$//')$ export CLUSTER_NAME=$(oc get infrastructure cluster -o=jsonpath="{.status.infrastructureName}" | sed 's/-[a-z0-9]\{5\}$//')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure all fields output correctly before moving to the next section:
echo "Cluster: ${CLUSTER_NAME}"$ echo "Cluster: ${CLUSTER_NAME}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Cluster: my-rosa-cluster
Cluster: my-rosa-clusterCopy to Clipboard Copied! Toggle word wrap Toggle overflow
14.3. Find the current routes Copy linkLink copied to clipboard!
You need to use the OpenShift CLI (oc) tool to find the base hostname of your cluster routes.
Procedure
Verify that you can reach the component routes on their default hostnames.
You can find the hostnames by querying the lists of routes in the
openshift-consoleandopenshift-authenticationprojects.oc get routes -n openshift-console oc get routes -n openshift-authentication
$ oc get routes -n openshift-console $ oc get routes -n openshift-authenticationCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD console console-openshift-console.apps.my-example-cluster-aws.z9a9.p1.openshiftapps.com ... 1 more console https reencrypt/Redirect None downloads downloads-openshift-console.apps.my-example-cluster-aws.z9a9.p1.openshiftapps.com ... 1 more downloads http edge/Redirect None NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD oauth-openshift oauth-openshift.apps.my-example-cluster-aws.z9a9.p1.openshiftapps.com ... 1 more oauth-openshift 6443 passthrough/Redirect None
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD console console-openshift-console.apps.my-example-cluster-aws.z9a9.p1.openshiftapps.com ... 1 more console https reencrypt/Redirect None downloads downloads-openshift-console.apps.my-example-cluster-aws.z9a9.p1.openshiftapps.com ... 1 more downloads http edge/Redirect None NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD oauth-openshift oauth-openshift.apps.my-example-cluster-aws.z9a9.p1.openshiftapps.com ... 1 more oauth-openshift 6443 passthrough/Redirect NoneCopy to Clipboard Copied! Toggle word wrap Toggle overflow From this output you can see that our base hostname is
z9a9.p1.openshiftapps.com.Get the ID of the default ingress by running the following command:
export INGRESS_ID=$(rosa list ingress -c ${CLUSTER_NAME} -o json | jq -r '.[] | select(.default == true) | .id')$ export INGRESS_ID=$(rosa list ingress -c ${CLUSTER_NAME} -o json | jq -r '.[] | select(.default == true) | .id')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure all fields output correctly before moving to the next section:
echo "Ingress ID: ${INGRESS_ID}"$ echo "Ingress ID: ${INGRESS_ID}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Ingress ID: r3l6
Ingress ID: r3l6Copy to Clipboard Copied! Toggle word wrap Toggle overflow By running these commands you can see that the default component routes for our cluster are:
-
console-openshift-console.apps.my-example-cluster-aws.z9a9.p1.openshiftapps.comfor Console -
downloads-openshift-console.apps.my-example-cluster-aws.z9a9.p1.openshiftapps.comfor Downloads oauth-openshift.apps.my-example-cluster-aws.z9a9.p1.openshiftapps.comfor OAuthWe can use the
rosa edit ingresscommand to change the hostname of each service and add a TLS certificate for all of our component routes. The relevant parameters are shown in this excerpt of the command-line help for therosa edit ingresscommand:rosa edit ingress -h Edit a cluster ingress for a cluster. Usage: rosa edit ingress ID [flags] [...] --component-routes string Component routes settings. Available keys [oauth, console, downloads]. For each key a pair of hostname and tlsSecretRef is expected to be supplied. Format should be a comma separate list 'oauth: hostname=example-hostname;tlsSecretRef=example-secret-ref,downloads:...'
$ rosa edit ingress -h Edit a cluster ingress for a cluster. Usage: rosa edit ingress ID [flags] [...] --component-routes string Component routes settings. Available keys [oauth, console, downloads]. For each key a pair of hostname and tlsSecretRef is expected to be supplied. Format should be a comma separate list 'oauth: hostname=example-hostname;tlsSecretRef=example-secret-ref,downloads:...'Copy to Clipboard Copied! Toggle word wrap Toggle overflow For this example, we’ll use the following custom component routes:
-
console.my-new-domain.devfor Console -
downloads.my-new-domain.devfor Downloads -
oauth.my-new-domain.devfor OAuth
-
14.4. Create a valid TLS certificate for each component route Copy linkLink copied to clipboard!
In this section, we create three separate self-signed certificate key pairs and then trust them to verify that we can access our new component routes using a real web browser.
This is for demonstration purposes only, and is not recommended as a solution for production workloads. Consult your certificate authority to understand how to create certificates with similar attributes for your production workloads.
To prevent issues with HTTP/2 connection coalescing, you must use a separate individual certificate for each endpoint. Using a wildcard or SAN certificate is not supported.
Procedure
Generate a certificate for each component route, taking care to set our certificate’s subject (
-subj) to the custom domain of the component route we want to use:Example:
openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout key-console.pem -out cert-console.pem -subj "/CN=console.my-new-domain.dev" openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout key-downloads.pem -out cert-downloads.pem -subj "/CN=downloads.my-new-domain.dev" openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout key-oauth.pem -out cert-oauth.pem -subj "/CN=oauth.my-new-domain.dev"
$ openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout key-console.pem -out cert-console.pem -subj "/CN=console.my-new-domain.dev" $ openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout key-downloads.pem -out cert-downloads.pem -subj "/CN=downloads.my-new-domain.dev" $ openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout key-oauth.pem -out cert-oauth.pem -subj "/CN=oauth.my-new-domain.dev"Copy to Clipboard Copied! Toggle word wrap Toggle overflow This generates three pairs of
.pemfiles,key-<component>.pemandcert-<component>.pem.
14.5. Add the certificates to the cluster as secrets Copy linkLink copied to clipboard!
You can use the OpenShift CLI (oc) tool to add the certificates to your created cluster as secrets.
Procedure
Create three TLS secrets in the
openshift-confignamespace.These become your secret reference when you update the component routes later in this guide.
oc create secret tls console-tls --cert=cert-console.pem --key=key-console.pem -n openshift-config oc create secret tls downloads-tls --cert=cert-downloads.pem --key=key-downloads.pem -n openshift-config oc create secret tls oauth-tls --cert=cert-oauth.pem --key=key-oauth.pem -n openshift-config
$ oc create secret tls console-tls --cert=cert-console.pem --key=key-console.pem -n openshift-config $ oc create secret tls downloads-tls --cert=cert-downloads.pem --key=key-downloads.pem -n openshift-config $ oc create secret tls oauth-tls --cert=cert-oauth.pem --key=key-oauth.pem -n openshift-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow
14.6. Find the hostname of the load balancer in your cluster Copy linkLink copied to clipboard!
When you create a cluster, the service creates a load balancer and generates a hostname for that load balancer. We need to know the load balancer hostname in order to create DNS records for our cluster. You can find the hostname by using the OpenShift CLI (oc) tool.
Procedure
Run the following command against the
openshift-ingressnamespace.oc get svc -n openshift-ingress NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE router-default LoadBalancer 172.30.237.88 a234gsr3242rsfsfs-1342r624.us-east-1.elb.amazonaws.com 80:31175/TCP,443:31554/TCP 76d
$ oc get svc -n openshift-ingress NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE router-default LoadBalancer 172.30.237.88 a234gsr3242rsfsfs-1342r624.us-east-1.elb.amazonaws.com 80:31175/TCP,443:31554/TCP 76dCopy to Clipboard Copied! Toggle word wrap Toggle overflow The hostname of the load balancer is the
EXTERNAL-IPassociated with therouter-defaultservice in theopenshift-ingressnamespace. In our case, the hostname isa234gsr3242rsfsfs-1342r624.us-east-1.elb.amazonaws.com.Save this value for later, as we will need it to configure DNS records for our new component route hostnames.
14.7. Add component route DNS records to your hosting provider Copy linkLink copied to clipboard!
In your hosting provider, add DNS records that map the CNAME of your new component route hostnames to the load balancer hostname we found in the previous step.
14.8. Update the component routes and TLS secret using the ROSA CLI Copy linkLink copied to clipboard!
When your DNS records have been updated, you can use the ROSA CLI to change the component routes.
Procedure
Use the
rosa edit ingresscommand to update your default ingress route with the new base domain and the secret reference associated with it, taking care to update the hostnames for each component route.rosa edit ingress -c ${CLUSTER_NAME} ${INGRESS_ID} --component-routes 'console: hostname=console.my-new-domain.dev;tlsSecretRef=console-tls,downloads: hostname=downloads.my-new-domain.dev;tlsSecretRef=downloads-tls,oauth: hostname=oauth.my-new-domain.dev;tlsSecretRef=oauth-tls'$ rosa edit ingress -c ${CLUSTER_NAME} ${INGRESS_ID} --component-routes 'console: hostname=console.my-new-domain.dev;tlsSecretRef=console-tls,downloads: hostname=downloads.my-new-domain.dev;tlsSecretRef=downloads-tls,oauth: hostname=oauth.my-new-domain.dev;tlsSecretRef=oauth-tls'Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can also edit only a subset of the component routes by leaving the component routes you do not want to change set to an empty string. For example, if you only want to change the Console and OAuth server hostnames and TLS certificates, you would run the following command:
rosa edit ingress -c ${CLUSTER_NAME} ${INGRESS_ID} --component-routes 'console: hostname=console.my-new-domain.dev;tlsSecretRef=console-tls,downloads: hostname="";tlsSecretRef="", oauth: hostname=oauth.my-new-domain.dev;tlsSecretRef=oauth-tls'$ rosa edit ingress -c ${CLUSTER_NAME} ${INGRESS_ID} --component-routes 'console: hostname=console.my-new-domain.dev;tlsSecretRef=console-tls,downloads: hostname="";tlsSecretRef="", oauth: hostname=oauth.my-new-domain.dev;tlsSecretRef=oauth-tls'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the
rosa list ingresscommand to verify that your changes were successfully made:rosa list ingress -c ${CLUSTER_NAME} -ojson | jq ".[] | select(.id == \"${INGRESS_ID}\") | .component_routes"$ rosa list ingress -c ${CLUSTER_NAME} -ojson | jq ".[] | select(.id == \"${INGRESS_ID}\") | .component_routes"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add your certificate to the truststore on your local system, then confirm that you can access your components at their new routes using your local web browser.
14.9. Reset the component routes to the default using the ROSA CLI Copy linkLink copied to clipboard!
You can use the OpenShift CLI (oc) tool to to reset the component routes to the default configuration.
Procedure
Run the following command to reset your component routes:
rosa edit ingress -c ${CLUSTER_NAME} ${INGRESS_ID} --component-routes 'console: hostname="";tlsSecretRef="",downloads: hostname="";tlsSecretRef="", oauth: hostname="";tlsSecretRef=""'$ rosa edit ingress -c ${CLUSTER_NAME} ${INGRESS_ID} --component-routes 'console: hostname="";tlsSecretRef="",downloads: hostname="";tlsSecretRef="", oauth: hostname="";tlsSecretRef=""'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 15. Getting started with ROSA classic architecture Copy linkLink copied to clipboard!
15.1. Tutorial: What is ROSA Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS (ROSA) is a fully-managed turnkey application platform that allows you to focus on what matters most, delivering value to your customers by building and deploying applications. Red Hat and AWS SRE experts manage the underlying platform so you do not have to worry about infrastructure management. ROSA provides seamless integration with a wide range of AWS compute, database, analytics, machine learning, networking, mobile, and other services to further accelerate the building and delivering of differentiating experiences to your customers.
ROSA makes use of AWS Security Token Service (STS) to obtain credentials to manage infrastructure in your AWS account. AWS STS is a global web service that creates temporary credentials for IAM users or federated users. ROSA uses this to assign short-term, limited-privilege, security credentials. These credentials are associated with IAM roles that are specific to each component that makes AWS API calls. This method aligns with the principals of least privilege and secure practices in cloud service resource management. The ROSA command-line interface (CLI) tool manages the STS credentials that are assigned for unique tasks and takes action on AWS resources as part of OpenShift functionality.
15.1.1. Key features of Red Hat OpenShift Service on AWS classic architecture Copy linkLink copied to clipboard!
The following sections show the key features of using Red Hat OpenShift Service on AWS classic architecture. Red Hat OpenShift Service on AWS classic architecture clusters also offer:
- Native AWS service: Access and use Red Hat OpenShift on-demand with a self-service onboarding experience through the AWS management console.
- Flexible, consumption-based pricing: Scale to your business needs and pay as you go with flexible pricing and an on-demand hourly or annual billing model.
- Single bill for Red Hat OpenShift and AWS usage: Customers will receive a single bill from AWS for both Red Hat OpenShift and AWS consumption.
- Fully integrated support experience: Installation, management, maintenance, and upgrades are performed by Red Hat site reliability engineers (SREs) with joint Red Hat and Amazon support and a 99.95% service-level agreement (SLA).
- AWS service integration: AWS has a robust portfolio of cloud services, such as compute, storage, networking, database, analytics, and machine learning. All of these services are directly accessible through Red Hat OpenShift Service on AWS classic architecture. This makes it easier to build, operate, and scale globally and on-demand through a familiar management interface.
- Maximum Availability: Deploy clusters across multiple availability zones in supported regions to maximize availability and maintain high availability for your most demanding mission-critical applications and data.
- Cluster node scaling: Easily add or remove compute nodes to match resource demand.
- Optimized clusters: Choose from memory-optimized, compute-optimized, or general purpose EC2 instance types with clusters sized to meet your needs.
- Global availability: Refer to the Additional Resources for information on availability regions.
15.1.1.1. Red Hat OpenShift Service on AWS classic architecture and Kubernetes Copy linkLink copied to clipboard!
In Red Hat OpenShift Service on AWS classic architecture, everything you need to deploy and manage containers is bundled, including container management, Operators, networking, load balancing, service mesh, CI/CD, firewall, monitoring, registry, authentication, and authorization capabilities. These components are tested together for unified operations as a complete platform. Automated cluster operations, including over-the-air platform upgrades, further enhance your Kubernetes experience.
15.1.1.2. Basic responsibilities Copy linkLink copied to clipboard!
In general, cluster deployment and upkeep is Red Hat’s or AWS’s responsibility, while applications, users, and data is the customer’s responsibility.
15.1.1.3. Roadmap and feature requests Copy linkLink copied to clipboard!
Visit the Red Hat OpenShift Service on AWS classic architecture roadmap to stay up-to-date with the status of features currently in development. Open a new issue if you have any suggestions for the product team.
15.1.1.4. AWS region availability Copy linkLink copied to clipboard!
See the Additional Resources for the product regional availability page for an up-to-date view of where Red Hat OpenShift Service on AWS classic architecture is available.
15.1.1.5. Compliance certifications Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture is currently compliant with SOC-2 type 2, SOC 3, ISO-27001, ISO 27017, ISO 27018, HIPAA, GDPR, and PCI-DSS. We are also currently working towards FedRAMP High.
15.1.1.6. Administrators Copy linkLink copied to clipboard!
A Red Hat OpenShift Service on AWS classic architecture customer’s administrator can manage users and quotas in addition to accessing all user-created projects.
15.1.1.7. OpenShift versions and upgrades Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture is a managed service which is based on OpenShift Container Platform. You can view the current version and life cycle dates in the Additional resources.
Customers can upgrade to the newest version of OpenShift and use the features from that version of OpenShift. Not all OpenShift features are be available on Red Hat OpenShift Service on AWS classic architecture. See the Service Definition page in the Additional resources for more information.
15.1.1.8. Nodes Copy linkLink copied to clipboard!
The following covers the various aspects about Red Hat OpenShift Service on AWS classic architecture cluster nodes, including worker node requirements, operating system, supported instances, and scaling capabilities.
15.1.1.8.1. Worker nodes across multiple AWS regions Copy linkLink copied to clipboard!
All nodes in a Red Hat OpenShift Service on AWS classic architecture cluster must be located in the same AWS region. For clusters configured for multiple availability zones, control plane nodes and worker nodes will be distributed across the availability zones.
15.1.1.8.2. Minimum number of worker nodes Copy linkLink copied to clipboard!
For a Red Hat OpenShift Service on AWS classic architecture cluster, the minimum is 2 worker nodes for single availability zone and 3 worker nodes for multiple availability zones.
15.1.1.8.3. Underlying node operating system Copy linkLink copied to clipboard!
As with all OpenShift v4.x offerings, the control plane, infra and worker nodes run Red Hat Enterprise Linux CoreOS (RHCOS).
15.1.1.8.4. Node hibernation or shut-down Copy linkLink copied to clipboard!
At this time, Red Hat OpenShift Service on AWS classic architecture does not have a hibernation or shut-down feature for nodes. The shutdown and hibernation feature is an OpenShift platform feature that is not yet mature enough for widespread cloud services use.
15.1.1.8.5. Supported instances for worker nodes Copy linkLink copied to clipboard!
For a complete list of supported instances for worker nodes see the Additional Resources for the AWS instance types. Spot instances are also supported.
15.1.1.8.6. Node autoscaling Copy linkLink copied to clipboard!
Autoscaling allows you to automatically adjust the size of the cluster based on the current workload.
15.1.1.8.7. Maximum number of worker nodes Copy linkLink copied to clipboard!
The maximum number of worker nodes in Red Hat OpenShift Service on AWS classic architecture clusters versions 4.14.14 and later is 249. For earlier versions, the limit is 180 nodes.
15.1.2. Support Copy linkLink copied to clipboard!
You can open a ticket directly from the OpenShift Cluster Manager or visit the Red Hat Customer Portal to search or browse through the Red Hat knowledge base of articles and solutions relating to Red Hat products or submit a support case to Red Hat Support.
You can open a ticket directly from the OpenShift Cluster Manager.
You can also visit the Red Hat Customer Portal to search or browse through the Red Hat knowledge base of articles and solutions relating to Red Hat products or submit a support case to Red Hat Support.
15.1.2.1. Limited support Copy linkLink copied to clipboard!
If a Red Hat OpenShift Service on AWS classic architecture cluster is not upgraded before the "end of life" date, the cluster continues to operate in a limited support status. The SLA for that cluster will no longer be applicable, but you can still get support for that cluster.
Additional support resources:
- Red Hat Support
AWS support customers must have a valid AWS support contract.
15.1.3. Service-level agreement (SLA) Copy linkLink copied to clipboard!
See the Additional resources for the Red Hat OpenShift Service on AWS classic architecture service-level agreement.
See the Additional resources for the Red Hat OpenShift Service on AWS classic architecture service-level agreement.
15.1.3.1. Notifications and communication Copy linkLink copied to clipboard!
Red Hat will provide notifications regarding new Red Hat and AWS features, updates, and scheduled maintenance through email and the Hybrid Cloud Console service log.
15.1.3.2. Open Service Broker for AWS (OBSA) Copy linkLink copied to clipboard!
You can use OSBA with Red Hat OpenShift Service on AWS classic architecture. However, the preferred method is the more recent AWS Controller for Kubernetes. See Open Service Broker for AWS for more information on OSBA.
15.1.3.3. Offboarding Copy linkLink copied to clipboard!
Customers can stop using Red Hat OpenShift Service on AWS classic architecture at any time and move their applications to on-premise, a private cloud, or other cloud providers. Standard reserved instances (RI) policy applies for unused RI.
15.1.3.4. Authentication Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture supports the following authentication mechanisms: OpenID Connect (a profile of OAuth2), Google OAuth, GitHub OAuth, GitLab, and LDAP.
15.1.3.5. SRE cluster access Copy linkLink copied to clipboard!
All SRE cluster access is secured by MFA.
15.1.4. Encryption Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture uses encryption keys stored in KMS to encrypt EBS volumes, with options for customer-provided keys, data encryption at rest, and etcd encryption.
15.1.4.1. Encryption keys Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture uses a key stored in KMS to encrypt EBS volumes. Customers also have the option to provide their own KMS keys at cluster creation.
15.1.4.2. KMS keys Copy linkLink copied to clipboard!
If you specify a KMS key, the control plane, infrastructure and worker node root volumes and the persistent volumes are encrypted with the key.
15.1.4.3. Data encryption Copy linkLink copied to clipboard!
By default, there is encryption at rest. The AWS Storage platform automatically encrypts your data before persisting it and decrypts the data before retrieval. See AWS EBS Encryption for more details.
You can also encrypt etcd in the cluster, combining it with AWS storage encryption. This results in double the encryption which adds up to a 20% performance hit.
15.1.4.4. etcd encryption Copy linkLink copied to clipboard!
etcd encryption can only be enabled at cluster creation.
etcd encryption incurs additional overhead with negligible security risk mitigation.
15.1.4.5. etcd encryption configuration Copy linkLink copied to clipboard!
etcd encryption is configured the same as in OpenShift Container Platform. The aescbc cypher is used and the setting is patched during cluster deployment. For more details, see the Kubernetes documentation.
15.1.4.6. Multi-region KMS keys for EBS encryption Copy linkLink copied to clipboard!
Currently, the ROSA CLI does not accept multi-region KMS keys for EBS encryption. This feature is in our backlog for product updates. The ROSA CLI accepts single region KMS keys for EBS encryption if it is defined at cluster creation.
15.1.5. Infrastructure Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture uses several different cloud services such as virtual machines, storage, and load balancers. This section covers infrastructure components, credential methods, storage, networking, monitoring, and other infrastructure-related features.
15.1.5.1. Infrastructure Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture uses several different cloud services such as virtual machines, storage, and load balancers. You can see a defined list on the AWS prerequisites page in the Additional resources.
15.1.5.2. Credential methods Copy linkLink copied to clipboard!
There are two credential methods to grant Red Hat the permissions needed to perform the required actions in your AWS account: AWS with STS or an IAM user with admin permissions. AWS with STS is the preferred method, and the IAM user method will eventually be deprecated. AWS with STS better aligns with the principles of least privilege and secure practices in cloud service resource management.
15.1.5.3. Prerequisite permission or failure errors Copy linkLink copied to clipboard!
Check for a newer version of the ROSA CLI. Every release of the ROSA CLI is located in two places: Github and the Red Hat signed binary releases.
15.1.5.4. Storage Copy linkLink copied to clipboard!
See the Additional resources for the Storage documentation. OpenShift includes the CSI driver for AWS EFS.
15.1.5.5. Using a VPC Copy linkLink copied to clipboard!
At installation you can select to deploy to an existing VPC or bring your own VPC. You can then select the required subnets and provide a valid CIDR range that encompasses the subnets for the installation program when using those subnets.
Red Hat OpenShift Service on AWS classic architecture allows multiple clusters to share the same VPC. The number of clusters on one VPC is limited by the remaining AWS resource quota and CIDR ranges that cannot overlap.
15.1.5.6. Network plugin Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture uses the OpenShift OVN-Kubernetes default CNI network provider.
15.1.5.7. Cross-namespace networking Copy linkLink copied to clipboard!
Cluster admins can customize, and deny, cross-namespace on a project basis using NetworkPolicy objects. Refer to for more information.
15.1.5.8. Using Prometheus and Grafana Copy linkLink copied to clipboard!
You can use Prometheus and Grafana to monitor containers and manage capacity using OpenShift User Workload Monitoring. This is a check-box option in the OpenShift Cluster Manager.
15.1.5.9. Audit logs output from the cluster control-plane Copy linkLink copied to clipboard!
If the Cluster Logging Operator Add-on has been added to the cluster then audit logs are available through CloudWatch. If it has not, then a support request would allow you to request some audit logs. Small targeted and time-boxed logs can be requested for export and sent to a customer. The selection of audit logs available are at the discretion of SRE in the category of platform security and compliance. Requests for exports of a cluster’s entirety of logs will be rejected.
15.1.5.10. AWS Permissions Boundary Copy linkLink copied to clipboard!
You can use an AWS Permissions Boundary around the policies for your cluster.
15.1.5.11. AMI Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture worker nodes use a different AMI from OSD and OpenShift Container Platform. Control Plane and Infra node AMIs are common across products in the same version.
15.1.5.12. Cluster backups Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture STS clusters do not have backups. Users must have their own backup policies for applications and data.
15.1.5.13. Custom domain Copy linkLink copied to clipboard!
You can define a custom domain for your applications.
15.1.5.14. Red Hat OpenShift Service on AWS classic architecture domain certificates Copy linkLink copied to clipboard!
Red Hat infrastructure (Hive) manages certificate rotation for default application ingress.
15.1.5.15. Disconnected environments Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture does not support an air-gapped, disconnected environment. The Red Hat OpenShift Service on AWS classic architecture cluster must have egress to the internet to access our registry, S3, and send metrics. The service requires a number of egress endpoints. Ingress can be limited to a PrivateLink for Red Hat SREs and a VPN for customer access.
Additional resources
- Red Hat product page
- AWS product page
- Red Hat Customer Portal
- AWS ROSA getting started guide
- ROSA documentation
- ROSA service definition
- ROSA responsibility assignment matrix
- Understanding Process and Security
- About Availability
- Backup policy
- Updates Lifecycle
- Configuring multitenant isolation with network policy
- Configuring custom domains for applications
- Red Hat OpenShift Service on AWS classic architecture regional availability
- Responsibility matrix
- Product regional availability
- AWS instance types
- About autoscaling nodes on a cluster
- List of the account-wide and per-cluster roles for Red Hat OpenShift Service on AWS classic architecture
- Red Hat OpenShift Service on AWS classic architecture life cycle
- Service Definition
- Red Hat OpenShift Service on AWS classic architecture support documentation
- Limited support status
- Red Hat OpenShift Service on AWS classic architecture service-level agreement
- SRE access
- etcd encryption
- AWS prerequisites
- Storage
- Setting up AWS EFS for Red Hat OpenShift Service on AWS
- CIDR Range Definitions
- ROSA roadmap
- Learn about OpenShift
- OpenShift Cluster Manager
- Red Hat Support
15.2. Tutorial: Red Hat OpenShift Service on AWS classic architecture with AWS STS explained Copy linkLink copied to clipboard!
This tutorial outlines the two options for allowing Red Hat OpenShift Service on AWS classic architecture to interact with resources in a user’s Amazon Web Service (AWS) account. It details the components and processes that Red Hat OpenShift Service on AWS classic architecture with Security Token Service (STS) uses to obtain the necessary credentials. It also reviews why Red Hat OpenShift Service on AWS classic architecture with STS is the more secure, preferred method.
This content currently covers Red Hat OpenShift Service on AWS classic architecture Classic with AWS STS.
This tutorial will:
Enumerate two of the deployment options:
- Red Hat OpenShift Service on AWS classic architecture with IAM Users
- Red Hat OpenShift Service on AWS classic architecture with STS
- Explain the differences between the two options
- Explain why Red Hat OpenShift Service on AWS classic architecture with STS is more secure and the preferred option
- Explain how Red Hat OpenShift Service on AWS classic architecture with STS works
15.2.1. Different credential methods to deploy Red Hat OpenShift Service on AWS classic architecture Copy linkLink copied to clipboard!
As part of Red Hat OpenShift Service on AWS classic architecture, Red Hat manages infrastructure resources in your AWS account and must be granted the necessary permissions. There are currently two supported methods for granting those permissions:
Using static IAM user credentials with an
AdministratorAccesspolicyThis is referred to as "Red Hat OpenShift Service on AWS classic architecture with IAM Users" in this tutorial. It is not the preferred credential method.
Using AWS STS with short-lived, dynamic tokens
This is referred to as “Red Hat OpenShift Service on AWS classic architecture with STS” in this tutorial. It is the preferred credential method.
15.2.1.1. Rosa with IAM Users Copy linkLink copied to clipboard!
When Red Hat OpenShift Service on AWS classic architecture was first released, the only credential method was Red Hat OpenShift Service on AWS classic architecture with IAM Users. This method grants IAM users with an AdministratorAccess policy full access to create the necessary resources in the AWS account that uses Red Hat OpenShift Service on AWS classic architecture. The cluster can then create and expand its credentials as needed.
15.2.1.2. Red Hat OpenShift Service on AWS classic architecture with STS Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture with STS grants users limited, short-term access to resources in your AWS account. The STS method uses predefined roles and policies to grant temporary, least-privilege permissions to IAM users or authenticated federated users. The credentials typically expire an hour after being requested. Once expired, they are no longer recognized by AWS and no longer have account access from API requests made with them. For more information, see the AWS documentation. While both Red Hat OpenShift Service on AWS classic architecture with IAM Users and Red Hat OpenShift Service on AWS classic architecture with STS are currently enabled, Red Hat OpenShift Service on AWS classic architecture with STS is the preferred and recommended option.
15.2.2. Red Hat OpenShift Service on AWS classic architecture with STS security Copy linkLink copied to clipboard!
Several crucial components make Red Hat OpenShift Service on AWS classic architecture with STS more secure than Red Hat OpenShift Service on AWS classic architecture with IAM Users:
- An explicit and limited set of roles and policies that the user creates ahead of time. The user knows every requested permission and every role used.
- The service cannot do anything outside of those permissions.
- Whenever the service needs to perform an action, it obtains credentials that expire in one hour or less. This means that there is no need to rotate or revoke credentials. Additionally, credential expiration reduces the risks of credentials leaking and being reused.
15.2.2.1. AWS STS explained Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture uses AWS STS to grant least-privilege permissions with short-term security credentials to specific and segregated IAM roles. The credentials are associated with IAM roles specific to each component and cluster that makes AWS API calls. This method aligns with principles of least-privilege and secure practices in cloud service resource management. The Red Hat OpenShift Service on AWS classic architecture command-line interface (CLI) tool manages the STS roles and policies that are assigned for unique tasks and takes action upon AWS resources as part of OpenShift functionality.
STS roles and policies must be created for each Red Hat OpenShift Service on AWS classic architecture cluster. To make this easier, the installation tools provide all the commands and files needed to create the roles as policies and an option to allow the CLI to automatically create the roles and policies. See "Creating a Red Hat OpenShift Service on AWS classic architecture cluster with STS using customizations" in the Additional resource for more information about the different --mode options.
15.2.2.2. Red Hat OpenShift Service on AWS classic architecture with STS workflow Copy linkLink copied to clipboard!
The user creates the required account-wide roles and account-wide policies. For more information, see the components section in this tutorial. During role creation, a trust policy, known as a cross-account trust policy, is created which allows a Red Hat-owned role to assume the roles. Trust policies are also created for the EC2 service, which allows workloads on EC2 instances to assume roles and obtain credentials. The user can then assign a corresponding permissions policy to each role.
After the account-wide roles and policies are created, the user can create a cluster. Once cluster creation is initiated, the Operator roles are created so that cluster Operators can make AWS API calls. These roles are then assigned to the corresponding permission policies that were created earlier and a trust policy with an OIDC provider. The Operator roles differ from the account-wide roles in that they ultimately represent the pods that need access to AWS resources. Because a user cannot attach IAM roles to pods, they must create a trust policy with an OIDC provider so that the Operator, and therefore the pods, can access the roles they need.
Once the user assigns the roles to the corresponding policy permissions, the final step is creating the OIDC provider.
When a new role is needed, the workload currently using the Red Hat role will assume the role in the AWS account, obtain temporary credentials from AWS STS, and begin performing the actions using API calls within the customer’s AWS account as permitted by the assumed role’s permissions policy. The credentials are temporary and have a maximum duration of one hour.
The entire workflow is depicted in the following graphic:
Operators use the following process to obtain the requisite credentials to perform their tasks. Each Operator is assigned an Operator role, a permissions policy, and a trust policy with an OIDC provider. The Operator will assume the role by passing a JSON web token that contains the role and a token file (web_identity_token_file) to the OIDC provider, which then authenticates the signed key with a public key. The public key is created during cluster creation and stored in an S3 bucket. The Operator then confirms that the subject in the signed token file matches the role in the role trust policy which ensures that the OIDC provider can only obtain the allowed role. The OIDC provider then returns the temporary credentials to the Operator so that the Operator can make AWS API calls. For a visual representation, see below:
15.2.2.3. Red Hat OpenShift Service on AWS classic architecture with STS use cases Copy linkLink copied to clipboard!
Creating nodes at cluster install: The Red Hat installation program uses the RH-Managed-OpenShift-Installer role and a trust policy to assume the Managed-OpenShift-Installer-Role role in the customer’s account. This process returns temporary credentials from AWS STS. The installation program begins making the required API calls with the temporary credentials just received from STS. The installation program creates the required infrastructure in AWS. The credentials expire within an hour and the installation program no longer has access to the customer’s account.
The same process also applies for support cases. In support cases, a Red Hat site reliability engineer (SRE) replaces the installation program.
15.2.3. Components specific to Red Hat OpenShift Service on AWS classic architecture with STS Copy linkLink copied to clipboard!
- AWS infrastructure - This provides the infrastructure required for the cluster. It contains the actual EC2 instances, storage, and networking components.
- AWS STS - See the credential method section above.
- OpenID Connect (OIDC) - This provides a mechanism for cluster Operators to authenticate with AWS, assume the cluster roles through a trust policy, and obtain temporary credentials from STS to make the required API calls.
Roles and policies - The roles and policies are one of the main differences between Red Hat OpenShift Service on AWS classic architecture with STS and Red Hat OpenShift Service on AWS classic architecture with IAM Users. For Red Hat OpenShift Service on AWS classic architecture with STS, the roles and policies used by Red Hat OpenShift Service on AWS classic architecture are broken into account-wide roles and policies and Operator roles and policies.
The policies determine the allowed actions for each of the roles. See the Additional resources for more details about the individual roles and policies.
The following account-wide roles are required:
- ManagedOpenShift-Installer-Role
- ManagedOpenShift-ControlPlane-Role
- ManagedOpenShift-Worker-Role
- ManagedOpenShift-Support-Role
The following account-wide policies are required:
- ManagedOpenShift-Installer-Role-Policy
- ManagedOpenShift-ControlPlane-Role-Policy
- ManagedOpenShift-Worker-Role-Policy
- ManagedOpenShift-Support-Role-Policy
- ManagedOpenShift-openshift-ingress-operator-cloud-credentials [1]
- ManagedOpenShift-openshift-cluster-csi-drivers-ebs-cloud-credent [1]
- ManagedOpenShift-openshift-cloud-network-config-controller-cloud [1]
- ManagedOpenShift-openshift-machine-api-aws-cloud-credentials [1]
- ManagedOpenShift-openshift-cloud-credential-operator-cloud-crede [1]
ManagedOpenShift-openshift-image-registry-installer-cloud-creden [1]
- This policy is used by the cluster Operator roles, listed below. The Operator roles are created in a second step because they are dependent on an existing cluster name and cannot be created at the same time as the account-wide roles.
The Operator roles are:
- <cluster-name\>-xxxx-openshift-cluster-csi-drivers-ebs-cloud-credent
- <cluster-name\>-xxxx-openshift-cloud-network-config-controller-cloud
- <cluster-name\>-xxxx-openshift-machine-api-aws-cloud-credentials
- <cluster-name\>-xxxx-openshift-cloud-credential-operator-cloud-crede
- <cluster-name\>-xxxx-openshift-image-registry-installer-cloud-creden
- <cluster-name\>-xxxx-openshift-ingress-operator-cloud-credentials
- Trust policies are created for each account-wide and Operator role.
15.2.4. Deploying a Red Hat OpenShift Service on AWS classic architecture STS cluster Copy linkLink copied to clipboard!
You are not expected to create the resources listed in the below steps from scratch. The Red Hat OpenShift Service on AWS classic architecture CLI creates the required JSON files for you and outputs the commands you need. The Red Hat OpenShift Service on AWS classic architecture CLI can also take this a step further and run the commands for you, if desired.
Procedure
- Steps to deploy a Red Hat OpenShift Service on AWS classic architecture with STS cluster
- Create the account-wide roles and policies.
- Assign the permissions policy to the corresponding account-wide role.
- Create the cluster.
- Create the Operator roles and policies.
- Assign the permission policy to the corresponding Operator role.
Create the OIDC provider.
The roles and policies can be created automatically by the Red Hat OpenShift Service on AWS classic architecture CLI, or they can be manually created by utilizing the
--mode manualor--mode autoflags in the ROSA CLI.-
Scaling the cluster: The
machine-api-operatoruses AssumeRoleWithWebIdentity to assume themachine-api-aws-cloud-credentialsrole. This launches the sequence for the cluster Operators to receive the credentials. Themachine-api-operatorrole can now make the relevant API calls to add more EC2 instances to the cluster.
15.3. Tutorial: OpenShift concepts Copy linkLink copied to clipboard!
The following sections explain various concepts of OpenShift.
15.3.1. Source-to-Image (S2I) Copy linkLink copied to clipboard!
Source-to-Image (S2I) is a toolkit and workflow for building reproducible container images from source code. S2I produces ready-to-run images by inserting source code into a container image and letting the container prepare the source code. By creating self-assembling builder images, you can version and control your build environments exactly like you use container images to version your runtime environments.
15.3.1.1. How it works Copy linkLink copied to clipboard!
For a dynamic language such as Ruby, the build time and run time environments are typically the same. Assuming that Ruby, Bundler, Rake, Apache, GCC, and all other packages needed to set up and run a Ruby application are already installed, a builder image performs the following steps:
- The builder image starts a container with the application source injected into a known directory.
- The container process transforms that source code into the appropriate runnable setup. For example, it installs dependencies with Bundler and moves the source code into a directory where Apache has been preconfigured to look for the Ruby configuration file.
- It then commits the new container and sets the image entrypoint to be a script that will start Apache to host the Ruby application.
For compiled languages such as C, C++, Go, or Java, the necessary dependencies for compilation might outweigh the size of the runtime artifacts. To keep runtime images small, S2I enables a multiple-step build process, where a binary artifact such as an executable file is created in the first builder image, extracted, and injected into a second runtime image that simply places the executable program in the correct location.
For example, to create a reproducible build pipeline for Tomcat and Maven:
- Create a builder image containing OpenJDK and Tomcat that expects to have a WAR file injected.
- Create a second image that layers on top of the first image Maven and any other standard dependencies, and expects to have a Maven project injected.
- Start S2I using the Java application source and the Maven image to create the desired application WAR.
- Start S2I a second time using the WAR file from the earlier step and the initial Tomcat image to create the runtime image.
By placing build logic inside of images and combining the images into multiple steps, the runtime environment is close to the build environment without requiring the deployment of build tools to production.
15.3.1.2. S2I benefits Copy linkLink copied to clipboard!
- Reproducibility
- Allow build environments to be tightly versioned by encapsulating them within a container image and defining a simple interface of injected source code for callers. Reproducible builds are a key requirement for enabling security updates and continuous integration in containerized infrastructure, and builder images help ensure repeatability and the ability to swap run times.
- Flexibility
- Any existing build system that can run on Linux can run inside of a container, and each individual builder can also be part of a larger pipeline. The scripts that process the application source code can be injected into the builder image, allowing authors to adapt existing images to enable source handling.
- Speed
- Instead of building multiple layers in a single Dockerfile, S2I encourages authors to represent an application in a single image layer. This saves time during creation and deployment and allows for better control over the output of the final image.
- Security
- Dockerfiles are run without many of the normal operational controls of containers. They usually run as root and have access to the container network. S2I can control what permissions and privileges are available to the builder image since the build is launched in a single container. In concert with platforms like OpenShift, S2I allows administrators to control what privileges developers have at build time.
15.3.2. Routes Copy linkLink copied to clipboard!
An OpenShift route exposes a service at a hostname so that external clients can reach it by name. When a Route object is created on OpenShift, it gets picked up by the built-in HAProxy load balancer to expose the requested service and make it externally available with the given configuration.
Similar to the Kubernetes Ingress object, Red Hat created the concept of route to fill a need and then contributed the design principles behind it to the community, which heavily influenced the Ingress design. A route does have some additional features as can be seen in the following chart:
| Feature | Ingress on OpenShift | Route on OpenShift |
|---|---|---|
| Standard Kubernetes object | X | |
| External access to services | X | X |
| Persistent (sticky) sessions | X | X |
| Load-balancing strategies (e.g. round robin) | X | X |
| Rate-limit and throttling | X | X |
| IP whitelisting | X | X |
| TLS edge termination for improved security | X | X |
| TLS re-encryption for improved security | X | |
| TLS passhtrough for improved security | X | |
| Multiple weighted backends (split traffic) | X | |
| Generated pattern-based hostnames | X | |
| Wildcard domains | X |
DNS resolution for a hostname is handled separately from routing. Your administrator might have configured a cloud domain that will always correctly resolve to the router or modify your unrelated hostname DNS records independently to resolve to the router.
An individual route can override some defaults by providing specific configurations in its annotations.
15.3.3. Image streams Copy linkLink copied to clipboard!
An image stream stores a mapping of tags to images, metadata overrides that are applied when images are tagged in a stream, and an optional reference to a Docker image repository on a registry.
15.3.3.1. Image stream benefits Copy linkLink copied to clipboard!
Using an image stream makes it easier to change a tag for a container image. Otherwise, to manually change a tag, you must download the image, change it locally, then push it all back. Promoting applications by manually changing a tag and then updating the deployment object entails many steps.
With image streams, you upload a container image once and then you manage its virtual tags internally in OpenShift. In one project you might use the developer tag and only change a reference to it internally, while in production you might use a production tag and also manage it internally. You do not have to deal with the registry.
You can also use image streams in conjunction with deployment configs to set a trigger that will start a deployment as soon as a new image appears or a tag changes its reference.
15.3.3.2. Builds Copy linkLink copied to clipboard!
A build is the process of transforming input parameters into a resulting object. Most often, the process is used to transform input parameters or source code into a runnable image. A BuildConfig object is the definition of the entire build process.
OpenShift Container Platform leverages Kubernetes by creating Docker-formatted containers from build images and pushing them to a container image registry.
Build objects share common characteristics:
- Inputs for a build
- Requirements to complete a build process
- Logging the build process
- Publishing resources from successful builds
- Publishing the final status of the build
Builds take advantage of resource restrictions, specifying limitations on resources such as CPU usage, memory usage, and build or pod execution time.
15.4. Deploying a cluster Copy linkLink copied to clipboard!
15.4.1. Tutorial: Choosing a deployment method Copy linkLink copied to clipboard!
This tutorial outlines the different ways to deploy a cluster. Choose the deployment method that best fits your preferences and needs.
15.4.1.1. Deployment options Copy linkLink copied to clipboard!
If you want:
- Only the necessary CLI commands - Simple CLI guide
- A user interface - Simple UI guide
- The CLI commands with details - Detailed CLI guide
- A user interface with details - Detailed UI guide
All of the above deployment options work well for this tutorial. If you are doing this tutorial for the first time, the Simple CLI guide is the simplest and recommended method.
15.4.2. Tutorial: Simple CLI guide Copy linkLink copied to clipboard!
This page outlines the minimum list of commands to deploy a Red Hat OpenShift Service on AWS classic architecture (ROSA) cluster using the command-line interface (CLI).
While this simple deployment works well for a tutorial setting, clusters used in production should be deployed with a more detailed method.
15.4.2.1. Prerequisites Copy linkLink copied to clipboard!
- You have completed the prerequisites in the Setup tutorial.
15.4.2.2. Creating account roles Copy linkLink copied to clipboard!
Run the following command once for each AWS account and y-stream OpenShift version:
rosa create account-roles --mode auto --yes
rosa create account-roles --mode auto --yes
15.4.2.3. Deploying the cluster Copy linkLink copied to clipboard!
Create the cluster with the default configuration by running the following command substituting your own cluster name:
rosa create cluster --cluster-name <cluster-name> --sts --mode auto --yes
rosa create cluster --cluster-name <cluster-name> --sts --mode auto --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check the status of your cluster by running the following command:
rosa list clusters
rosa list clustersCopy to Clipboard Copied! Toggle word wrap Toggle overflow
15.4.3. Tutorial: Detailed CLI guide Copy linkLink copied to clipboard!
This tutorial outlines the detailed steps to deploy a Red Hat OpenShift Service on AWS classic architecture cluster using the ROSA command-line interface (CLI) (rosa).
15.4.3.1. CLI deployment modes Copy linkLink copied to clipboard!
There are two modes with which to deploy a Red Hat OpenShift Service on AWS classic architecture cluster. One is automatic, which is quicker and performs the manual work for you. The other is manual, requires you to run extra commands, and allows you to inspect the roles and policies being created. This tutorial documents both options.
If you want to create a cluster quickly, use the automatic option. If you prefer exploring the roles and policies being created, use the manual option.
Choose the deployment mode by using the --mode flag in the relevant commands.
Valid options for --mode are:
-
manual: Role and policies are created and saved in the current directory. You must manually run the provided commands as the next step. This option allows you to review the policy and roles before creating them. -
auto: Roles and policies are created and applied automatically using the current AWS account.
You can use either deployment method for this tutorial. The auto mode is faster and has less steps.
15.4.3.1.1. Deployment workflow Copy linkLink copied to clipboard!
The overall deployment workflow follows these steps:
-
rosa create account-roles- This is executed only once for each account. Once created, the account roles do not need to be created again for more clusters of the same y-stream version. -
rosa create cluster -
rosa create operator-roles- For manual mode only. -
rosa create oidc-provider- For manual mode only.
For each additional cluster in the same account for the same y-stream version, only step 2 is needed for automatic mode. Steps 2 through 4 are needed for manual mode.
15.4.3.2. Creating a cluster with automatic mode Copy linkLink copied to clipboard!
Use this method if you want the ROSA CLI to automate the creation of the roles and policies to create your cluster quickly. If this is the first time you are deploying Red Hat OpenShift Service on AWS classic architecture in this account and you have not yet created the account roles, then create the account-wide roles and policies, including Operator policies.
Procedure
Run the following command to create the account-wide roles:
rosa create account-roles --mode auto --yes
rosa create account-roles --mode auto --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command to create a cluster with all the default options:
rosa create cluster --cluster-name <cluster-name> --sts --mode auto --yes
rosa create cluster --cluster-name <cluster-name> --sts --mode auto --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThis will also create the required Operator roles and OIDC provider. If you want to see all available options for your cluster use the
--helpflag or--interactivefor interactive mode.Example input
rosa create cluster --cluster-name my-rosa-cluster --sts --mode auto --yes
$ rosa create cluster --cluster-name my-rosa-cluster --sts --mode auto --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The default settings are as follows:
Nodes:
- 3 control plane nodes
- 2 infrastructure nodes
- 2 worker nodes
- No autoscaling
-
Region: As configured for the
awsCLI Networking IP ranges:
- Machine CIDR: 10.0.0.0/16
- Service CIDR: 172.30.0.0/16
- Pod CIDR: 10.128.0.0/14
- New VPC
- Default AWS KMS key for encryption
-
The most recent version of OpenShift available to
rosa - A single availability zone
- Public cluster
Run one of the following commands to check the status of your cluster:
For a detailed view of the status, run:
rosa describe cluster --cluster <cluster-name>
rosa describe cluster --cluster <cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For an abridged view of the status, run:
rosa list clusters
rosa list clustersCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- The cluster state will change from “waiting” to “installing” to "ready". This will take about 40 minutes.
- Once the state changes to “ready” your cluster is installed.
15.4.3.3. Creating a cluster with manual Mode Copy linkLink copied to clipboard!
If you want to review the roles and policies before applying them to a cluster, use the manual method. This method requires running a few extra commands to create the roles and policies. This section uses the --interactive mode.
Procedure
If this is the first time you are deploying Red Hat OpenShift Service on AWS classic architecture in this account and you have not yet created the account roles, create the account-wide roles and policies, including the Operator policies. The command creates the needed JSON files for the required roles and policies for your account in the current directory. It also outputs the
awsCLI commands that you need to run to create these objects.Run the following command to create the needed files and output the additional commands:
rosa create account-roles --mode manual
rosa create account-roles --mode manualCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the contents of your current directory to see the new files. Use the
awsCLI to create each of these objects.Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Open the files to review what you will create. For example, opening the
sts_installer_permission_policy.jsonshows:Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Run the
awscommands listed in step 1. You can copy and paste if you are in the same directory as the JSON files you created. After the
awscommands are executed successfully, run the following command to begin Red Hat OpenShift Service on AWS classic architecture cluster creation in interactive mode:rosa create cluster --interactive --sts
rosa create cluster --interactive --stsCopy to Clipboard Copied! Toggle word wrap Toggle overflow For the purpose of this tutorial, copy and then input the following values:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe cluster state will remain as “waiting” until the next two steps are completed.
The above step outputs the next commands to run. These roles need to be created once for each cluster. To create the roles run the following command:
rosa create operator-roles --mode manual --cluster <cluster-name>
rosa create operator-roles --mode manual --cluster <cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Run each of the
awscommands. Run the following command to create the OIDC provider:
rosa create oidc-provider --mode manual --cluster <cluster-name>
rosa create oidc-provider --mode manual --cluster <cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow This displays the
awscommands that you need to run.Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Your cluster will now continue the installation process.
Run one of the following commands to check the status of your cluster:
For a detailed view of the status, run:
rosa describe cluster --cluster <cluster-name>
rosa describe cluster --cluster <cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For an abridged view of the status, run:
rosa list clusters
rosa list clustersCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- The cluster state will change from “waiting” to “installing” to "ready". This will take about 40 minutes.
- Once the state changes to “ready” your cluster is installed.
To obtain the Hybrid Cloud Console URL, run the following command:
rosa describe cluster -c <cluster-name> | grep Console
rosa describe cluster -c <cluster-name> | grep ConsoleCopy to Clipboard Copied! Toggle word wrap Toggle overflow The cluster has now been successfully deployed. The next tutorial shows how to create an admin user to be able to use the cluster immediately.
15.4.4. Tutorial: Simple UI guide Copy linkLink copied to clipboard!
This page outlines the minimum list of commands to deploy a Red Hat OpenShift Service on AWS classic architecture cluster using the user interface (UI).
While this simple deployment works well for a tutorial setting, clusters used in production should be deployed with a more detailed method.
15.4.4.1. Prerequisites Copy linkLink copied to clipboard!
- You have completed the prerequisites in the Setup tutorial.
15.4.4.2. Creating required cluster creation roles Copy linkLink copied to clipboard!
You create your required cluster creation roles using ROSA command-line interface (CLI) (rosa).
Procedure
Run the following command once for each AWS account and y-stream OpenShift version:
rosa create account-roles --mode auto --yes
rosa create account-roles --mode auto --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create one OpenShift Cluster Manager role for each AWS account by running the following command:
rosa create ocm-role --mode auto --admin --yes
rosa create ocm-role --mode auto --admin --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create one OpenShift Cluster Manager user role for each AWS account by running the following command:
rosa create user-role --mode auto --yes
rosa create user-role --mode auto --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Use the OpenShift Cluster Manager to select your AWS account, cluster options, and begin deployment.
OpenShift Cluster Manager UI displays cluster status.
15.4.5. Tutorial: Detailed UI guide Copy linkLink copied to clipboard!
This tutorial outlines the detailed steps to deploy a Red Hat OpenShift Service on AWS classic architecture cluster using the Red Hat OpenShift Cluster Manager user interface (UI).
15.4.5.1. Deployment workflow Copy linkLink copied to clipboard!
The overall deployment workflow follows these steps:
- Create the account wide roles and policies.
Associate your AWS account with your Red Hat account.
- Create and link the Red Hat OpenShift Cluster Manager role.
- Create and link the user role.
- Create the cluster.
Step 1 only needs to be performed the first time you are deploying into an AWS account. Step 2 only needs to be performed the first time you are using the UI. For successive clusters of the same y-stream version, you only need to create the cluster.
15.4.5.2. Creating account wide roles Copy linkLink copied to clipboard!
You create your account wide roles to create your cluster by using the ROSA command-line interface (CLI) (rosa) tool.
If you already have account roles from an earlier deployment, skip this step. The UI will detect your existing roles after you select an associated AWS account.
If this is the first time you are deploying Red Hat OpenShift Service on AWS classic architecture in this account and you have not yet created the account roles, create the account-wide roles and policies, including the Operator policies.
Procedure
In your terminal, run the following command to create the account-wide roles:
rosa create account-roles --mode auto --yes
$ rosa create account-roles --mode auto --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.4.5.3. Creating and associating an OpenShift Cluster Manager role Copy linkLink copied to clipboard!
Create and associate an OpenShift Cluster Manager role to enable cluster management through the OpenShift Cluster Manager Hybrid Cloud Console.
Procedure
Run the following command to see if an OpenShift Cluster Manager role exists:
rosa list ocm-role
$ rosa list ocm-roleCopy to Clipboard Copied! Toggle word wrap Toggle overflow The UI displays the commands to create an OpenShift Cluster Manager role with two different levels of permissions:
- Basic OpenShift Cluster Manager role: Allows the OpenShift Cluster Manager to have read-only access to the account to check if the roles and policies that are required by Red Hat OpenShift Service on AWS classic architecture are present before creating a cluster. You will need to manually create the required roles, policies, and OIDC provider using the CLI.
Admin OpenShift Cluster Manager role: Grants the OpenShift Cluster Manager additional permissions to create the required roles, policies, and OIDC provider for Red Hat OpenShift Service on AWS classic architecture. Using this makes the deployment of a Red Hat OpenShift Service on AWS classic architecture cluster quicker since the OpenShift Cluster Manager will be able to create the required resources for you.
To read more about these roles, see the "OpenShift Cluster Manager roles and permissions" documentation in the Additional resources.
For the purposes of this tutorial, use the Admin OpenShift Cluster Manager role for the simplest and quickest approach.
Copy the command to create the Admin OpenShift Cluster Manager role from the sidebar or switch to your terminal and enter the following command:
rosa create ocm-role --mode auto --admin --yes
$ rosa create ocm-role --mode auto --admin --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command creates the OpenShift Cluster Manager role and associates it with your Red Hat account.
Example output
I: Creating ocm role I: Creating role using 'arn:aws:iam::000000000000:user/rosa-user' I: Created role 'ManagedOpenShift-OCM-Role-12561000' with ARN 'arn:aws:iam::000000000000:role/ManagedOpenShift-OCM-Role-12561000' I: Linking OCM role I: Successfully linked role-arn 'arn:aws:iam::000000000000:role/ManagedOpenShift-OCM-Role-12561000' with organization account '1MpZfntsZeUdjWHg7XRgP000000'
I: Creating ocm role I: Creating role using 'arn:aws:iam::000000000000:user/rosa-user' I: Created role 'ManagedOpenShift-OCM-Role-12561000' with ARN 'arn:aws:iam::000000000000:role/ManagedOpenShift-OCM-Role-12561000' I: Linking OCM role I: Successfully linked role-arn 'arn:aws:iam::000000000000:role/ManagedOpenShift-OCM-Role-12561000' with organization account '1MpZfntsZeUdjWHg7XRgP000000'Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click Step 2: User role.
15.4.5.4. Creating and associating an OpenShift Cluster Manager role Copy linkLink copied to clipboard!
You need the OpenShift Cluster Manager role to create your cluster.
Procedure
Run the following command to see if an OpenShift Cluster Manager role exists:
rosa list ocm-role
$ rosa list ocm-roleCopy to Clipboard Copied! Toggle word wrap Toggle overflow The UI displays the commands to create an OpenShift Cluster Manager role with two different levels of permissions:
- Basic OpenShift Cluster Manager role: Allows the OpenShift Cluster Manager to have read-only access to the account to check if the roles and policies that are required by Red Hat OpenShift Service on AWS classic architecture are present before creating a cluster. You will need to manually create the required roles, policies, and OIDC provider using the CLI.
Admin OpenShift Cluster Manager role: Grants the OpenShift Cluster Manager additional permissions to create the required roles, policies, and OIDC provider for Red Hat OpenShift Service on AWS classic architecture. Using this makes the deployment of a Red Hat OpenShift Service on AWS classic architecture cluster quicker since the OpenShift Cluster Manager will be able to create the required resources for you.
To read more about these roles, see the "OpenShift Cluster Manager roles and permissions" documentation in the Additional resources.
For the purposes of this tutorial, use the Admin OpenShift Cluster Manager role for the simplest and quickest approach.
Copy the command to create the Admin OpenShift Cluster Manager role from the sidebar or switch to your terminal and enter the following command:
rosa create ocm-role --mode auto --admin --yes
$ rosa create ocm-role --mode auto --admin --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command creates the OpenShift Cluster Manager role and associates it with your Red Hat account.
Example output
I: Creating ocm role I: Creating role using 'arn:aws:iam::000000000000:user/rosa-user' I: Created role 'ManagedOpenShift-OCM-Role-12561000' with ARN 'arn:aws:iam::000000000000:role/ManagedOpenShift-OCM-Role-12561000' I: Linking OCM role I: Successfully linked role-arn 'arn:aws:iam::000000000000:role/ManagedOpenShift-OCM-Role-12561000' with organization account '1MpZfntsZeUdjWHg7XRgP000000'
I: Creating ocm role I: Creating role using 'arn:aws:iam::000000000000:user/rosa-user' I: Created role 'ManagedOpenShift-OCM-Role-12561000' with ARN 'arn:aws:iam::000000000000:role/ManagedOpenShift-OCM-Role-12561000' I: Linking OCM role I: Successfully linked role-arn 'arn:aws:iam::000000000000:role/ManagedOpenShift-OCM-Role-12561000' with organization account '1MpZfntsZeUdjWHg7XRgP000000'Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click Step 2: User role.
15.4.5.4.1. Other OpenShift Cluster Manager role creation options Copy linkLink copied to clipboard!
You can use the ROSA CLI tool to create your cluster roles.
Procedure
Manual mode: If you prefer to run the AWS CLI commands yourself, you can define the mode as
manualrather thanauto. The CLI will output the AWS commands and the relevant JSON files are created in the current directory.Use the following command to create the OpenShift Cluster Manager role in manual mode:
rosa create ocm-role --mode manual --admin --yes
$ rosa create ocm-role --mode manual --admin --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Basic OpenShift Cluster Manager role: If you prefer that the OpenShift Cluster Manager has read only access to the account, create a basic OpenShift Cluster Manager role. You will then need to manually create the required roles, policies, and OIDC provider using the CLI.
Use the following command to create a Basic OpenShift Cluster Manager role:
rosa create ocm-role --mode auto --yes
$ rosa create ocm-role --mode auto --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow
15.4.5.5. Creating an OpenShift Cluster Manager user role Copy linkLink copied to clipboard!
The user role needs to be created so that Red Hat OpenShift Service on AWS classic architecture can verify your AWS identity. This role has no permissions, and it is only used to create a trust relationship between the installation program account and your OpenShift Cluster Manager role resources. For more information, see the user role documentation in Additional resources.
Procedure
Check if a user role already exists by running the following command:
rosa list user-role
$ rosa list user-roleCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command to create the user role and to link it to your Red Hat account:
rosa create user-role --mode auto --yes
$ rosa create user-role --mode auto --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
I: Creating User role I: Creating ocm user role using 'arn:aws:iam::000000000000:user/rosa-user' I: Created role 'ManagedOpenShift-User-rosa-user-Role' with ARN 'arn:aws:iam::000000000000:role/ManagedOpenShift-User-rosa-user-Role' I: Linking User role I: Successfully linked role ARN 'arn:aws:iam::000000000000:role/ManagedOpenShift-User-rosa-user-Role' with account '1rbOQez0z5j1YolInhcXY000000'
I: Creating User role I: Creating ocm user role using 'arn:aws:iam::000000000000:user/rosa-user' I: Created role 'ManagedOpenShift-User-rosa-user-Role' with ARN 'arn:aws:iam::000000000000:role/ManagedOpenShift-User-rosa-user-Role' I: Linking User role I: Successfully linked role ARN 'arn:aws:iam::000000000000:role/ManagedOpenShift-User-rosa-user-Role' with account '1rbOQez0z5j1YolInhcXY000000'Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteAs before, you can define
--mode manualif you’d prefer to run the AWS CLI commands yourself. The CLI outputs the AWS commands and the relevant JSON files are created in the current directory. Make sure to link the role.- Click Step 3: Account roles.
15.4.5.6. Creating account roles Copy linkLink copied to clipboard!
You can create your account roles using the ROSA CLI tool.
Procedure
Create your account roles by running the following command:
rosa create account-roles --mode auto
$ rosa create account-roles --mode autoCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Click OK to close the sidebar.
15.4.5.7. Confirming successful account association Copy linkLink copied to clipboard!
You should now see your AWS account in the Associated AWS infrastructure account dropdown menu.
Procedure
- If you see your account, account association was successful.
- Select the account.
You will see the account role ARNs populated below.
- Click Next.
15.4.5.8. Creating the cluster Copy linkLink copied to clipboard!
This tutorial uses the default options for creating a cluster.
Procedure
In Cluster settings, select:
- Cluster name: <pick a name\>
- Version: <select latest version\>
- Region: <select region\>
- Availability: Single zone
- Enable user workload monitoring: leave checked
- Enable additional etcd encryption: leave unchecked
- Encrypt persistent volumes with customer keys: leave unchecked
- Click Next.
Leave the default settings on for the machine pool:
- Compute node instance type: m5.xlarge - 4 vCPU 16 GiB RAM
- Enable autoscaling: unchecked
- Compute node count: 2
- Leave node labels blank
- Click Next.
15.4.5.8.1. Finalizing cluster creation Copy linkLink copied to clipboard!
You can select the defaults to complete cluster installation.
Procedure
- For Networking, leave all the default values for configuration.
- Click Next.
- Leave all the default values for CIDR ranges.
- Click Next.
For Cluster roles and policies, leave Auto selected. It makes the cluster deployment process simpler and quicker.
NoteIf you selected a Basic OpenShift Cluster Manager role earlier, you can only use manual mode. You must manually create the operator roles and OIDC provider. See the "Basic OpenShift Cluster Manager role" section below after you have completed the "Cluster updates" section and started cluster creation.
Leave all of the Cluster update options at default in this section.
- Review the content for the cluster configuration.
- Click Create cluster.
Stay on the current page to monitor the installation progress. It should take about 40 minutes.
15.4.5.9. Basic OpenShift Cluster Manager Role Copy linkLink copied to clipboard!
You need to create the Operator roles to manage your cluster.
If you created an Admin OpenShift Cluster Manager role as directed above ignore this entire section. The OpenShift Cluster Manager will create the resources for you.
If you created a Basic OpenShift Cluster Manager role earlier, you will need to manually create two more elements before cluster installation can continue:
- Operator roles
- OIDC provider
Procedure
A pop up window will show you the commands to run.
Run the commands from the window in your terminal to launch interactive mode. Or, for simplicity, run the following command to create the Operator roles:
rosa create operator-roles --mode auto --cluster <cluster-name> --yes
$ rosa create operator-roles --mode auto --cluster <cluster-name> --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.4.5.9.1. Creating the OIDC provider Copy linkLink copied to clipboard!
You need to use the ROSA CLI tool to create your OpenID Connect provider for your cluster.
Procedure
In your terminal, run the following command to create the OIDC provider:
rosa create oidc-provider --mode auto --cluster <cluster-name> --yes
$ rosa create oidc-provider --mode auto --cluster <cluster-name> --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
I: Creating OIDC provider using 'arn:aws:iam::000000000000:user/rosauser' I: Created OIDC provider with ARN 'arn:aws:iam::000000000000:oidc-provider/rh-oidc.s3.us-east-1.amazonaws.com/1tt4kvrr2kha2rgs8gjfvf0000000000'
I: Creating OIDC provider using 'arn:aws:iam::000000000000:user/rosauser' I: Created OIDC provider with ARN 'arn:aws:iam::000000000000:oidc-provider/rh-oidc.s3.us-east-1.amazonaws.com/1tt4kvrr2kha2rgs8gjfvf0000000000'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.5. Tutorial: Creating an admin user Copy linkLink copied to clipboard!
Creating an administration (admin) user allows you to access your cluster quickly.
An admin user works well in this tutorial setting. For actual deployment, use a formal identity provider to access the cluster and grant the user admin privileges.
15.5.1. Creating an admin user with ROSA CLI Copy linkLink copied to clipboard!
You must use the ROSA CLI tool to create an admin user.
Procedure
Run the following command to create the admin user:
rosa create admin --cluster=<cluster-name>
rosa create admin --cluster=<cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the log in command returned to you in the previous step and paste it into your terminal. This will log you in to the cluster using the CLI so you can start using the cluster.
oc login https://api.my-rosa-cluster.abcd.p1.openshiftapps.com:6443 \ --username cluster-admin \ --password FWGYL-2mkJI-00000-00000
$ oc login https://api.my-rosa-cluster.abcd.p1.openshiftapps.com:6443 \ > --username cluster-admin \ > --password FWGYL-2mkJI-00000-00000Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Login successful. You have access to 79 projects, the list has been suppressed. You can list all projects with ' projects' Using project "default".
Login successful. You have access to 79 projects, the list has been suppressed. You can list all projects with ' projects' Using project "default".Copy to Clipboard Copied! Toggle word wrap Toggle overflow To check that you are logged in as the admin user, run one of the following commands:
Option 1:
oc whoami
$ oc whoamiCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
cluster-admin
cluster-adminCopy to Clipboard Copied! Toggle word wrap Toggle overflow Option 2:
oc get all -n openshift-apiserver
oc get all -n openshift-apiserverCopy to Clipboard Copied! Toggle word wrap Toggle overflow Only an admin user can run this command without errors.
- You can now use the cluster as an admin user, which will suffice for this tutorial.
15.5.2. Next steps Copy linkLink copied to clipboard!
15.6. Tutorial: Setting up an identity provider Copy linkLink copied to clipboard!
To log in to your cluster, set up an identity provider (IDP). This tutorial uses GitHub as an example IDP. See the full list of IDPs supported by ROSA.
15.6.1. Creating an identiy provider using GitHub Copy linkLink copied to clipboard!
You need to configure an identity provider to access your cluster.
Procedure
View all IDP options, run the following command:
rosa create idp --help
rosa create idp --helpCopy to Clipboard Copied! Toggle word wrap Toggle overflow This tutorial uses GitHub to create your IDP.
- Log in to your GitHub account.
Create a new GitHub organization where you are an administrator.
TipIf you are already an administrator in an existing organization and you want to use that organization, skip to step 9.
Click the + icon, then click New Organization.
- Choose the most applicable plan for your situation or click Join for free.
Enter an organization account name, an email, and whether it is a personal or business account. Then, click Next.
- Optional: Add the GitHub IDs of other users to grant additional access to your ROSA cluster. You can also add them later.
- Click Complete Setup.
- Optional: Enter the requested information on the following page.
- Click Submit.
Go back to the terminal and enter the following command to set up the GitHub IDP:
rosa create idp --cluster=<cluster name> --interactive
rosa create idp --cluster=<cluster name> --interactiveCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the following values:
Type of identity provider: github Identity Provider Name: <IDP-name> Restrict to members of: organizations GitHub organizations: <organization-account-name>
Type of identity provider: github Identity Provider Name: <IDP-name> Restrict to members of: organizations GitHub organizations: <organization-account-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow The CLI will provide you with a link. Copy and paste the link into a browser and press Enter. This will fill the required information to register this application for OAuth. You do not need to modify any of the information.
Click Register application.
The next page displays a Client ID. Copy the ID and paste it in the terminal where it asks for Client ID.
NoteDo not close the tab.
The CLI will ask for a Client Secret. Go back in your browser and click Generate a new client secret.
- A secret is generated for you. Copy your secret because it will never be visible again.
- Paste your secret into the terminal and press Enter.
- Leave GitHub Enterprise Hostname blank.
- Select claim.
Wait approximately 1 minute for the IDP to be created and the configuration to land on your cluster.
Copy the returned link and paste it into your browser. The new IDP should be available under your chosen name. Click your IDP and use your GitHub credentials to access the cluster.
15.6.2. Granting other users access to the cluster Copy linkLink copied to clipboard!
To grant access to other cluster user you will need to add their GitHub user ID to the GitHub organization used for this cluster.
Procedure
- In GitHub, go to the Your organizations page.
Click your profile icon, then Your organizations. Then click <your-organization-name>. In our example, it is
my-rosa-cluster.
Click Invite someone.
- Enter the GitHub ID of the new user, select the correct user, and click Invite.
- Once the new user accepts the invitation, they will be able to log in to the ROSA cluster using the Hybrid Cloud Console link and their GitHub credentials.
15.7. Tutorial: Granting admin privileges Copy linkLink copied to clipboard!
Administration (admin) privileges are not automatically granted to users that you add to your cluster. If you want to grant admin-level privileges to certain users, you will need to manually grant them to each user. You can grant admin privileges from either the ROSA command-line interface (CLI) or the Red Hat OpenShift Cluster Manager web user interface (UI).
Red Hat offers two types of admin privileges:
-
cluster-admin:cluster-adminprivileges give the admin user full privileges within the cluster. -
dedicated-admin:dedicated-adminprivileges allow the admin user to complete most administrative tasks with certain limitations to prevent cluster damage. For best practice usededicated-adminwhen elevated privileges are needed.
For more information on admin privileges, see the administering a cluster documentation.
15.7.1. Using the ROSA CLI Copy linkLink copied to clipboard!
As the cluster creator, you can use the ROSA command-line interface (CLI) (rosa) tool to create your grant admin credentials to a user.
Procedure
Assuming you are the user who created the cluster, run one of the following commands to grant admin privileges:
For
cluster-admin:rosa grant user cluster-admin --user <idp_user_name> --cluster=<cluster-name>
$ rosa grant user cluster-admin --user <idp_user_name> --cluster=<cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For
dedicated-admin:rosa grant user dedicated-admin --user <idp_user_name> --cluster=<cluster-name>
$ rosa grant user dedicated-admin --user <idp_user_name> --cluster=<cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verify that the admin privileges were added by running the following command:
rosa list users --cluster=<cluster-name>
$ rosa list users --cluster=<cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
rosa list users --cluster=my-rosa-cluster ID GROUPS <idp_user_name> cluster-admins
$ rosa list users --cluster=my-rosa-cluster ID GROUPS <idp_user_name> cluster-adminsCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you are currently logged into the Red Hat Hybrid Cloud Console, log out of the console and log back in to the cluster to see a new perspective with the "Administrator Panel". You might need an incognito or private window.
You can also test that admin privileges were added to your account by running the following command. Only a
cluster-adminusers can run this command without errors.oc get all -n openshift-apiserver
$ oc get all -n openshift-apiserverCopy to Clipboard Copied! Toggle word wrap Toggle overflow
15.7.2. Using the Red Hat OpenShift Cluster Manager UI Copy linkLink copied to clipboard!
You can grant admin rights to a user by using OpenShift Cluster Manager.
Procedure
- Log in to the OpenShift Cluster Manager.
- Select your cluster.
- Click the Access Control tab.
- Click the Cluster roles and Access tab in the sidebar.
Click Add user.
- On the pop-up screen, enter the user ID.
Select whether you want to grant the user
cluster-adminsordedicated-adminsprivileges.
15.8. Tutorial: Accessing your cluster Copy linkLink copied to clipboard!
You can connect to your cluster using the ROSA command-line interface (CLI) (rosa) or the Red Hat Hybrid Cloud Console user interface (UI).
15.8.1. Accessing your cluster using the CLI Copy linkLink copied to clipboard!
To access the cluster using the CLI, you must have the oc CLI installed. If you are following the tutorials, you already installed the oc CLI.
Procedure
- Log in to the OpenShift Cluster Manager.
- Click your username in the top right corner.
Click Copy Login Command.
This opens a new tab with a choice of identity providers (IDPs). Click the IDP you want to use. For example, "rosa-github".
- A new tab opens. Click Display token.
Run the following command in your terminal:
oc login --token=sha256~GBAfS4JQ0t1UTKYHbWAK6OUWGUkdMGz000000000000 --server=https://api.my-rosa-cluster.abcd.p1.openshiftapps.com:6443
$ oc login --token=sha256~GBAfS4JQ0t1UTKYHbWAK6OUWGUkdMGz000000000000 --server=https://api.my-rosa-cluster.abcd.p1.openshiftapps.com:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Logged into "https://api.my-rosa-cluster.abcd.p1.openshiftapps.com:6443" as "rosa-user" using the token provided. You have access to 79 projects, the list has been suppressed. You can list all projects with ' projects' Using project "default".
Logged into "https://api.my-rosa-cluster.abcd.p1.openshiftapps.com:6443" as "rosa-user" using the token provided. You have access to 79 projects, the list has been suppressed. You can list all projects with ' projects' Using project "default".Copy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm that you are logged in by running the following command:
oc whoami
$ oc whoamiCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
rosa-user
rosa-userCopy to Clipboard Copied! Toggle word wrap Toggle overflow - You can now access your cluster.
15.8.2. Accessing the cluster via the Hybrid Cloud Console Copy linkLink copied to clipboard!
Access your Red Hat OpenShift Service on AWS classic architecture cluster through the Hybrid Cloud Console web interface by logging in with your identity provider credentials.
Procedure
Log in to the OpenShift Cluster Manager.
To retrieve the Hybrid Cloud Console URL run:
rosa describe cluster -c <cluster-name> | grep Console
rosa describe cluster -c <cluster-name> | grep ConsoleCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Click your IDP. For example, "rosa-github".
- Enter your user credentials.
You should be logged in. If you are following the tutorials, you will be a cluster-admin and should see the Hybrid Cloud Console webpage with the Administrator panel visible.
15.9. Tutorial: Managing worker nodes Copy linkLink copied to clipboard!
In Red Hat OpenShift Service on AWS classic architecture, changing aspects of your worker nodes is performed through the use of machine pools. A machine pool allows users to manage many machines as a single entity. Every Red Hat OpenShift Service on AWS classic architecture cluster has a default machine pool that is created when the cluster is created. For more information, see the machine pool documentation.
15.9.1. Creating a machine pool Copy linkLink copied to clipboard!
You can create a machine pool with either the command-line interface (CLI) or the user interface (UI).
Procedure
Create a machine pool by using the ROSA command-line interface (CLI) (
rosa).Run the following command:
rosa create machinepool --cluster=<cluster-name> --name=<machinepool-name> --replicas=<number-nodes>
rosa create machinepool --cluster=<cluster-name> --name=<machinepool-name> --replicas=<number-nodes>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example input
rosa create machinepool --cluster=my-rosa-cluster --name=new-mp --replicas=2
$ rosa create machinepool --cluster=my-rosa-cluster --name=new-mp --replicas=2Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
I: Machine pool 'new-mp' created successfully on cluster 'my-rosa-cluster' I: To view all machine pools, run 'rosa list machinepools -c my-rosa-cluster'
I: Machine pool 'new-mp' created successfully on cluster 'my-rosa-cluster' I: To view all machine pools, run 'rosa list machinepools -c my-rosa-cluster'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Add node labels or taints to specific nodes in a new machine pool by running the following command:
rosa create machinepool --cluster=<cluster-name> --name=<machinepool-name> --replicas=<number-nodes> --labels=`<key=pair>`
rosa create machinepool --cluster=<cluster-name> --name=<machinepool-name> --replicas=<number-nodes> --labels=`<key=pair>`Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example input
rosa create machinepool --cluster=my-rosa-cluster --name=db-nodes-mp --replicas=2 --labels='app=db','tier=backend'
$ rosa create machinepool --cluster=my-rosa-cluster --name=db-nodes-mp --replicas=2 --labels='app=db','tier=backend'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
I: Machine pool 'db-nodes-mp' created successfully on cluster 'my-rosa-cluster'
I: Machine pool 'db-nodes-mp' created successfully on cluster 'my-rosa-cluster'Copy to Clipboard Copied! Toggle word wrap Toggle overflow This creates an additional 2 nodes that can be managed as a unit and also assigns them the labels shown.
Run the following command to confirm machine pool creation and the assigned labels:
rosa list machinepools --cluster=<cluster-name>
rosa list machinepools --cluster=<cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
ID AUTOSCALING REPLICAS INSTANCE TYPE LABELS TAINTS AVAILABILITY ZONES Default No 2 m5.xlarge us-east-1a
ID AUTOSCALING REPLICAS INSTANCE TYPE LABELS TAINTS AVAILABILITY ZONES Default No 2 m5.xlarge us-east-1aCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create a machine pool with the UI.
Log in to the OpenShift Cluster Manager and click your cluster.
Click Machine pools.
- Click Add machine pool.
Enter the desired configuration.
TipYou can also and expand the Edit node labels and taints section to add node labels and taints to the nodes in the machine pool.
You will see the new machine pool you created.
15.9.2. Scaling worker nodes Copy linkLink copied to clipboard!
Edit a machine pool to scale the number of worker nodes in that specific machine pool. You can use either the CLI or the UI to scale worker nodes.
Procedure
Scale worker nodes using the CLI
Run the following command to see the default machine pool that is created with each cluster:
rosa list machinepools --cluster=<cluster-name>
rosa list machinepools --cluster=<cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
ID AUTOSCALING REPLICAS INSTANCE TYPE LABELS TAINTS AVAILABILITY ZONES Default No 2 m5.xlarge us-east-1a
ID AUTOSCALING REPLICAS INSTANCE TYPE LABELS TAINTS AVAILABILITY ZONES Default No 2 m5.xlarge us-east-1aCopy to Clipboard Copied! Toggle word wrap Toggle overflow To scale the default machine pool out to a different number of nodes, run the following command:
rosa edit machinepool --cluster=<cluster-name> --replicas=<number-nodes> <machinepool-name>
rosa edit machinepool --cluster=<cluster-name> --replicas=<number-nodes> <machinepool-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example input
rosa edit machinepool --cluster=my-rosa-cluster --replicas 3 Default
rosa edit machinepool --cluster=my-rosa-cluster --replicas 3 DefaultCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command to confirm that the machine pool has scaled:
rosa describe cluster --cluster=<cluster-name> | grep Compute
rosa describe cluster --cluster=<cluster-name> | grep ComputeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example input
rosa describe cluster --cluster=my-rosa-cluster | grep Compute
$ rosa describe cluster --cluster=my-rosa-cluster | grep ComputeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
- Compute: 3 (m5.xlarge)
- Compute: 3 (m5.xlarge)Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Scaling worker nodes using the UI
- Click the three dots to the right of the machine pool you want to edit.
- Click Edit.
- Enter the desired number of nodes, and click Save.
Confirm that the cluster has scaled by selecting the cluster, clicking the Overview tab, and scrolling to Compute listing. The compute listing should equal the scaled nodes. For example, 3/3.
15.9.2.1. Adding node labels Copy linkLink copied to clipboard!
You can add labels to your worker nodes by using the ROSA command-line interface (CLI) (rosa) tool.
Procedure
Use the following command to add node labels:
rosa edit machinepool --cluster=<cluster-name> --replicas=<number-nodes> --labels='key=value' <machinepool-name>
rosa edit machinepool --cluster=<cluster-name> --replicas=<number-nodes> --labels='key=value' <machinepool-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example input
rosa edit machinepool --cluster=my-rosa-cluster --replicas=2 --labels 'foo=bar','baz=one' new-mp
rosa edit machinepool --cluster=my-rosa-cluster --replicas=2 --labels 'foo=bar','baz=one' new-mpCopy to Clipboard Copied! Toggle word wrap Toggle overflow This adds 2 labels to the new machine pool.
ImportantThis command replaces all machine pool configurations with the newly defined configuration. If you want to add another label and keep the old label, you must state both the new and preexisting the label. Otherwise the command will replace all preexisting labels with the one you wanted to add. Similarly, if you want to delete a label, run the command and state the ones you want, excluding the one you want to delete.
15.9.3. Mixing node types Copy linkLink copied to clipboard!
You can also mix different worker node machine types in the same cluster by using new machine pools. You cannot change the node type of a machine pool once it is created, but you can create a new machine pool with different nodes by adding the --instance-type flag.
Procedure
For example, to change the database nodes to a different node type, run the following command:
rosa create machinepool --cluster=<cluster-name> --name=<mp-name> --replicas=<number-nodes> --labels='<key=pair>' --instance-type=<type>
rosa create machinepool --cluster=<cluster-name> --name=<mp-name> --replicas=<number-nodes> --labels='<key=pair>' --instance-type=<type>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example input
rosa create machinepool --cluster=my-rosa-cluster --name=db-nodes-large-mp --replicas=2 --labels='app=db','tier=backend' --instance-type=m5.2xlarge
rosa create machinepool --cluster=my-rosa-cluster --name=db-nodes-large-mp --replicas=2 --labels='app=db','tier=backend' --instance-type=m5.2xlargeCopy to Clipboard Copied! Toggle word wrap Toggle overflow To see all the instance types available, run the following command:
rosa list instance-types
rosa list instance-typesCopy to Clipboard Copied! Toggle word wrap Toggle overflow To make step-by-step changes, use the
--interactiveflag:rosa create machinepool -c <cluster-name> --interactive
rosa create machinepool -c <cluster-name> --interactiveCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Run the following command to list the machine pools and see the new, larger instance type:
rosa list machinepools -c <cluster-name>
rosa list machinepools -c <cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.10. Tutorial: Autoscaling Copy linkLink copied to clipboard!
The cluster autoscaler adds or removes worker nodes from a cluster based on pod resources.
The cluster autoscaler increases the size of the cluster when:
- Pods fail to schedule on the current nodes due to insufficient resources.
- Another node is necessary to meet deployment needs.
The cluster autoscaler does not increase the cluster resources beyond the limits that you specify.
The cluster autoscaler decreases the size of the cluster when:
- Some nodes are consistently not needed for a significant period. For example, when a node has low resource use and all of its important pods can fit on other nodes.
15.10.1. Enabling autoscaling for an existing machine pool using the CLI Copy linkLink copied to clipboard!
You can enable autoscaling on your machine pools by using the ROSA command-line interface (CLI) (rosa).
Cluster autoscaling can be enabled at cluster creation and when creating a new machine pool by using the --enable-autoscaling option.
Procedure
Autoscaling is set based on machine pool availability. To find out which machine pools are available for autoscaling, run the following command:
rosa list machinepools -c <cluster-name>
$ rosa list machinepools -c <cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
ID AUTOSCALING REPLICAS INSTANCE TYPE LABELS TAINTS AVAILABILITY ZONES Default No 2 m5.xlarge us-east-1a
ID AUTOSCALING REPLICAS INSTANCE TYPE LABELS TAINTS AVAILABILITY ZONES Default No 2 m5.xlarge us-east-1aCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command to add autoscaling to an available machine pool:
rosa edit machinepool -c <cluster-name> --enable-autoscaling <machinepool-name> --min-replicas=<num> --max-replicas=<num>
$ rosa edit machinepool -c <cluster-name> --enable-autoscaling <machinepool-name> --min-replicas=<num> --max-replicas=<num>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example input
rosa edit machinepool -c my-rosa-cluster --enable-autoscaling Default --min-replicas=2 --max-replicas=4
$ rosa edit machinepool -c my-rosa-cluster --enable-autoscaling Default --min-replicas=2 --max-replicas=4Copy to Clipboard Copied! Toggle word wrap Toggle overflow The above command creates an autoscaler for the worker nodes that scales between 2 and 4 nodes depending on the resources.
15.10.2. Enabling autoscaling for an existing machine pool using the UI Copy linkLink copied to clipboard!
You can enable autoscaling on your machine pools in OpenShift Cluster Manager.
Cluster autoscaling can be enabled at cluster creation by checking the Enable autoscaling checkbox when creating machine pools.
Procedure
- Go to the Machine pools tab and click the three dots in the right..
- Click Scale, then Enable autoscaling.
Run the following command to confirm that autoscaling was added:
rosa list machinepools -c <cluster-name>
$ rosa list machinepools -c <cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
ID AUTOSCALING REPLICAS INSTANCE TYPE LABELS TAINTS AVAILABILITY ZONES Default Yes 2-4 m5.xlarge us-east-1a
ID AUTOSCALING REPLICAS INSTANCE TYPE LABELS TAINTS AVAILABILITY ZONES Default Yes 2-4 m5.xlarge us-east-1aCopy to Clipboard Copied! Toggle word wrap Toggle overflow
15.11. Tutorial: Upgrading your cluster Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture executes all cluster upgrades as part of the managed service. You do not need to run any commands or make changes to the cluster. You can schedule the upgrades at a convenient time.
Ways to schedule a cluster upgrade include:
- Manually using the command-line interface (CLI): Start a one-time immediate upgrade or schedule a one-time upgrade for a future date and time.
- Manually using the Red Hat OpenShift Cluster Manager user interface (UI): Start a one-time immediate upgrade or schedule a one-time upgrade for a future date and time.
- Automated upgrades: Set an upgrade window for recurring y-stream upgrades whenever a new version is available without needing to manually schedule it. Minor versions have to be manually scheduled.
For more details about cluster upgrades, run the following command:
rosa upgrade cluster --help
$ rosa upgrade cluster --help
15.11.1. Manually upgrading your cluster using the CLI Copy linkLink copied to clipboard!
You can upgrade your cluster by using the ROSA command-line interface (CLI) (rosa).
Procedure
Check if there is an upgrade available by running the following command:
rosa list upgrade -c <cluster-name>
$ rosa list upgrade -c <cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
rosa list upgrade -c <cluster-name> VERSION NOTES 4.14.7 recommended 4.14.6 ...
$ rosa list upgrade -c <cluster-name> VERSION NOTES 4.14.7 recommended 4.14.6 ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the above example, versions 4.14.7 and 4.14.6 are both available.
Schedule the cluster to upgrade within the hour by running the following command:
rosa upgrade cluster -c <cluster-name> --version <desired-version>
$ rosa upgrade cluster -c <cluster-name> --version <desired-version>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Schedule the cluster to upgrade at a later date and time by running the following command:
rosa upgrade cluster -c <cluster-name> --version <desired-version> --schedule-date <future-date-for-update> --schedule-time <future-time-for-update>
$ rosa upgrade cluster -c <cluster-name> --version <desired-version> --schedule-date <future-date-for-update> --schedule-time <future-time-for-update>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.11.2. Manually upgrading your cluster using the UI Copy linkLink copied to clipboard!
You can upgrade your clusters using the OpenShift Cluster Manager.
Procedure
- Log in to the OpenShift Cluster Manager, and select the cluster you want to upgrade.
- Click Settings.
If an upgrade is available, click Update.
- Select the version to which you want to upgrade in the new window.
- Schedule a time for the upgrade or begin it immediately.
15.11.3. Setting up automatic recurring upgrades Copy linkLink copied to clipboard!
You can set up automatic recurring upgrades within OpenShift Cluster Manager for your clusters.
Procedure
- Log in to the OpenShift Cluster Manager, and select the cluster you want to upgrade.
- Click Settings.
- Under Update Strategy, click Recurring updates.
- Set the day and time for the upgrade to occur.
- Under Node draining, select a grace period to allow the nodes to drain before pod eviction.
- Click Save.
15.12. Tutorial: Deleting your cluster Copy linkLink copied to clipboard!
You can delete your Red Hat OpenShift Service on AWS classic architecture cluster using either the command-line interface (CLI) or the user interface (UI).
15.12.1. Deleting a Red Hat OpenShift Service on AWS classic architecture cluster using the CLI Copy linkLink copied to clipboard!
You can delete your cluster by using the ROSA command-line interface (CLI) (rosa) tool.
Procedure
Optional: List your clusters to make sure you are deleting the correct one by running the following command:
rosa list clusters
$ rosa list clustersCopy to Clipboard Copied! Toggle word wrap Toggle overflow Delete a cluster by running the following command:
rosa delete cluster --cluster <cluster-name>
$ rosa delete cluster --cluster <cluster-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow WarningThis command is non-recoverable.
The CLI prompts you to confirm that you want to delete the cluster. Press y and then Enter. The cluster and all its associated infrastructure will be deleted.
NoteAll AWS STS and IAM roles and policies will remain and must be deleted manually once the cluster deletion is complete by following the steps below.
The CLI outputs the commands to delete the OpenID Connect (OIDC) provider and Operator IAM roles resources that were created. Wait until the cluster finishes deleting before deleting these resources. Perform a quick status check by running the following command:
rosa list clusters
$ rosa list clustersCopy to Clipboard Copied! Toggle word wrap Toggle overflow Once the cluster is deleted, delete the OIDC provider by running the following command:
rosa delete oidc-provider -c <clusterID> --mode auto --yes
$ rosa delete oidc-provider -c <clusterID> --mode auto --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the Operator IAM roles by running the following command:
rosa delete operator-roles -c <clusterID> --mode auto --yes
$ rosa delete operator-roles -c <clusterID> --mode auto --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThis command requires the cluster ID and not the cluster name.
Only remove the remaining account roles if they are no longer needed by other clusters in the same account. If you want to create other Red Hat OpenShift Service on AWS classic architecture clusters in this account, do not perform this step.
To delete the account roles, you need to know the prefix used when creating them. The default is "ManagedOpenShift" unless you specified otherwise.
Delete the account roles by running the following command:
rosa delete account-roles --prefix <prefix> --mode auto --yes
$ rosa delete account-roles --prefix <prefix> --mode auto --yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow
15.12.2. Deleting a Red Hat OpenShift Service on AWS classic architecture cluster using the UI Copy linkLink copied to clipboard!
You can delete your cluster by using OpenShift Cluster Manager.
Procedure
- Log in to the OpenShift Cluster Manager, and locate the cluster you want to delete.
Click the three dots to the right of the cluster.
In the dropdown menu, click Delete cluster.
- Enter the name of the cluster to confirm deletion, and click Delete.
15.13. Tutorial: Obtaining support Copy linkLink copied to clipboard!
Finding the right help when you need it is important. These are some of the resources at your disposal when you need assistance.
15.13.1. Adding support contacts Copy linkLink copied to clipboard!
You can add additional email addresses for communications about your cluster.
Procedure
- On the Red Hat OpenShift Cluster Manager user interface (UI), click select cluster.
- Click the Support tab.
- Click Add notification contact, and enter the additional email addresses.
15.13.2. Contacting Red Hat for support Copy linkLink copied to clipboard!
You can contact support by using the UI or using the support page.
Procedure
Contact Support using the UI
- On the OpenShift Cluster Manager UI, click the Support tab.
- Click Open support case.
Contacting Red Hat for support using the support page
- Go to the Red Hat support page.
Click Open a new Case.
- Log in to your Red Hat account.
Select the reason for contacting support.
Select Red Hat OpenShift Service on AWS.
- Click continue.
Enter a summary of the issue and the details of your request. Upload any files, logs, and screenshots. The more details you provide, the better Red Hat support can help your case.
NoteRelevant suggestions that might help with your issue will appear at the bottom of this page.
- Click Continue.
- Answer the questions in the new fields.
- Click Continue.
Enter the following information about your case:
- Support level: Premium
- Severity: Review the Red Hat Support Severity Level Definitions to choose the correct one.
- Group: If this is related to a few other cases you can select the corresponding group.
- Language
- Send notifications: Add any additional email addresses to keep notified of activity.
- Red Hat associates: If you are working with anyone from Red Hat and want to keep them in the loop you can enter their email address here.
- Alternate Case ID: If you want to attach your own ID to it you can enter it here.
- Click Continue.
On the review screen make sure you select the correct cluster ID that you are contacting support about.
- Click Submit.
- You will be contacted based on the response time committed to for the indicated severity level.
Chapter 16. Deploying an application Copy linkLink copied to clipboard!
16.1. Tutorial: Deploying an application Copy linkLink copied to clipboard!
After successfully provisioning your cluster, you can deploy an application on it. This application allows you to become more familiar with some of the features of Red Hat OpenShift Service on AWS classic architecture and Kubernetes.
16.1.1. Lab overview Copy linkLink copied to clipboard!
In this lab, you will complete the following set of tasks designed to help you understand the concepts of deploying and operating container-based applications:
- Deploy a Node.js based app by using S2I and Kubernetes Deployment objects.
- Set up a continuous delivery (CD) pipeline to automatically push source code changes.
- Explore logging.
- Experience self healing of applications.
- Explore configuration management through configmaps, secrets, and environment variables.
- Use persistent storage to share data across pod restarts.
- Explore networking within Kubernetes and applications.
- Familiarize yourself with ROSA and Kubernetes functionality.
- Automatically scale pods based on loads from the Horizontal Pod Autoscaler.
- Use AWS Controllers for Kubernetes (ACK) to deploy and use an S3 bucket.
This lab uses either the ROSA CLI or Red Hat OpenShift Service on AWS classic architecture web user interface (UI).
16.2. Tutorial: Deploying an application Copy linkLink copied to clipboard!
This tutorial requires a provisioned Red Hat OpenShift Service on AWS classic architecture cluster, the OpenShift CLI, and a GitHub account to complete the prerequisites for deploying an application.
16.2.1. Prerequisites Copy linkLink copied to clipboard!
A provisioned Red Hat OpenShift Service on AWS classic architecture cluster
This lab assumes you have access to a successfully provisioned a Red Hat OpenShift Service on AWS classic architecture cluster. If you have not yet created a Red Hat OpenShift Service on AWS classic architecture cluster, see Red Hat OpenShift Service on AWS classic architecture quick start guide for more information.
The OpenShift Command Line Interface (CLI)
For more information, see Getting started with the OpenShift CLI.
A GitHub Account
Use your existing GitHub account or register at https://github.com/signup.
16.2.1.1. Understanding AWS account association Copy linkLink copied to clipboard!
Before you can use Red Hat OpenShift Cluster Manager on the Red Hat Hybrid Cloud Console to create Red Hat OpenShift Service on AWS classic architecture (ROSA) clusters that use the AWS Security Token Service (STS), you must associate your AWS account with your Red Hat organization. You can associate your account by creating and linking the following IAM roles.
- OpenShift Cluster Manager role
Create an OpenShift Cluster Manager IAM role and link it to your Red Hat organization.
You can apply basic or administrative permissions to the OpenShift Cluster Manager role. The basic permissions enable cluster maintenance using OpenShift Cluster Manager. The administrative permissions enable automatic deployment of the cluster-specific Operator roles and the OpenID Connect (OIDC) provider using OpenShift Cluster Manager.
- User role
Create a user IAM role and link it to your Red Hat user account. The Red Hat user account must exist in the Red Hat organization that is linked to your OpenShift Cluster Manager role.
The user role is used by Red Hat to verify your AWS identity when you use the OpenShift Cluster Manager Hybrid Cloud Console to install a cluster and the required STS resources.
16.2.1.2. Associating your AWS account with your Red Hat organization Copy linkLink copied to clipboard!
Before using Red Hat OpenShift Cluster Manager on the Red Hat Hybrid Cloud Console to create ROSA (classic) clusters that use the AWS Security Token Service (STS), create an OpenShift Cluster Manager IAM role and link it to your Red Hat organization. Then, create a user IAM role and link it to your Red Hat user account in the same Red Hat organization.
Procedure
Create an OpenShift Cluster Manager role and link it to your Red Hat organization:
NoteTo enable automatic deployment of the cluster-specific Operator roles and the OpenID Connect (OIDC) provider using the OpenShift Cluster Manager Hybrid Cloud Console, you must apply the administrative privileges to the role by choosing the Admin OCM role command in the Accounts and roles step of creating a ROSA cluster. For more information about the basic and administrative privileges for the OpenShift Cluster Manager role, see Understanding AWS account association.
NoteIf you choose the Basic OCM role command in the Accounts and roles step of creating a ROSA cluster in the OpenShift Cluster Manager Hybrid Cloud Console, you must deploy a ROSA cluster using manual mode. You will be prompted to configure the cluster-specific Operator roles and the OpenID Connect (OIDC) provider in a later step.
rosa create ocm-role
$ rosa create ocm-roleCopy to Clipboard Copied! Toggle word wrap Toggle overflow Select the default values at the prompts to quickly create and link the role.
Create a user role and link it to your Red Hat user account:
rosa create user-role
$ rosa create user-roleCopy to Clipboard Copied! Toggle word wrap Toggle overflow Select the default values at the prompts to quickly create and link the role.
NoteThe Red Hat user account must exist in the Red Hat organization that is linked to your OpenShift Cluster Manager role.
16.3. Tutorial: Deploying an application Copy linkLink copied to clipboard!
This tutorial teaches you how to deploy an application.
16.3.1. Lab resources Copy linkLink copied to clipboard!
The following section lists all of the various resources that are used in this lab.
- Source code for the OSToy application
- OSToy front-end container image
- OSToy microservice container image
Deployment Definition YAML files:
Example of the
ostoy-frontend-deployment.yamlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example of the
ostoy-microservice-deployment.yamlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow S3 bucket manifest for ACK S3
Example of the
s3-bucket.yamlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
To simplify deployment of the OSToy application, all of the objects required in the above deployment manifests are grouped together. For a typical enterprise deployment, a separate manifest file for each Kubernetes object is recommended.
16.3.2. About the OSToy application Copy linkLink copied to clipboard!
OSToy is a simple Node.js application that you will deploy to a ROSA cluster to help explore the functionality of Kubernetes. This application has a user interface where you can:
- Write messages to the log (stdout / stderr).
- Intentionally crash the application to view self-healing.
- Toggle a liveness probe and monitor OpenShift behavior.
- Read config maps, secrets, and env variables.
- If connected to shared storage, read and write files.
- Check network connectivity, intra-cluster DNS, and intra-communication with the included microservice.
- Increase the load to view automatic scaling of the pods to handle the load using the Horizontal Pod Autoscaler.
- Optional: Connect to an AWS S3 bucket to read and write objects.
16.3.2.1. OSToy Application Diagram Copy linkLink copied to clipboard!
16.3.3. Understanding the OSToy UI Copy linkLink copied to clipboard!
The following diagram explains the various parts of the OSToy application’s UI.
- Shows the pod name that served your browser the page.
- Home: The main page of the application where you can perform some of the functions listed which we will explore.
- Persistent Storage: Allows you to write data to the persistent volume bound to this application.
- Config Maps: Shows the contents of configmaps available to the application and the key:value pairs.
- Secrets: Shows the contents of secrets available to the application and the key:value pairs.
- ENV Variables: Shows the environment variables available to the application.
- Networking: Tools to illustrate networking within the application.
- Pod Auto Scaling: Tool to increase the load of the pods and test the HPA.
ACK S3: Optional: Integrate with AWS S3 to read and write objects to a bucket.
NoteIn order see the "ACK S3" section of OSToy, you must complete the ACK section of this workshop. If you decide not to complete that section, the OSToy application will still function.
- About: Displays more information about the application.
16.4. Tutorial: Deploying an application Copy linkLink copied to clipboard!
You can deploy the OSToy application by creating and storing the images for the front-end and back-end microservice containers in an image repository. You can then create Kubernetes deployments to deploy the application.
16.4.1. Retrieving the login command Copy linkLink copied to clipboard!
To deploy your application, you need to get the CLI login command.
Procedure
- If you are not logged in to the CLI, access your cluster with the web console.
Click the dropdown arrow next to your login name in the upper right, and select Copy Login Command.
A new tab opens.
- Select your authentication method.
- Click Display Token.
- Copy the command under Log in with this token.
From your terminal, paste and run the copied command. If the login is successful, you will see the following confirmation message:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.4.2. Creating a new project by using the CLI Copy linkLink copied to clipboard!
You can use the OpenShift CLI (oc) tool to create your project for this tutorial.
Procedure
Create a new project named
ostoyin your cluster by running following command:oc new-project ostoy
$ oc new-project ostoyCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Now using project "ostoy" on server "https://api.myrosacluster.abcd.p1.openshiftapps.com:6443".
Now using project "ostoy" on server "https://api.myrosacluster.abcd.p1.openshiftapps.com:6443".Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Alternatively, create a unique project name by running the following command:
oc new-project ostoy-$(uuidgen | cut -d - -f 2 | tr '[:upper:]' '[:lower:]')
$ oc new-project ostoy-$(uuidgen | cut -d - -f 2 | tr '[:upper:]' '[:lower:]')Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.4.3. Creating a new project by using the web console Copy linkLink copied to clipboard!
You can create your project using OpenShift Cluster Manager.
Procedure
- From the web console, click Home → Projects.
On the Projects page, click create Create Project.
16.4.4. Deploying the back-end microservice Copy linkLink copied to clipboard!
The microservice serves internal web requests and returns a JSON object containing the current hostname and a randomly generated color string.
Procedure
Deploy the microservice by running the following command from your terminal:
oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yaml
$ oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yaml deployment.apps/ostoy-microservice created service/ostoy-microservice-svc created
$ oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yaml deployment.apps/ostoy-microservice created service/ostoy-microservice-svc createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
16.4.5. Deploying the front-end service Copy linkLink copied to clipboard!
The front-end deployment uses the Node.js front-end for the application and additional Kubernetes objects.
The ostoy-frontend-deployment.yaml file shows that front-end deployment defines the following features:
- Persistent volume claim
- Deployment object
- Service
- Route
- Configmaps
- Secrets
Procedure
Deploy the application front-end and create all of the objects by entering the following command:
oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-frontend-deployment.yaml
$ oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-frontend-deployment.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You should see all objects created successfully.
16.4.6. Getting the route Copy linkLink copied to clipboard!
You must get the route to access the application.
Procedure
Get the route to your application by running the following command:
oc get route
$ oc get routeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD ostoy-route ostoy-route-ostoy.apps.<your-rosa-cluster>.abcd.p1.openshiftapps.com ostoy-frontend-svc <all> None
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD ostoy-route ostoy-route-ostoy.apps.<your-rosa-cluster>.abcd.p1.openshiftapps.com ostoy-frontend-svc <all> NoneCopy to Clipboard Copied! Toggle word wrap Toggle overflow
16.4.7. Viewing the application Copy linkLink copied to clipboard!
After launching your application, you can view the application from your browser.
Procedure
-
Copy the
ostoy-route-ostoy.apps.<your-rosa-cluster>.abcd.p1.openshiftapps.comURL output from the previous step. Paste the copied URL into your web browser and press enter. You should see the homepage of your application. If the page does not load, make sure you use
httpand nothttps.
16.5. Tutorial: Health Check Copy linkLink copied to clipboard!
You can see how Kubernetes responds to pod failure by intentionally crashing your pod and making it unresponsive to the Kubernetes liveness probes.
16.5.1. Preparing your desktop Copy linkLink copied to clipboard!
You can set up your desktop to make this tutorial easier to follow.
Procedure
Split your desktop screen between the OpenShift web console and the OSToy application web console so that you can see the results of your actions immediately.
If you cannot split your screen, open the OSToy application web console in another tab so you can quickly switch to the OpenShift web console after activating the features in the application.
From the OpenShift web console, select Workloads > Deployments > ostoy-frontend to view the OSToy deployment.
16.5.2. Manipulating your pods Copy linkLink copied to clipboard!
You can crash and revive your pods to see how the application reports these statuses.
Procedure
-
From the OSToy application web console, click Home in the left menu, and enter a message in the Crash Pod box, for example,
This is goodbye!. Click Crash Pod.
The pod crashes and Kubernetes should restart the pod.
You can now revive your pod from the OpenShift web console, quickly switch to the Deployments screen. You will see that the pod turns yellow, meaning it is down. It should quickly revive and turn blue. The revival process happens quickly so you might miss it.
Verification
From the web console, click Pods > ostoy-frontend-xxxxxxx-xxxx to change to the pods screen.
Click the Events sub-tab and verify that the container crashed and restarted.
16.5.3. Making the application malfunction Copy linkLink copied to clipboard!
You can force the application that you deployed to malfunction to see how failures show up.
Procedure
From the OSToy application, click Toggle Health in the Toggle Health Status tile. Watch Current Health switch to I’m not feeling all that well.
Verification
After the previous step, the application stops responding with a 200 HTTP code. After 3 consecutive failures, Kubernetes will stop the pod and restart it. From the web console, switch back to the pod events page and you will see that the liveness probe failed and the pod restarted.
The following image shows an example of what you should see on your pod events page.
A. The pod has three consecutive failures. B. Kubernetes stops the pod. C. Kubernetes restarts the pod.
16.6. Tutorial: Persistent volumes for cluster storage Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture supports storing persistent volumes with either Amazon Web Services (AWS) Elastic Block Store (EBS) or AWS Elastic File System (EFS).
16.6.1. Using persistent volumes Copy linkLink copied to clipboard!
Use the following procedures to create a file, store it on a persistent volume in your cluster, and confirm that it still exists after pod failure and re-creation.
Procedure
- View your persistent volume claim by navigating to the cluster’s OpenShift web console.
- Click Storage in the left menu, then click PersistentVolumeClaims to see a list of all the persistent volume claims.
Click a persistence volume claim to see the size, access mode, storage class, and other additional claim details.
NoteThe access mode is
ReadWriteOnce(RWO). This means that the volume can only be mounted to one node and the pod or pods can read and write to the volume.- In the OSToy app console, click Persistent Storage in the left menu.
-
In the Filename box, enter a file name with a
.txtextension, for exampletest-pv.txt. -
In the File contents box, enter a sentence of text, for example
OpenShift is the greatest thing since sliced bread!. Click Create file.
Verification
- Scroll to Existing files on the OSToy app console.
Click the file you created to see the file name and contents.
16.6.2. Crashing the pod Copy linkLink copied to clipboard!
Crash the pod to test that persistent storage persists across pod restarts.
Procedure
- On the OSToy app console, click Home in the left menu.
- Click Crash pod.
16.6.3. Verifying persistent storage Copy linkLink copied to clipboard!
Verify that the file you created persists after the pod is recreated and confirm the contents are intact.
Procedure
- Wait for the pod to re-create.
- On the OSToy app console, click Persistent Storage in the left menu.
Find the file you created, and open it to view and confirm the contents.
Verification
The deployment YAML file shows that we mounted the directory /var/demo_files to our persistent volume claim.
Retrieve the name of your front-end pod by running the following command:
oc get pods
$ oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start a secure shell (SSH) session in your container by running the following command:
oc rsh <pod_name>
$ oc rsh <pod_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Go to the directory by running the following command:
cd /var/demo_files
$ cd /var/demo_filesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: See all the files you created by running the following command:
ls
$ lsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Open the file to view the contents by running the following command:
cat test-pv.txt
$ cat test-pv.txtCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the output is the text you entered in the OSToy app console.
Example terminal
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Type
exitin your terminal to quit the session and return to the CLI.
16.7. Tutorial: ConfigMaps, secrets, and environment variables Copy linkLink copied to clipboard!
This tutorial shows how to configure the OSToy application by using config maps, secrets, and environment variables. For more information, see these linked topics.
16.7.1. Configuration using ConfigMaps Copy linkLink copied to clipboard!
Config maps allow you to decouple configuration artifacts from container image content to keep containerized applications portable.
Procedure
In the OSToy app, in the left menu, click Config Maps, displaying the contents of the config map available to the OSToy application. The code snippet shows an example of a config map configuration:
Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.7.2. Configuration using secrets Copy linkLink copied to clipboard!
Kubernetes Secret objects allow you to store and manage sensitive information, such as passwords, OAuth tokens, and SSH keys. Putting this information in a secret is safer and more flexible than putting it in plain text into a pod definition or a container image.
Procedure
In the OSToy app, in the left menu, click Secrets, displaying the contents of the secrets available to the OSToy application. The code snippet shows an example of a secret configuration:
Example output:
USERNAME=my_user PASSWORD=VVNFUk5BTUU9bXlfdXNlcgpQQVNTV09SRD1AT3RCbCVYQXAhIzYzMlk1RndDQE1UUWsKU01UUD1sb2NhbGhvc3QKU01UUF9QT1JUPTI1 SMTP=localhost SMTP_PORT=25
USERNAME=my_user PASSWORD=VVNFUk5BTUU9bXlfdXNlcgpQQVNTV09SRD1AT3RCbCVYQXAhIzYzMlk1RndDQE1UUWsKU01UUD1sb2NhbGhvc3QKU01UUF9QT1JUPTI1 SMTP=localhost SMTP_PORT=25Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.7.3. Configuration using environment variables Copy linkLink copied to clipboard!
Using environment variables is an easy way to change application behavior without requiring code changes. It allows different deployments of the same application to potentially behave differently based on the environment variables. Red Hat OpenShift Service on AWS classic architecture makes it simple to set, view, and update environment variables for pods or deployments.
Procedure
In the OSToy app, in the left menu, click ENV Variables, displaying the environment variables available to the OSToy application. The code snippet shows an example of an environmental variable configuration:
Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.8. Tutorial: Networking Copy linkLink copied to clipboard!
This tutorial shows how the OSToy app uses intra-cluster networking to separate functions by using microservices and visualize the scaling of pods.
The diagram shows there are at least two separate pods, each with its own service.
One pod functions as the front end web application with a service and a publicly accessible route. The other pod functions as the backend microservice with a service object so that the front end pod can communicate with the microservice. This communication occurs across the pods if more than one. Because of these communication limits, this microservice is not accessible from outside this cluster or from other namespaces or projects if these are configured. The sole purpose of this microservice is to serve internal web requests and return a JSON object containing the current hostname, which is the pod’s name, and a randomly generated color string. This color string is used to display a box with that color displayed in the tile titled "Intra-cluster Communication".
For more information about the networking limitations, see About network policy.
16.8.1. Intra-cluster networking Copy linkLink copied to clipboard!
You can view your networking configurations in your OSToy application.
Procedure
- In the OSToy application, click Networking in the left menu.
Review the networking configuration. The right tile titled "Hostname Lookup" illustrates how the service name created for a pod can be used to translate into an internal ClusterIP address.
Enter the name of the microservice created in the right tile ("Hostname Lookup") following the format of
<service_name>.<namespace>.svc.cluster.local. You can find this service name in the service definition ofostoy-microservice.yamlby running the following command:oc get service <name_of_service> -o yaml
$ oc get service <name_of_service> -o yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this example, the full hostname is
ostoy-microservice-svc.ostoy.svc.cluster.local.You see an IP address returned. In this example it is
172.30.165.246. This is the intra-cluster IP address, which is only accessible from within the cluster.
16.9. Tutorial: Scaling an application Copy linkLink copied to clipboard!
You can manually or automatically scale your pods by using the Horizontal Pod Autoscaler (HPA). You can also scale your cluster nodes.
16.9.1. Manual pod scaling Copy linkLink copied to clipboard!
You can manually scale your application’s pods by using one of the following methods: changing your ReplicaSet or deployment definition, using the command line, or using the web console.
You can manually scale your application’s pods by using one of the following methods:
- Changing your ReplicaSet or deployment definition
- Using the command line
- Using the web console
This workshop starts by using only one pod for the microservice. By defining a replica of 1 in your deployment definition, the Kubernetes Replication Controller strives to keep one pod alive. You then learn how to define pod autoscaling by using the Horizontal Pod Autoscaler(HPA) which is based on the load and will scale out more pods, beyond your initial definition, if high load is experienced.
Prerequisites
- An active ROSA cluster
- A deloyed the OSToy application
Procedure
- In the OSToy app, click the Networking tab in the navigational menu.
In the "Intra-cluster Communication" section, locate the box located beneath "Remote Pods" that randomly changes colors. Inside the box, you see the microservice’s pod name. There is only one box in this example because there is only one microservice pod.
Confirm that there is only one pod running for the microservice by running the following command:
oc get pods
$ oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME READY STATUS RESTARTS AGE ostoy-frontend-679cb85695-5cn7x 1/1 Running 0 1h ostoy-microservice-86b4c6f559-p594d 1/1 Running 0 1h
NAME READY STATUS RESTARTS AGE ostoy-frontend-679cb85695-5cn7x 1/1 Running 0 1h ostoy-microservice-86b4c6f559-p594d 1/1 Running 0 1hCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Download the ostoy-microservice-deployment.yaml and save it to your local machine.
Change the deployment definition to three pods instead of one by using the following example:
spec: selector: matchLabels: app: ostoy-microservice replicas: 3spec: selector: matchLabels: app: ostoy-microservice replicas: 3Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the replica changes by running the following command:
oc apply -f ostoy-microservice-deployment.yaml
$ oc apply -f ostoy-microservice-deployment.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can also edit the
ostoy-microservice-deployment.yamlfile in the OpenShift Web Console by going to the Workloads > Deployments > ostoy-microservice > YAML tab.Confirm that there are now 3 pods by running the following command:
oc get pods
$ oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow The output shows that there are now 3 pods for the microservice instead of only one.
Example output:
NAME READY STATUS RESTARTS AGE ostoy-frontend-5fbcc7d9-rzlgz 1/1 Running 0 26m ostoy-microservice-6666dcf455-2lcv4 1/1 Running 0 81s ostoy-microservice-6666dcf455-5z56w 1/1 Running 0 81s ostoy-microservice-6666dcf455-tqzmn 1/1 Running 0 26m
NAME READY STATUS RESTARTS AGE ostoy-frontend-5fbcc7d9-rzlgz 1/1 Running 0 26m ostoy-microservice-6666dcf455-2lcv4 1/1 Running 0 81s ostoy-microservice-6666dcf455-5z56w 1/1 Running 0 81s ostoy-microservice-6666dcf455-tqzmn 1/1 Running 0 26mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Scale the application by using the CLI or by using the web UI:
In the CLI, decrease the number of pods from
3to2by running the following command:oc scale deployment ostoy-microservice --replicas=2
$ oc scale deployment ostoy-microservice --replicas=2Copy to Clipboard Copied! Toggle word wrap Toggle overflow - From the navigational menu of the OpenShift web console UI, click Workloads > Deployments > ostoy-microservice.
- On the left side of the page, locate the blue circle with a "3 Pod" label in the middle.
Selecting the arrows next to the circle scales the number of pods. Select the down arrow to
2.
Verify your pod counts by using the CLI, the web UI, or the OSToy app:
From the CLI, confirm that you are using two pods for the microservice by running the following command:
oc get pods
$ oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME READY STATUS RESTARTS AGE ostoy-frontend-5fbcc7d9-rzlgz 1/1 Running 0 75m ostoy-microservice-6666dcf455-2lcv4 1/1 Running 0 50m ostoy-microservice-6666dcf455-tqzmn 1/1 Running 0 75m
NAME READY STATUS RESTARTS AGE ostoy-frontend-5fbcc7d9-rzlgz 1/1 Running 0 75m ostoy-microservice-6666dcf455-2lcv4 1/1 Running 0 50m ostoy-microservice-6666dcf455-tqzmn 1/1 Running 0 75mCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the web UI, select Workloads > Deployments > ostoy-microservice.
You can also confirm that there are two pods in use by selecting Networking in the navigational menu of the OSToy app. There should be two colored boxes for the two pods.
16.9.2. Pod Autoscaling Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture offers a Horizontal Pod Autoscaler (HPA) that uses metrics to increase or decrease the number of pods when necessary.
Red Hat OpenShift Service on AWS classic architecture offers a Horizontal Pod Autoscaler (HPA). The HPA uses metrics to increase or decrease the number of pods when necessary.
Procedure
From the navigational menu of the web UI, select Pod Auto Scaling.
Create the HPA by running the following command:
oc autoscale deployment/ostoy-microservice --cpu-percent=80 --min=1 --max=10
$ oc autoscale deployment/ostoy-microservice --cpu-percent=80 --min=1 --max=10Copy to Clipboard Copied! Toggle word wrap Toggle overflow This command creates an HPA that maintains between 1 and 10 replicas of the pods controlled by the ostoy-microservice deployment. Thoughout deployment, HPA increases and decreases the number of replicas to keep the average CPU use across all pods at 80% and 40 millicores.
On the Pod Auto Scaling > Horizontal Pod Autoscaling page, select Increase the load.
ImportantBecause increasing the load generates CPU intensive calculations, the page can become unresponsive. This is an expected response. Click Increase the Load only once. For more information about the process, see the microservice’s GitHub repository.
After a few minutes, the new pods display on the page represented by colored boxes.
NoteThe page can experience lag.
Verification
Check your pod counts with one of the following methods:
In the OSToy application’s web UI, see the remote pods box:
Because there is only one pod, increasing the workload should trigger an increase of pods.
In the CLI, run the following command:
oc get pods --field-selector=status.phase=Running | grep microservice
oc get pods --field-selector=status.phase=Running | grep microserviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
ostoy-microservice-79894f6945-cdmbd 1/1 Running 0 3m14s ostoy-microservice-79894f6945-mgwk7 1/1 Running 0 4h24m ostoy-microservice-79894f6945-q925d 1/1 Running 0 3m14s
ostoy-microservice-79894f6945-cdmbd 1/1 Running 0 3m14s ostoy-microservice-79894f6945-mgwk7 1/1 Running 0 4h24m ostoy-microservice-79894f6945-q925d 1/1 Running 0 3m14sCopy to Clipboard Copied! Toggle word wrap Toggle overflow You can also verify autoscaling from the OpenShift Cluster Manager
- In the OpenShift web console navigational menu, click Observe > Dashboards.
In the dashboard, select Kubernetes / Compute Resources / Namespace (Pods) and your namespace ostoy.
A graph appears showing your resource usage across CPU and memory. The top graph shows recent CPU consumption per pod and the lower graph indicates memory usage. The following lists the callouts in the graph:
- The load increased (A).
- Two new pods were created (B and C).
- The thickness of each graph represents the CPU consumption and indicates which pods handled more load.
The load decreased (D), and the pods were deleted.
16.9.3. Node Autoscaling Copy linkLink copied to clipboard!
Red Hat OpenShift Service on AWS classic architecture allows you to use node autoscaling. In this scenario, you will create a new project with a job that has a large workload that the cluster cannot handle. With autoscaling enabled, when the load is larger than your current capacity, the cluster will automatically create new nodes to handle the load.
Red Hat OpenShift Service on AWS classic architecture allows you to use node autoscaling. In this scenario, you will create a new project with a job that has a large workload that the cluster cannot handle. With autoscaling enabled, when the load is larger than your current capacity, the cluster will automatically create new nodes to handle the load.
Prerequisites
- Autoscaling is enabled on your machine pools.
Procedure
Create a new project called
autoscale-exby running the following command:oc new-project autoscale-ex
$ oc new-project autoscale-exCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the job by running the following command:
oc create -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/job-work-queue.yaml
$ oc create -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/job-work-queue.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow After a few minuts, run the following command to see the pods:
oc get pods
$ oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Because there are many pods in a
Pendingstate, this status should trigger the autoscaler to create more nodes in your machine pool. Allow time to create these worker nodes. After a few minutes, use the following command to see how many worker nodes you now have:
oc get nodes
$ oc get nodesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can see the worker nodes were automatically created to handle the workload.
Return to the OSToy app by entering the following command:
oc project ostoy
$ oc project ostoyCopy to Clipboard Copied! Toggle word wrap Toggle overflow
16.10. Tutorial: Logging Copy linkLink copied to clipboard!
There are various methods to view your logs in Red Hat OpenShift Service on AWS. Use the following procedures to forward the logs to AWS CloudWatch and view the logs directly through the pod by using oc logs.
Red Hat OpenShift Service on AWS classic architecture is not preconfigured with a logging solution.
16.10.1. Forwarding logs to CloudWatch Copy linkLink copied to clipboard!
Install the logging add-on service to forward the logs to AWS CloudWatch.
Procedure
Run the following script to configure your Red Hat OpenShift Service on AWS classic architecture cluster to forward logs to CloudWatch:
curl https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/resources/configure-cloudwatch.sh | bash
$ curl https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/resources/configure-cloudwatch.sh | bashCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteConfiguring Red Hat OpenShift Service on AWS classic architecture to send logs to CloudWatch goes beyond the scope of this tutorial. Integrating with AWS and enabling CloudWatch logging are important aspects of Red Hat OpenShift Service on AWS classic architecture, so a script is included to simplify the configuration process. The script will automatically set up AWS CloudWatch. You can examine the script to understand the steps involved.
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow After a few minutes, you should begin to see log groups inside of AWS CloudWatch. Run the following command to see the log groups:
aws logs describe-log-groups --log-group-name-prefix rosa-mycluster
$ aws logs describe-log-groups --log-group-name-prefix rosa-myclusterCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.10.2. Outputting the data to the streams and logs Copy linkLink copied to clipboard!
Output your data to the streams and logs in the OSToy application.
Procedure
Output a message to
stdout.- In the OSToy application, click Home and then click the message box for Log Message (stdout).
-
Write a message to output to the
stdoutstream, for example "All is well!". Click Send Message.
Output a message to
stderr.- Click the message box for Log Message (stderr).
-
Write a message to output to the
stderrstream, for example "Oh no! Error!". Click Send Message.
16.10.3. Viewing the application logs Copy linkLink copied to clipboard!
You can view your application’s logs by using the oc command.
Procedure
Enter the following command in the command-line interface (CLI) to retrieve the name of your frontend pod:
oc get pods -o name
$ oc get pods -o nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
pod/ostoy-frontend-679cb85695-5cn7x pod/ostoy-microservice-86b4c6f559-p594d
pod/ostoy-frontend-679cb85695-5cn7x1 pod/ostoy-microservice-86b4c6f559-p594dCopy to Clipboard Copied! Toggle word wrap Toggle overflow The pod name in this example is
ostoy-frontend-679cb85695-5cn7x.Run the following command to see both the
stdoutandstderrmessages:oc logs <pod-name>
$ oc logs <pod-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.10.4. Viewing the logs with CloudWatch Copy linkLink copied to clipboard!
You can verify your logs within CloudWatch on the AWS web console.
Procedure
- Navigate to CloudWatch on the AWS web console.
In the left menu, click Logs and then Log groups to see the different groups of logs. You should see 3 groups:
-
rosa-<cluster-name>.application -
rosa-<cluster-name>.audit rosa-<cluster-name>.infrastructure
-
-
Click
rosa-<cluster-name>.application. Click the log stream for the frontend pod.
-
Filter for
stdoutandstderr. Expand the row to show the messages you entered earlier and other pertinent information.
- Return to the log streams and select the microservice.
- Enter "microservice" in the search bar to see other messages in your logs.
Expand one of the entries to see the color the frontend pod received from microservice and which pod sent that color to the frontend pod.
16.11. Tutorial: S2I deployments Copy linkLink copied to clipboard!
There are several methods to deploy applications in OpenShift. This tutorial explores using the integrated Source-to-Image (S2I) builder. As mentioned in the OpenShift concepts section, S2I is a tool for building reproducible, Docker-formatted container images.
16.11.1. Prerequisites Copy linkLink copied to clipboard!
The following requirements must be completed before you can use this tutorial.
- You have created a Red Hat OpenShift Service on AWS classic architecture cluster.
- Retrieve your login command
Create a new project from the CLI by running the following command:
oc new-project ostoy-s2i
$ oc new-project ostoy-s2iCopy to Clipboard Copied! Toggle word wrap Toggle overflow
16.11.2. Fork the OSToy repository Copy linkLink copied to clipboard!
The next section focuses on triggering automated builds based on changes to the source code. You must set up a GitHub webhook to trigger S2I builds when you push code into your GitHub repo.
Procedure
To set up the webhook, you must first fork the repo.
NoteReplace
<UserName>with your own GitHub username for the following URLs in this guide.
16.11.3. Using S2i to deploy OSToy on your cluster Copy linkLink copied to clipboard!
You can use source-to-image (S2i) to deploy your OSToy app onto your cluster.
Procedure
Add secret to OpenShift
The example emulates a
.envfile and shows how easy it is to move these directly into an OpenShift environment. Files can even be renamed in the Secret. In your CLI enter the following command, replacing<UserName>with your GitHub username:oc create -f https://raw.githubusercontent.com/<UserName>/ostoy/master/deployment/yaml/secret.yaml
$ oc create -f https://raw.githubusercontent.com/<UserName>/ostoy/master/deployment/yaml/secret.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add ConfigMap to OpenShift
The example emulates an HAProxy config file, and is typically used for overriding default configurations in an OpenShift application. Files can even be renamed in the ConfigMap.
In your CLI enter the following command, replacing
<UserName>with your GitHub username:oc create -f https://raw.githubusercontent.com/<UserName>/ostoy/master/deployment/yaml/configmap.yaml
$ oc create -f https://raw.githubusercontent.com/<UserName>/ostoy/master/deployment/yaml/configmap.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the microservice
You must deploy the microservice first to ensure that the SERVICE environment variables are available from the UI application.
--context-diris used here to only build the application defined in themicroservicedirectory in the git repository. Using theapplabel allows us to ensure the UI application and microservice are both grouped in the OpenShift UI. Run the following command in the CLI to create the microservice, replacing<UserName>with your GitHub username:oc new-app https://github.com/<UserName>/ostoy \ --context-dir=microservice \ --name=ostoy-microservice \ --labels=app=ostoy$ oc new-app https://github.com/<UserName>/ostoy \ --context-dir=microservice \ --name=ostoy-microservice \ --labels=app=ostoyCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the status of the microservice
Before moving onto the next step we should be sure that the microservice was created and is running correctly by running the following command:
oc status
$ oc statusCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Wait until you see that it was successfully deployed. You can also check this through the web UI.
Deploy the front end UI
The application has been designed to rely on several environment variables to define external settings. Attach the previously created Secret and ConfigMap afterward, along with creating a PersistentVolume. Enter the following into the CLI:
oc new-app https://github.com/<UserName>/ostoy \ --env=MICROSERVICE_NAME=OSTOY_MICROSERVICE$ oc new-app https://github.com/<UserName>/ostoy \ --env=MICROSERVICE_NAME=OSTOY_MICROSERVICECopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the Deployment
Update the deployment to use a "Recreate" deployment strategy (as opposed to the default of
RollingUpdate) for consistent deployments with persistent volumes. Reasoning here is that the PV is backed by EBS and as such only supports theRWOmethod. If the deployment is updated without all existing pods being killed it might not be able to schedule a new pod and create a PVC for the PV as it’s still bound to the existing pod. If you will be using EFS you do not have to change this.oc patch deployment ostoy --type=json -p \ '[{"op": "replace", "path": "/spec/strategy/type", "value": "Recreate"}, {"op": "remove", "path": "/spec/strategy/rollingUpdate"}]'$ oc patch deployment ostoy --type=json -p \ '[{"op": "replace", "path": "/spec/strategy/type", "value": "Recreate"}, {"op": "remove", "path": "/spec/strategy/rollingUpdate"}]'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set a Liveness probe
Create a Liveness Probe on the Deployment to ensure the pod is restarted if something isn’t healthy within the application. Enter the following into the CLI:
oc set probe deployment ostoy --liveness --get-url=http://:8080/health
$ oc set probe deployment ostoy --liveness --get-url=http://:8080/healthCopy to Clipboard Copied! Toggle word wrap Toggle overflow Attach Secret, ConfigMap, and PersistentVolume to Deployment
Run the following commands attach your secret, ConfigMap, and PersistentVolume:
Attach Secret
oc set volume deployment ostoy --add \ --secret-name=ostoy-secret \ --mount-path=/var/secret$ oc set volume deployment ostoy --add \ --secret-name=ostoy-secret \ --mount-path=/var/secretCopy to Clipboard Copied! Toggle word wrap Toggle overflow Attach ConfigMap
oc set volume deployment ostoy --add \ --configmap-name=ostoy-config \ -m /var/config$ oc set volume deployment ostoy --add \ --configmap-name=ostoy-config \ -m /var/configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create and attach PersistentVolume
oc set volume deployment ostoy --add \ --type=pvc \ --claim-size=1G \ -m /var/demo_files$ oc set volume deployment ostoy --add \ --type=pvc \ --claim-size=1G \ -m /var/demo_filesCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Expose the UI application as an OpenShift Route
Run the following command to deploy this as an HTTPS application that uses the included TLS wildcard certificates:
oc create route edge --service=ostoy --insecure-policy=Redirect
$ oc create route edge --service=ostoy --insecure-policy=RedirectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Browse to your application with the following methods:
Running the following command opens a web browser with your OSToy application:
python -m webbrowser "$(oc get route ostoy -o template --template='https://{{.spec.host}}')"$ python -m webbrowser "$(oc get route ostoy -o template --template='https://{{.spec.host}}')"Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can get the route for the application and copy and paste the route into your browser by running the following command:
oc get route
$ oc get routeCopy to Clipboard Copied! Toggle word wrap Toggle overflow
16.12. Tutorial: Using Source-to-Image (S2I) webhooks for automated deployment Copy linkLink copied to clipboard!
Automatically trigger a build and deploy anytime you change the source code by using a webhook. For more information about this process, see Triggering Builds.
16.12.1. Setting up S2I webhooks for automated deployment Copy linkLink copied to clipboard!
This procedure guides you through setting up a GitHub webhook to automatically trigger builds and deployments when you push changes to your source code repository.
Procedure
To get the GitHub webhook trigger secret, in your terminal, run the following command:
oc get bc/ostoy-microservice -o=jsonpath='{.spec.triggers..github.secret}'$ oc get bc/ostoy-microservice -o=jsonpath='{.spec.triggers..github.secret}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
`o_3x9M1qoI2Wj_cz1WiK`
`o_3x9M1qoI2Wj_cz1WiK`Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantYou need to use this secret in a later step in this process.
To get the GitHub webhook trigger URL from the OSToy’s buildconfig, run the following command:
oc describe bc/ostoy-microservice
$ oc describe bc/ostoy-microserviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
[...] Webhook GitHub: URL: https://api.demo1234.openshift.com:443/apis/build.openshift.io/v1/namespaces/ostoy-s2i/buildconfigs/ostoy/webhooks/<secret>/github [...]
[...] Webhook GitHub: URL: https://api.demo1234.openshift.com:443/apis/build.openshift.io/v1/namespaces/ostoy-s2i/buildconfigs/ostoy/webhooks/<secret>/github [...]Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the GitHub webhook URL, replace the
<secret>text with the secret you retrieved. Your URL will resemble the following example output:Example output:
https://api.demo1234.openshift.com:443/apis/build.openshift.io/v1/namespaces/ostoy-s2i/buildconfigs/ostoy-microservice/webhooks/o_3x9M1qoI2Wj_czR1WiK/github
https://api.demo1234.openshift.com:443/apis/build.openshift.io/v1/namespaces/ostoy-s2i/buildconfigs/ostoy-microservice/webhooks/o_3x9M1qoI2Wj_czR1WiK/githubCopy to Clipboard Copied! Toggle word wrap Toggle overflow Setup the webhook URL in GitHub repository.
In your repository, click Settings > Webhooks > Add webhook.
-
Paste the GitHub webhook URL with the
Secretincluded into the "Payload URL" field. -
Change the "Content type" to
application/json. Click the Add webhook button.
You should see a message from GitHub stating that your webhook was successfully configured. Now, whenever you push a change to your GitHub repository, a new build automatically starts, and upon a successful build, a new deployment starts.
Now, make a change in the source code. Any changes automatically trigger a build and deployment. In this example, the colors that denote the status of your OSToy app are selected randomly. To test the configuration, change the box to only display grayscale.
- Go to the source code in your repository https://github.com/<username>/ostoy/blob/master/microservice/app.js.
- Edit the file.
-
Comment out line 8 (containing
let randomColor = getRandomColor();). Uncomment line 9 (containing
let randomColor = getRandomGrayScaleColor();).7 app.get('/', function(request, response) { 8 //let randomColor = getRandomColor(); // <-- comment this 9 let randomColor = getRandomGrayScaleColor(); // <-- uncomment this 10 11 response.writeHead(200, {'Content-Type': 'application/json'});7 app.get('/', function(request, response) { 8 //let randomColor = getRandomColor(); // <-- comment this 9 let randomColor = getRandomGrayScaleColor(); // <-- uncomment this 10 11 response.writeHead(200, {'Content-Type': 'application/json'});Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Enter a message for the update, such as "changed box to grayscale colors".
- Click Commit at the bottom to commit the changes to the main branch.
In your cluster’s web UI, click Builds > Builds to determine the status of the build. After this build is completed, the deployment begins. You can also check the status by running
oc statusin your terminal.
After the deployment has finished, return to the OSToy application in your browser. Access the Networking menu item on the left. The box color is now limited to grayscale colors only.
16.13. Tutorial: Integrating with AWS Services Copy linkLink copied to clipboard!
Although the OSToy application functions independently, many real-world applications require external services such as databases, object stores, or messaging services.
Objectives
- Learn how to integrate the OSToy application with other Amazon Web Services (AWS) services, specifically AWS S3 Storage. By the end of this section, the application will securely create and read objects from AWS S3 Storage.
- Use the Amazon Controller for Kubernetes (ACK) to create the necessary services for our application directly from Kubernetes.
- Use Identity and Access Management (IAM) roles for service accounts to manage access and authentication.
- Use OSToy to create a basic text file and save it in an S3 bucket.
- Confirm that the file was successfully added and can be read from the bucket.
16.13.1. Amazon Controller for Kubernetes (ACK) Copy linkLink copied to clipboard!
With ACK, you can create an S3 bucket, integrate it with the OSToy application, upload a file to it, and view the file in your application.
Procedure
- Use the ACK to create and use AWS services directly from Kubernetes. You can deploy your applications directly in the Kubernetes framework by using a familiar structure to declaratively define and create AWS services such as S3 buckets or Relational Database Service (RDS) databases.
16.13.2. IAM roles for service accounts Copy linkLink copied to clipboard!
You can use IAM roles for service accounts to assign IAM roles directly to Kubernetes service accounts. You can use it to grant the ACK controller credentials to deploy services in your AWS account. Use IAM roles for service accounts to automate the management and rotation of temporary credentials.
Pods receive a valid OpenID Connect (OIDC) JSON web token (JWT) and pass it to the AWS STS AssumeRoleWithWebIdentity API operation to receive IAM temporary role credentials. The process relies on the EKS pod identity mutating webhook which modifies pods that require AWS IAM access.
IAM roles for service accounts adheres to the following best practices:
- Principle of least privilege: You can create IAM permissions for AWS roles that only allow limited access. These permissions are limited to the service account associated with the role and only the pods that use that service account have access.
- Credential isolation: A pod can only retrieve credentials for the IAM role associated with the service account that the pod is using.
- Auditing: All AWS resource access can be viewed in CloudTrail.
16.13.3. Installing the ACK controller Copy linkLink copied to clipboard!
Install the ACK controller to create and delete buckets in the S3 service by using a Kubernetes custom resource for the bucket. Installing the controller will also create the required namespace and service account.
We will use an Operator to make it easy. The Operator installation will also create an ack-system namespace and a service account ack-s3-controller for you.
Procedure
- Log in to the cluster console.
- On the left menu, click Ecosystem, then Software Catalog.
In the filter box, enter "S3" and select AWS Controller for Kubernetes - Amazon S3.
- If a pop-up about community operators appears, click Continue.
- Click Install.
- Select All namespaces on the cluster under "Installation mode".
- Select ack-system under "Installed Namespace".
Select Manual under "Update approval".
ImportantMake sure Manual Mode is selected so changes to the service account are not overwritten by an automatic operator update.
Click Install.
The settings should look like the below image.
- Click Approve.
- The installation begins but will not complete until you have created an IAM role and policy for the ACK controller.
16.13.4. Creating an IAM role and policy for the ACK controller Copy linkLink copied to clipboard!
Create the IAM roles and policies for the ACK controller by using the provided scripts.
Procedure
Run one of the following scripts to create the AWS IAM role for the ACK controller and assign the S3 policy:
- Automatically download the setup-s3-ack-controller.sh script, which automates the process for you.
Run the following script in your command-line interface (CLI):
curl https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/resources/setup-s3-ack-controller.sh | bash
$ curl https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/resources/setup-s3-ack-controller.sh | bashCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- When the script completes, it restarts the deployment which updates the service controller pods with the IAM roles for service accounts environment variables.
Confirm that the environment variables are set by running the following command:
oc describe pod ack-s3-controller -n ack-system | grep "^\s*AWS_"
$ oc describe pod ack-s3-controller -n ack-system | grep "^\s*AWS_"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
AWS_ROLE_ARN: arn:aws:iam::000000000000:role/ack-s3-controller AWS_WEB_IDENTITY_TOKEN_FILE: /var/run/secrets/eks.amazonaws.com/serviceaccount/token
AWS_ROLE_ARN: arn:aws:iam::000000000000:role/ack-s3-controller AWS_WEB_IDENTITY_TOKEN_FILE: /var/run/secrets/eks.amazonaws.com/serviceaccount/tokenCopy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm successful setup of the ACK controller in the web console by clicking Operators and then Installed operators.
If you do not see a successful Operator installation and the environment variables, manually restart the deployment by running the following command:
oc rollout restart deployment ack-s3-controller -n ack-system
$ oc rollout restart deployment ack-s3-controller -n ack-systemCopy to Clipboard Copied! Toggle word wrap Toggle overflow
16.13.5. Setting up access for the application Copy linkLink copied to clipboard!
You can create an AWS IAM role and service account so that OSToy can read and write objects to an S3 bucket.
Procedure
Create a new unique project for OSToy by running the following command:
oc new-project ostoy-$(uuidgen | cut -d - -f 2 | tr '[:upper:]' '[:lower:]')
$ oc new-project ostoy-$(uuidgen | cut -d - -f 2 | tr '[:upper:]' '[:lower:]')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Save the name of the namespace and project to an environment variable by running the following command:
export OSTOY_NAMESPACE=$(oc config view --minify -o 'jsonpath={..namespace}')$ export OSTOY_NAMESPACE=$(oc config view --minify -o 'jsonpath={..namespace}')Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.13.6. Creating an AWS IAM role Copy linkLink copied to clipboard!
You can use the aws CLI to create your AWS IAM role.
Procedure
Get your AWS account ID by running the following command:
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
$ export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Get the OIDC provider by running the following command, replacing
<cluster-name>with the name of your cluster:export OIDC_PROVIDER=$(rosa describe cluster -c <cluster-name> -o yaml | awk '/oidc_endpoint_url/ {print $2}' | cut -d '/' -f 3,4)$ export OIDC_PROVIDER=$(rosa describe cluster -c <cluster-name> -o yaml | awk '/oidc_endpoint_url/ {print $2}' | cut -d '/' -f 3,4)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the trust policy file by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the AWS IAM role to be used with your service account by running the following command:
aws iam create-role --role-name "ostoy-sa-role" --assume-role-policy-document file://ostoy-sa-trust.json
$ aws iam create-role --role-name "ostoy-sa-role" --assume-role-policy-document file://ostoy-sa-trust.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow
16.13.7. Attaching the S3 policy to the IAM role Copy linkLink copied to clipboard!
After you created your IAM role, you can use the aws CLI to attach the S3 policy to this created role.
Procedure
Get the S3 full access policy ARN by running the following command:
export POLICY_ARN=$(aws iam list-policies --query 'Policies[?PolicyName==`AmazonS3FullAccess`].Arn' --output text)
$ export POLICY_ARN=$(aws iam list-policies --query 'Policies[?PolicyName==`AmazonS3FullAccess`].Arn' --output text)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Attach the policy to the AWS IAM role by running the following command:
aws iam attach-role-policy --role-name "ostoy-sa-role" --policy-arn "${POLICY_ARN}"$ aws iam attach-role-policy --role-name "ostoy-sa-role" --policy-arn "${POLICY_ARN}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.13.8. Creating the service account for your pod Copy linkLink copied to clipboard!
Create your new service account that you use on your pod.
Procedure
Get the ARN for the AWS IAM role we created so that it will be included as an annotation when you create your service account by running the following command:
export APP_IAM_ROLE_ARN=$(aws iam get-role --role-name=ostoy-sa-role --query Role.Arn --output text)
$ export APP_IAM_ROLE_ARN=$(aws iam get-role --role-name=ostoy-sa-role --query Role.Arn --output text)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the service account by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantDo not change the name of the service account from "ostoy-sa" or you will have to change the trust relationship for the AWS IAM role.
Grant the service account the
restrictedrole by running the following command:oc adm policy add-scc-to-user restricted system:serviceaccount:${OSTOY_NAMESPACE}:ostoy-sa$ oc adm policy add-scc-to-user restricted system:serviceaccount:${OSTOY_NAMESPACE}:ostoy-saCopy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm that the annotation was successful by running the following command:
oc describe serviceaccount ostoy-sa -n ${OSTOY_NAMESPACE}$ oc describe serviceaccount ostoy-sa -n ${OSTOY_NAMESPACE}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.13.9. Creating an S3 bucket Copy linkLink copied to clipboard!
Use the OpenShift CLI (oc) tool to create your S3 bucket.
Procedure
Create an S3 bucket using a manifest file by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantThe OSToy application expects to find a bucket named
<namespace>-bucket. If you use anything other than the namespace of your OSToy project, this feature will not work. For example, if our project is "ostoy", the value fornamemust beostoy-bucket.Confirm the bucket was created by running the following command:
aws s3 ls | grep ${OSTOY_NAMESPACE}-bucket$ aws s3 ls | grep ${OSTOY_NAMESPACE}-bucketCopy to Clipboard Copied! Toggle word wrap Toggle overflow
16.13.10. Redeploying the OSToy app with the new service account Copy linkLink copied to clipboard!
After creating the new service account, you need to redeploy the OSToy app.
Procedure
- Run your pod with the service account you created.
Deploy the microservice by running the following command:
- oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yaml
$ - oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the
ostoy-frontendby running the following command:- oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-frontend-deployment.yaml
$ - oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-frontend-deployment.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Patch the
ostoy-frontenddeployment by running the following command:oc patch deploy ostoy-frontend -n ${OSTOY_NAMESPACE} --type=merge --patch '{"spec": {"template": {"spec":{"serviceAccount":"ostoy-sa"}}}}'$ oc patch deploy ostoy-frontend -n ${OSTOY_NAMESPACE} --type=merge --patch '{"spec": {"template": {"spec":{"serviceAccount":"ostoy-sa"}}}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Wait for the pod to update.
16.13.11. Confirming the environment variables Copy linkLink copied to clipboard!
Before continuing, you need to verify that the environment variables are correct.
Procedure
Use the following command to describe the pods and verify that the
AWS_WEB_IDENTITY_TOKEN_FILEandAWS_ROLE_ARNenvironment variables exist for our application:oc describe pod ostoy-frontend -n ${OSTOY_NAMESPACE} | grep "^\s*AWS_"$ oc describe pod ostoy-frontend -n ${OSTOY_NAMESPACE} | grep "^\s*AWS_"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
AWS_ROLE_ARN: arn:aws:iam::000000000000:role/ostoy-sa AWS_WEB_IDENTITY_TOKEN_FILE: /var/run/secrets/eks.amazonaws.com/serviceaccount/token
AWS_ROLE_ARN: arn:aws:iam::000000000000:role/ostoy-sa AWS_WEB_IDENTITY_TOKEN_FILE: /var/run/secrets/eks.amazonaws.com/serviceaccount/tokenCopy to Clipboard Copied! Toggle word wrap Toggle overflow
16.13.12. Viewing the bucket contents through OSToy Copy linkLink copied to clipboard!
Use your app to view the contents of your S3 bucket.
Procedure
Get the route for the newly deployed application by running the following command:
oc get route ostoy-route -n ${OSTOY_NAMESPACE} -o jsonpath='{.spec.host}{"\n"}'$ oc get route ostoy-route -n ${OSTOY_NAMESPACE} -o jsonpath='{.spec.host}{"\n"}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Open a new browser tab and enter the route obtained in the previous step.
ImportantBe sure to use
http://and nothttps://.- Click ACK S3 in the left menu in OSToy.
Because it is a new bucket, the bucket should be empty.
16.13.13. Creating files in your S3 bucket Copy linkLink copied to clipboard!
Use OStoy to create a file and upload it to the S3 bucket. While S3 can accept any kind of file, for this tutorial use text files so that the contents can easily be rendered in the browser.
Procedure
- Click ACK S3 in the left menu in OSToy.
- Scroll down to Upload a text file to S3.
- Enter a file name for your file.
- Enter content for your file.
Click Create file.
- Scroll to the top section for existing files and confirm that the file you just created is there.
Click the file name to view the file.
Confirm with the AWS CLI by running the following command to list the contents of your bucket:
aws s3 ls s3://${OSTOY_NAMESPACE}-bucket$ aws s3 ls s3://${OSTOY_NAMESPACE}-bucketCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
aws s3 ls s3://ostoy-bucket 2023-05-04 22:20:51 51 OSToy.txt
$ aws s3 ls s3://ostoy-bucket 2023-05-04 22:20:51 51 OSToy.txtCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Legal Notice
Copy linkLink copied to clipboard!
Copyright © Red Hat
OpenShift documentation is licensed under the Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0).
Modified versions must remove all Red Hat trademarks.
Portions adapted from https://github.com/kubernetes-incubator/service-catalog/ with modifications by Red Hat.
Red Hat, Red Hat Enterprise Linux, the Red Hat logo, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of the OpenJS Foundation.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation’s permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.