I have an EKS cluster.
I created my service and exposed it using ingress-nginx.
ingress-nginx external IP appears as a DNS name and not as IP.
How can I connect my private domain to point to my EKS service?
I know that there is an annotation for using AWS Elastic IP with Kubernetes,
but it's only available starting from Kubernetes 1.16 and EKS supports only up to 1.14.
So what are my options to assign some static IP to my service and configure my DNS to point this IP?
Answers
To connect your private domain to your EKS service and point it to the EKS ingress controller's external DNS name, you can follow these steps:
1. Get the External DNS Name
Ensure you have the external DNS name of your ingress-nginx. You can retrieve it by describing the service:
kubectl get svc -n ingress-nginx
Look for the EXTERNAL-IP
or Hostname
field.
2. Configure Your DNS
You need to create a DNS record that points your domain to the external DNS name provided by your ingress-nginx service.
Using Route 53
If you are using AWS Route 53 for your DNS, you can create an A
record with an alias to the external DNS name of your ingress-nginx service.
- Log in to the AWS Management Console and open the Route 53 console.
- Navigate to your hosted zone where your domain is managed.
- Create a new record:
- Record name: The subdomain you want to point (e.g.,
api.yourdomain.com
). - Record type:
A - IPv4 address
. - Alias: Yes.
- Alias target: Choose the load balancer from the dropdown that corresponds to your ingress-nginx service's external DNS name.
- Record name: The subdomain you want to point (e.g.,
3. Using Elastic IP with Ingress-nginx
If you prefer to use a static IP and attach it to your DNS, you can manually allocate an Elastic IP and associate it with your ingress-nginx service.
Allocate an Elastic IP
-
Allocate an Elastic IP:
- Open the EC2 console.
- In the left navigation pane, choose Elastic IPs.
- Choose Allocate Elastic IP address.
- Choose Allocate.
-
Associate the Elastic IP with the Load Balancer:
- Find the Network Load Balancer (NLB) created by your ingress-nginx.
- Associate the allocated Elastic IP with one or more of the NLB's subnets. This step usually involves editing the NLB listeners or directly associating the IP with the NLB.
Update the Ingress-nginx Configuration
Ensure that your ingress-nginx service is configured to use the NLB. If it’s not, you may need to update the service type and annotations to ensure it uses the NLB.
Here is an example of how you might configure an ingress-nginx service to use an NLB:
apiVersion: v1
kind: Service
metadata:
name: ingress-nginx
namespace: ingress-nginx
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
service.beta.kubernetes.io/aws-load-balancer-eip-allocations: "<your-elastic-ip-allocation-id>"
spec:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: 80
- name: https
port: 443
targetPort: 443
selector:
app: ingress-nginx
4. Update Your DNS to Point to the Elastic IP
If you allocated and associated an Elastic IP, you would update your DNS record to point to this Elastic IP instead of the DNS name. This is done similarly as described above but pointing to the Elastic IP instead of the DNS name.
Summary
- Get the external DNS name of your ingress-nginx service.
- Create a DNS record in Route 53 (or your DNS provider) that points to this DNS name.
- Optionally, allocate an Elastic IP and associate it with your NLB if you need a static IP.
- Update your ingress-nginx configuration to use the NLB and potentially the Elastic IP.
By following these steps, you can successfully point your private domain to your EKS service.