
# Openshift

1. download tarfile
1. untar file

1. In a terminal (T1)
1. cd into lb-service directory and run the following to build and deploy the client/server apps.

   ~~~
   oc new-project lb-service
   ~~~

   ncat server
   ~~~
   oc new-build  -D "-" < \
      containers/server-ncat/Containerfile \
      --to server-ncat:latest \
   && oc wait --for=condition=complete \
      build/server-ncat-1 --timeout 5m \
   && oc new-app server-ncat:latest
   ~~~

   socat server
   ~~~
   oc new-build  -D "-" < \
      containers/server-socat/Containerfile \
      --to server-socat:latest \
   && oc wait --for=condition=complete \
      build/server-socat-1 --timeout 5m \
   && oc new-app server-socat:latest
   ~~~

   client
   ~~~
   oc new-build  -D "-" < \
      containers/client/Containerfile \
      --to client:latest \
   && oc wait --for=condition=complete \
      build/client-1 --timeout 5m \
   && oc new-app client:latest
   ~~~



1. View the messages being sent to the socat server
   ~~~
   source bin/clusterResources
   ~~~
   ~~~
   oc logs $POD_SERVER_SOCAT -f
   ~~~

1. Send a messages to the socat server app using the cluster IP.  Since the cluster IP is only available from inside the cluster we need to rsh into the client pod
   ~~~
   source bin/clusterResources \
   && sed \
      -e "s/{SERVICEIP}/$SVC_SOCAT_IP/" \
      -e "s/{sleep}//"  \
      bin/snd-msg  | oc rsh $POD_CLIENT
   ~~~

1. Create the external Load Balancer Service
   ~~~
   oc create -f configs/svc-socat-lb.yml
   ~~~

1. Confirm that Azure has provided an exteranl IP.  If the EXTERNAL-IP is \<pending> wait for Azure to populate the cluster with the external IP
   ~~~
   oc get svc
   NAME              TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
   ...
   server-socat-lb   LoadBalancer   172.30.62.0      <pending>     4224:31841/TCP   9s
   ~~~
1. Send a messages to the socat server app using the external IP.  Since this IP is external it can be done from any location that has access to to the external IP.

   From the client pod
   ~~~
   source bin/clusterResources \
   && sed \
      -e "s/{SERVICEIP}/$SVC_LB_SOCAT_IP_EXT/" \
      -e "s/{sleep}//"  \
      bin/snd-msg  | oc rsh $POD_CLIENT
   ~~~
   From a local machine
   ~~~
   let i=1
   while [[ $i -le 50 ]]
   do
      echo "########## msg $i" | /usr/bin/nc -w 1 20.241.220.82 4224 &

      let i=$i+1
   done
   ~~~

This procedure will show that non https protocols will work with ARO.  If the procedure does not work then it highlights that changes have been made to the ARO/Azure networking which will need to be resolved.


# Clean up
~~~
oc delete deployment,build,svc,buildconfig,imagestream --all

oc delete project lb-service
~~~
