Install ExternalDNS¶
Let's see how you can install ExternalDNS
in your EKS cluster.
Step 1: Get the Required IAM Policy¶
First, get the IAM Policy from official git repository. It should look something like this:
The above IAM policy allows ExternalDNS
to update Route 53 Resource Record Sets and Hosted Zones. If you prefer, you may fine-tune the policy to permit updates only to explicit Hosted Zone IDs.
Step 2: Create IAM Policy¶
We need to create a policy in IAM first. We will name the policy ExternalDNSIAMPolicy
. But you can name it anything that you prefer.
aws iam create-policy \
--policy-name ExternalDNSIAMPolicy \
--policy-document file://external-dns-iam-policy.json
Note down the ARN
of the policy. We'll need it in the next section.
Step 3: Create IAM Role and Service Account¶
We'll use IAM Roles for Service Accounts (IRSA) to grant ExternalDNS
permission to AWS resources. So, let's create IRSA as follows:
eksctl create iamserviceaccount \
--cluster my-cluster \
--name external-dns \
--namespace external-dns \
--attach-policy-arn <policy-arn> \
--approve
Please note that we have specified the namespace as external-dns
, and as a result, the service account will be created within this namespace.
Verify the service account:
# List service accounts
kubectl get sa -n external-dns
# View the service account definition in yaml format
kubectl get sa external-dns -n external-dns -o yaml
# Describe the service account
kubectl describe sa external-dns -n external-dns
Also, go to AWS console and verify the IAM role that was created. You can get the role name from the annotation in the service account that was created.
Step 4: Install ExternalDNS¶
With the service account ready, we can now move forward with the installation of ExternalDNS
.
-
Download the YAML manifest for ExternalDNS:
-
Update the YAML manifest:
Now, before we proceed with the installation of this manifest, we need to make some modifications to it.
We'll deploy all the resources in
external-dns
namespace. So, we need to make the following modifications to ensure that resources are created in theexternal-dns
namespace:- In
ClusterRoleBinding
object replacenamespace: default
withnamespace: external-dns
since we have created the service account inexternal-dns
namespace. - In
Deployment
object addnamespace: external-dns
so that the resources are deployed inexternal-dns
namespace ClusterRole
andClusterRoleBinding
are not namespaced objects so we don't have to specify the namespace
We'll also omit the
--domain-filter
,--policy
, and--aws-zone-type
because we want ExternalDNS to manage all the public and private hosted zones and enable full synchronization.The modified manifest should look something like this:
- In
-
Apply the manifest to install ExternalDNS:
-
Verify ExternalDNS pods and view logs: