Chapter 4. Tutorial: Deploy Red Hat OpenShift Service on AWS with a custom DNS resolver
Use a custom Dynamic Host Configuration Protocol (DHCP) option set to customize your Virtual Private Cloud (VPC) with your own Domain Name System (DNS) server, domain name, and more. Red Hat OpenShift Service on AWS clusters support using custom DHCP option sets.
By default, Red Hat OpenShift Service on AWS clusters require setting the "domain name servers" option to AmazonProvidedDNS to ensure successful cluster creation and operation. If you want to use custom DNS servers for DNS resolution, you must do additional configuration to ensure successful Red Hat OpenShift Service on AWS cluster creation and operation.
In this tutorial, you configure a DNS server to forward DNS lookups for specific DNS zones to an Amazon Route 53 Inbound Resolver. For more information, see Additional resources.
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 cluster into. Refer to the documentation of your preferred DNS server for how to configure zone forwarding.
4.1. Set up your environment Copy linkLink copied to clipboard!
You can use environment variables to ensure consistency across the commands within this lab.
Prerequisites
-
You have access to the ROSA command-line interface (CLI) (
rosa). -
You have access to the AWS CLI (
aws). - You have manually created an AWS Virtual Private Cloud (VPC).
- You have configured a DHCP option set to point to a custom DNS server and set as the default for your VPC.
Procedure
In your terminal, configure the following environment variables:
$ export VPC_ID=<vpc_ID> $ export REGION=<region> $ export VPC_CIDR=<vpc_CIDR>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}"
4.2. Create an Amazon Route 53 Inbound Resolver Copy linkLink copied to clipboard!
Deploy an Amazon Route 53 Inbound Resolver in the Virtual Private Cloud (VPC) where you plan to deploy the cluster. With the inbound resolver, your DNS server can forward queries to Route 53.
In this example, the Amazon Route 53 Inbound Resolver is deployed into the same VPC the cluster uses. If you want to deploy it into a separate VPC, you must manually associate the private hosted zone(s) 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}Create an Amazon Route 53 Inbound Resolver in your VPC:
$ RESOLVER_ID=$(aws route53resolver create-resolver-endpoint \ --name rosa-inbound-resolver \ --creator-request-id rosa-$(date '+%Y-%m-%d') \ --security-group-ids ${SG_ID} \ --direction INBOUND \ --ip-addresses $(aws ec2 describe-subnets --filter Name=vpc-id,Values=${VPC_ID} --region ${REGION} | jq -jr '.Subnets | map("SubnetId=\(.SubnetId) ") | .[]') \ --region ${REGION} \ --output text \ --query 'ResolverEndpoint.Id')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, the IP addresses, or both, run the following command instead:
$ RESOLVER_ID=$(aws route53resolver create-resolver-endpoint \ --name rosa-inbound-resolver \ --creator-request-id rosa-$(date '+%Y-%m-%d') \ --security-group-ids ${SG_ID} \ --direction INBOUND \ --ip-addresses SubnetId=<subnet_ID>,Ip=<endpoint_IP> SubnetId=<subnet_ID>,Ip=<endpoint_IP> \ --region ${REGION} \ --output text \ --query 'ResolverEndpoint.Id')+ where:
<subnet_ID>- Specifies the subnet ID you want inbound resolver endpoints added to.
<endpoint_IP>- Specifies 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'Example output
[ "10.0.45.253", "10.0.23.131", "10.0.148.159" ]
4.3. Configure your DNS server Copy linkLink copied to clipboard!
Configure your Domain Name System (DNS) server to forward the private hosted zones to your Amazon Route 53 Inbound Resolver so the Red Hat OpenShift Service on AWS cluster can resolve internal DNS names after creation.
The following private hosted zones must be forwarded:
-
<cluster-name>.hypershift.local -
rosa.<domain-prefix>.<unique-ID>.p3.openshiftapps.com
These Amazon Route 53 private hosted zones are created during cluster creation. The cluster-name and domain-prefix are customer-specified values, 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 p3.openshiftapps.com private hosted zone.
Procedure
Before the cluster is created, configure your DNS server to forward all DNS requests for
<cluster-name>.hypershift.localto your Amazon Route 53 Inbound Resolver endpoints.If you use a BIND DNS server, add a new zone to the
/etc/named.conffile using the following example:zone "<cluster-name>.hypershift.local" { type forward; forward only; forwarders { 10.0.45.253; 10.0.23.131; 10.0.148.159; }; };-
Replace
<cluster-name>with your Red Hat OpenShift Service on AWS cluster name. -
Replace with the IP addresses of your inbound resolver endpoints collected above, ensuring that following each IP address there is a
;.
-
Replace
- Create your cluster.
After 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 tableExample output
-------------------------------------------------- | ListHostedZonesByVPC | +------------------------------------------------+ | rosa.domain-prefix.lkmb.p3.openshiftapps.com. | | cluster-name.hypershift.local. | +------------------------------------------------+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 a
p3.openshiftapps.comdomain, wait a few minutes and run the command again.When you know the unique ID of the cluster domain, configure your DNS server to forward all DNS requests for
rosa.<domain-prefix>.<unique-ID>.p3.openshiftapps.comto your Amazon Route 53 Inbound Resolver endpoints. If you use a BIND DNS server, add a new zone to the/etc/named.conffile using the following example:zone "rosa.<domain-prefix>.<unique-ID>.p3.openshiftapps.com" { type forward; forward only; forwarders { 10.0.45.253; 10.0.23.131; 10.0.148.159; }; };-
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