{"_id":"5500a5712e8c48170076d163","category":{"_id":"54fa42b3961fea210092068e","pages":["54fada9b5c41173700ecf29e","54fadb625c41173700ecf2a0","54fae365019b2537006d00bc","5500a5712e8c48170076d163","551a876868da7f0d00f58cbc","5521351e29a3dc0d00fae453","5522b5af85fa041700623976","556d98e442dd610d00a3cfde"],"version":"54fa0050f63cf9210041c3c1","__v":8,"project":"54fa004ff63cf9210041c3be","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-03-07T00:13:39.405Z","from_sync":false,"order":0,"slug":"getting-started","title":"Getting Started"},"project":"54fa004ff63cf9210041c3be","version":{"_id":"54fa0050f63cf9210041c3c1","__v":5,"project":"54fa004ff63cf9210041c3be","createdAt":"2015-03-06T19:30:24.258Z","releaseDate":"2015-03-06T19:30:24.258Z","categories":["54fa0050f63cf9210041c3c2","54fa42b3961fea210092068e","54facefd5c41173700ecf296","54fad9d5f63cf9210041c669","54fae9ed5c41173700ecf2ad"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":8,"githubsync":"","user":"54fa0018e7a0ba2f00306211","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-03-11T20:28:33.916Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"Paz can only run services that have been defined in the Service Directory; so the first step to deploying your new service is to do just that. Once a service is declared, it can be deployed by the scheduler, usually via your CI system and the Docker Hub.\n\n\nWe're going to add a contrived service called \"demo-api\", which is a simple \"Hello World!\" website.\n\nThis assumes that you've set up a CoreOS Paz Vagrant/VirtualBox cluster.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Adding a Service to the Service Directory\"\n}\n[/block]\nAdding new services is described [here](doc:deploying-your-first-application-using-paz).\n\nCreate a service named \"demo-api\", give it any description, Docker repository `lukebond/demo-api`, number of units `3`. Don't specify any ports or environment variables.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Deploying your New Service from the Paz UI\"\n}\n[/block]\nIn the Services tab there is a button to deploy your new service. Click that button and it should appear in the dashboard.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Manually Deploying Your New Service\"\n}\n[/block]\nServices can also be deployed via an HTTP post, and the Scheduler has two endpoints for ths, one expects Docker Hub webhooks and the other is for manual deployment. You may prefer to use the latter for manual deployments with something like cURL.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Important\",\n  \"body\": \"Have you set up your `/etc/hosts` for Paz? See the note towards the end of [this documentation](doc:installing-paz-using-vagrant) for information on how to do this.\"\n}\n[/block]\nManually trigger the deployment using `curl`:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ curl -i -d '{\\\"serviceName\\\": \\\"demo-api\\\", \\\"dockerRepository\\\": \\\"lukebond/demo-api\\\", \\\"pushedAt\\\": 0}' -H 'Content-Type: application/json' paz-scheduler/hooks/deploy\\nHTTP/1.1 200 OK\\n...\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nYou can now go to the Paz dashboard and the service should soon appear (it may take a moment to pull the image down from the Docker Hub).\n\nYou should see three green `demo-api` units running in the Paz web UI dashboard.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Accessing Your New Service\"\n}\n[/block]\nIn order to access your new service from outside the cluster we need to modify our /etc/hosts file. This is because all incoming requests to the cluster go through HAProxy and HAProxy will route requests by HTTP host header. Therefore incoming requests need to include the service name.\n\nAdd the following line to your /etc/hosts file:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"172.17.9.101 demo-api.paz\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]","excerpt":"Running your services on a newly-installed Paz cluster","slug":"deploying-your-first-application","type":"basic","title":"Deploying your First Application"}

Deploying your First Application

Running your services on a newly-installed Paz cluster

Paz can only run services that have been defined in the Service Directory; so the first step to deploying your new service is to do just that. Once a service is declared, it can be deployed by the scheduler, usually via your CI system and the Docker Hub. We're going to add a contrived service called "demo-api", which is a simple "Hello World!" website. This assumes that you've set up a CoreOS Paz Vagrant/VirtualBox cluster. [block:api-header] { "type": "basic", "title": "Adding a Service to the Service Directory" } [/block] Adding new services is described [here](doc:deploying-your-first-application-using-paz). Create a service named "demo-api", give it any description, Docker repository `lukebond/demo-api`, number of units `3`. Don't specify any ports or environment variables. [block:api-header] { "type": "basic", "title": "Deploying your New Service from the Paz UI" } [/block] In the Services tab there is a button to deploy your new service. Click that button and it should appear in the dashboard. [block:api-header] { "type": "basic", "title": "Manually Deploying Your New Service" } [/block] Services can also be deployed via an HTTP post, and the Scheduler has two endpoints for ths, one expects Docker Hub webhooks and the other is for manual deployment. You may prefer to use the latter for manual deployments with something like cURL. [block:callout] { "type": "warning", "title": "Important", "body": "Have you set up your `/etc/hosts` for Paz? See the note towards the end of [this documentation](doc:installing-paz-using-vagrant) for information on how to do this." } [/block] Manually trigger the deployment using `curl`: [block:code] { "codes": [ { "code": "$ curl -i -d '{\"serviceName\": \"demo-api\", \"dockerRepository\": \"lukebond/demo-api\", \"pushedAt\": 0}' -H 'Content-Type: application/json' paz-scheduler/hooks/deploy\nHTTP/1.1 200 OK\n...", "language": "text" } ] } [/block] You can now go to the Paz dashboard and the service should soon appear (it may take a moment to pull the image down from the Docker Hub). You should see three green `demo-api` units running in the Paz web UI dashboard. [block:api-header] { "type": "basic", "title": "Accessing Your New Service" } [/block] In order to access your new service from outside the cluster we need to modify our /etc/hosts file. This is because all incoming requests to the cluster go through HAProxy and HAProxy will route requests by HTTP host header. Therefore incoming requests need to include the service name. Add the following line to your /etc/hosts file: [block:code] { "codes": [ { "code": "172.17.9.101 demo-api.paz", "language": "text" } ] } [/block]