# AWS Load Balancer Operator On ROSA with persistent IP
1. Follow the steps [here](https://github.com/tosin2013/sno-quickstarts/tree/main/gitops/cluster-config/aws-load-balancer-operator-on-rosa) to configure OpenShift Enviornment.
1. Deploy Sample [application](https://github.com/tosin2013/sno-quickstarts/tree/main/gitops/cluster-config/aws-load-balancer-operator-on-rosa/app-instance) to test
## Configure Elastic IP in AWS
* Log into the AWS console and navigate to EC2 > Elastic IPs.
* Allocate a new Elastic IP.
* Take note of the Allocation ID (e.g. eipalloc-023fxxxxx).

## Echo Server example
**replace the `Allocation ID` with eipalloc-CHANGEME example eipalloc-023fxxxxxxx**
```
apiVersion: v1
kind: Service
metadata:
name: echoserver-nlb
namespace: echoserver
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: nlb
service.beta.kubernetes.io/aws-load-balancer-eip-allocations: eipalloc-CHANGEME
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: instance
service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
type: LoadBalancer
selector:
app: echoserver
```
**The key things to note:**
* Set aws-load-balancer-eip-allocations to the EIP Allocation ID
* Set aws-load-balancer-type to nlb
* Set aws-load-balancer-nlb-target-type to instance
* Set scheme to internet-facing
This will configure an NLB with the specified Elastic IP. Even if the service is later recreated, it will continue using that IP address.
**Inital service instance**
```
dig a329a45a1e83d4a10befa41d4913cee4-0ad7caaefca5df44.elb.us-east-2.amazonaws.com
; <<>> DiG 9.16.23-RH <<>> a329a45a1e83d4a10befa41d4913cee4-0ad7caaefca5df44.elb.us-east-2.amazonaws.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42629
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;a329a45a1e83d4a10befa41d4913cee4-0ad7caaefca5df44.elb.us-east-2.amazonaws.com. IN A
;; ANSWER SECTION:
a329a45a1e83d4a10befa41d4913cee4-0ad7caaefca5df44.elb.us-east-2.amazonaws.com. 60 IN A 3.138.71.119
;; Query time: 9 msec
;; SERVER: 10.0.0.2#53(10.0.0.2)
;; WHEN: Wed Dec 20 15:46:02 UTC 2023
;; MSG SIZE rcvd: 122
```
**After delete and recreation of service**
```
dig a62bdf887aad2450eac19a9f09923a7d-d41d01f195abb3a3.elb.us-east-2.amazonaws.com
; <<>> DiG 9.16.23-RH <<>> a62bdf887aad2450eac19a9f09923a7d-d41d01f195abb3a3.elb.us-east-2.amazonaws.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20085
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;a62bdf887aad2450eac19a9f09923a7d-d41d01f195abb3a3.elb.us-east-2.amazonaws.com. IN A
;; ANSWER SECTION:
a62bdf887aad2450eac19a9f09923a7d-d41d01f195abb3a3.elb.us-east-2.amazonaws.com. 60 IN A 3.138.71.119
;; Query time: 0 msec
;; SERVER: 10.0.0.2#53(10.0.0.2)
;; WHEN: Wed Dec 20 15:52:01 UTC 2023
;; MSG SIZE rcvd: 122
```