Creating new service
Now it may be a good time to roll your own service on Armada. The easiest way to create a new service is to base it on a template. As an example we will use Armada's template for Python:$ armada create uppercase-service -b python
Service uppercase-service has been created in /home/vagrant/uppercase-service from python template.
$ cd uppercase-service ; find
.
./README.md
./Dockerfile
./Vagrantfile
./supervisor
./supervisor/uppercase-service.conf
./src
./src/uppercase-service.py
~/uppercase-service$ vim ./src/uppercase-service.py
import web
class Index(object):
def GET(self):
return 'Service works!'
class Shout(object):
def GET(self, txt):
return txt.upper() + "\n"
def main():
urls = (
'/', Index.__name__,
'/shout/(.*)', Shout.__name__,
)
app = web.application(urls, globals())
app.run()
if __name__ == '__main__':
main()
~/uppercase-service$ armada build upcase-service
Pulling repository dockyard.armada.sh/microservice_python
cae965566422: Pulling dependent layers
511136ea3c5a: Download complete
...(skipped)...
356e562e6310: Download complete
Uploading context 9.728 kB
Uploading context
Step 0 : FROM dockyard.armada.sh/microservice_python
---> cae965566422
...(skipped)...
Removing intermediate container dbdff2a06a09
Successfully built c0b134888b7a
~/uppercase-service$ armada push upcase-service
Pushing microservice upcase-service to dockyard: 192.168.3.141:10000...
The push refers to a repository [192.168.3.141:10000/upcase-service] (len: 1)
Sending image list
Pushing repository 192.168.3.141:10000/upcase-service (1 tags)
Image 511136ea3c5a already pushed, skipping
...(skipped)...
f87353915cb3: Image successfully pushed
Pushing tag for rev [f87353915cb3] on {http://192.168.3.141:10000/v1/repositories/upcase-service/tags/latest}
~/uppercase-service$ armada run upcase-service
Running microservice upcase-service from dockyard: 192.168.3.141:10000 (alias: myrepo) locally...
Service is running in container 9707b42a4c77 available at addresses:
192.168.3.141:49168 (80/tcp)
~/uppercase-service$ curl http://192.168.3.141:49168/shout/Armada-is-cool!
ARMADA-IS-COOL!