Skip to content

Installation on CoreOS Fleet

Omnipresent edited this page Oct 13, 2015 · 1 revision

Kick off a cluster on AWS

NOTE: this is hardcoded to use the us-east-1 region, so if you need a different region, you should edit the URL accordingly

Parameters:

  • 3 nodes (default)
  • Discovery URL - as it says, you need to grab a new token from https://discovery.etcd.io/new and paste it in the box.
  • KeyPair: use whatever you normally use to start EC2 instances. For this discussion, let's assumed you used aws, which corresponds to a file you have on your laptop called aws.cer

SSH into any of the CoreOS machines

  • Go to EC2 console and pick any of the 3 ec2 instances you just started, get the public IP
  • ssh in using this command $ ssh -i aws.cer -A core@<instance ip>

Start units (docker containers)

The following will kickoff all the docker containers required to run OpenOCR. You should end up with three docker containers, one running on each CoreOS machine.

$ wget https://raw.githubusercontent.com/tleyden/open-ocr/master/docs/coreos-fleet/start-fleet.sh
$ chmod +x start-fleet.sh
$ ./start-fleet.sh

Wait for units to start

fleetctl list-units should show all units as active / running:

$ fleetctl list-units
httpd.service                   7a3deefa.../10.13.190.245	active	running
rabbitmq.service                87ce46ea.../10.169.56.130	active	running
rabbitmq_announce.service       87ce46ea.../10.169.56.130	active	running
worker.service                  d2a28265.../10.63.23.86		active	running

Verify

Get the IP address of the httpd.service, in this case 10.13.190.245, and then try to call the OpenOCR REST API to decode an image.

$ curl -X POST -H "Content-Type: application/json" -d '{"img_url":"http://bit.ly/ocrimage","engine":"tesseract"}' http://10.13.190.245:8080/ocr

You should see "You can create local variables .. " which is the decoded OCR output.

In order to verify the Stroke Width Transform the following is needed:

$ export AMQP_URI=amqp://admin:${RABBIT_PASS}@${RABBIT_HOST}/
$ docker run -d tleyden5iwx/open-ocr-preprocessor open-ocr-preprocessor -amqp_uri "${AMQP_URI}" -preprocessor "stroke-width-transform"
$ curl -X POST -H "Content-Type: application/json" -d '{"img_url":"http://bit.ly/ocrimage-swt","engine":"tesseract", "preprocessors":["stroke-width-transform"]}' http://${HTTPD_SERVICE}:8080/ocr
YH XMCDMTDC

Using OpenOCR via public ip

The security group configuration already allows connections to port 8080 from the outside world, but to connect from outside you need to find the public ip of the CoreOS machine running the httpd service.

Find the public ip address of the httpd unit

  • Go to your EC2 console
  • Ssh into each of your 3 core instances via public ip
  • Run sudo docker ps
  • If it says "httpd", then the public ip you just ssh'd into is the one running httpd. Eg, ec2-174-129-90-33.compute-1.amazonaws.com

Run curl

Repeat the above curl command in the Verify section above, but this time use the public ip you found in the previous step.

$ curl -X POST -H "Content-Type: application/json" -d '{"img_url":"http://bit.ly/ocrimage","engine":"tesseract"}' http://ec2-174-129-90-33.compute-1.amazonaws.com:8080/ocr

Debugging

If things aren't working, you'll first need to make a change to the SSH setup before you can debug it.

Enable SSH between CoreOS nodes

In order to enable a coreOS node to communicate with another node over ssh (required for certain fleetctl commands like status), you will need to do a few steps to enable that.

Add key to agent

From the machine you are ssh'ing into the CoreOS cluster with (eg, your laptop), you need to add the injected AWS key to your ssh-agent.

$ ssh-add aws.cer
Identity added: aws.cer (aws.cer)

Viewing logs

If the httpd.service unit did not start, you can view the logs by running:

$ fleetctl journal httpd.service

SSH in

To ssh into the httpd.service unit, run

$ fleetctl ssh httpd.service