DC/OS™ agent nodes can be designated as public or private during installation. Public agent nodes provide access from outside of the cluster through infrastructure networking to your DC/OS services. By default, services are launched on private agent nodes and are not accessible from outside the cluster.
To launch a service on a public node, you must:
- Create a Marathon app definition with the
"acceptedResourceRoles":["slave_public"]
parameter specified - Configure an edge load balancer and a service discovery mechanism
Prerequisites:
Create a Marathon app definition
-
Create a Marathon app definition with the required
"acceptedResourceRoles":["slave_public"]
parameter specified. For example:{ "id":"/product/service/myApp", "acceptedResourceRoles":[ "slave_public" ], "instances":1, "cpus":0.1, "mem":64, "networks":[ { "mode":"container/bridge" } ], "container":{ "type":"DOCKER", "docker":{ "image":"group/image" }, "portMappings":[ { "containerPort":8080, "hostPort":0 } ] } }
For more information about the
acceptedResourceRoles
parameter, see the Marathon API documentation. -
Add your app to Marathon by using this command, where
myApp.json
is the file containing your Marathon app definition.dcos marathon app add myApp.json
If this is added successfully, there is no output. You can also add your app by using the Services tab of the DC/OS UI.
-
Verify that the app is added with this command:
dcos marathon app list
The output should look like this:
ID MEM CPUS TASKS HEALTH DEPLOYMENT CONTAINER CMD /myApp 64 0.1 0/1 --- scale DOCKER None
You can also view deployed apps by using the Services tab of the DC/OS UI.
Configure edge load balancer
-
Configure an edge load balancer and service discovery mechanism.
- AWS® users: If you installed DC/OS by using the AWS CloudFormation templates, an ELB is included. However, you must reconfigure the health check on the public ELB to expose the app to the port specified in your app definition (e.g. port 80).
- All other users: You can use Marathon-LB, a rapid proxy and load balancer that is based on HAProxy®.
-
Go to your public agent to see the site running. For information about how to find your public agent IP, see the documentation.
You should see the following message in your browser:
Figure 1. Confirmation page
Learn more
Learn how to load balance your app on a public node using Marathon-LB.