// Module included in the following assemblies:
//
// * networking/networking_operators/aws-load-balancer-operator.adoc

:_mod-docs-content-type: PROCEDURE
[id="aws-load-balancer-operator-validate-install_{context}"]
= Validating Operator installation

[role="_abstract"]
To confirm that the AWS Load Balancer Operator and Controller have installed correctly, deploy a basic sample application. This validation process involves creating ingress and load balancing services to test the deployment.

.Procedure

. Create a new project:
+
[source,terminal]
----
$ oc new-project hello-world
----

. Create a new `hello-world` application based on the `hello-openshift` image:
+
[source,terminal]
----
$ oc new-app -n hello-world --image=docker.io/openshift/hello-openshift
----

. Configure a `NodePort` service for an AWS Application Load Balancer (ALB) to connect to:
+
[source,terminal]
----
$ cat << EOF | oc apply -f -
apiVersion: v1
kind: Service
metadata:
  name: hello-openshift-nodeport
  namespace: hello-world
spec:
  ports:
    - port: 80
      targetPort: 8080
      protocol: TCP
  type: NodePort
  selector:
    deployment: hello-openshift
EOF
----

. Deploy an AWS ALB for the application:
+
[source,terminal]
----
$ cat << EOF | oc apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: hello-openshift-alb
  namespace: hello-world
  annotations:
    alb.ingress.kubernetes.io/scheme: internet-facing
spec:
  ingressClassName: alb
  rules:
    - http:
        paths:
          - path: /
            pathType: Exact
            backend:
              service:
                name: hello-openshift-nodeport
                port:
                  number: 80
EOF
----

. Test access to the AWS ALB endpoint for the application:
+
[NOTE]
====
ALB provisioning takes a few minutes. If you receive an error that says `curl: (6) Could not resolve host`, wait and try again.
====
+
[source,terminal]
----
$ ALB_INGRESS=$(oc -n hello-world get ingress hello-openshift-alb \
    -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
----
+
[source,terminal]
----
$ curl "http://${ALB_INGRESS}"
----
+
.Example output
[source,text]
----
Hello OpenShift!
----

. Deploy an AWS Network Load Balancer (NLB) for the application:
+
[source,terminal]
----
$ cat << EOF | oc apply -f -
apiVersion: v1
kind: Service
metadata:
  name: hello-openshift-nlb
  namespace: hello-world
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: external
    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:
    deployment: hello-openshift
EOF
----
+
The `service.beta.kubernetes.io/aws-load-balancer-type` annotation is immutable for existing services. To change the load balancer type, you must recreate the service.

. Test access to the NLB endpoint for the application:
+
[NOTE]
====
NLB provisioning takes a few minutes. If you receive an error that says `curl: (6) Could not resolve host`, wait and try again.
====
+
[source,terminal]
----
$ NLB=$(oc -n hello-world get service hello-openshift-nlb \
  -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
----
+
[source,terminal]
----
$ curl "http://${NLB}"
----
+
Expected output shows `Hello OpenShift!`.

. You can now delete the sample application and all resources in the  `hello-world` namespace.
+
[source,terminal]
----
$ oc delete project hello-world
----
