Lab Steps

lock
Logging in to the Amazon Web Services Console
lock
Understanding the DC/OS Cluster Architecture
lock
Connecting to the DC/OS Cluster NAT Instance using SSH with Agent Forwarding
lock
Adding Agent Attributes to DC/OS Nodes
lock
Using Attributes to Constrain Marathon Applications
lock
Validate AWS Lab
Need help? Contact our support team

Here you can find the instructions for this specific Lab Step.

If you are ready for a real environment experience please start the Lab. Keep in mind that you'll need to start from the first step.

Introduction

Agent nodes in DC/OS can be assigned attributes, which are key-value pairs. The values are optional. When included, values can be of the following types with two examples of each type:

  • scalar: 1, 20.34
  • ranges: [50-99.99], [1-5, 11-15, 21-25]
  • text: hello, CA-Labs_DC/OS.4

When a node tells Marathon of its available resources, called a resource offer, the node's attributes are included. Marathon can then use the attributes to make scheduling decisions.

In this Lab Step, you will first install the DC/OS CLI by using commands found in the GUI. Second, you will use the DC/OS CLI to connect to private agent nodes in the cluster and configure their attributes.

 

Instructions

1. In the AWS Management Console, navigate to Services > Compute > EC2 > INSTANCES > Instances:

alt

 

2. Select the instance named Master, and copy its Public DNS:

alt

 

3. Open a new browser tab and navigate to the Master's Public DNS:

alt

Reminder: It can take several minutes for the DC/OS website to become available. Once it loads, you should wait until the dashboard shows 3 Connected Nodes and all Component Health rows are Healthy. This usually completes within 10 minutes from the time you start the Lab.

 

4. In the DC/OS GUI, click on the cloudacademylab cluster name in the upper-left corner to reveal a drop-down menu:

alt 

 

5. Click Install CLI.

 

6. Click on the LINUX button to show the instructions for installing the DC/OS CLI on Linux:

alt

One of the commands sets up the CLI to talk specifically with your cluster. You can leave the GUI browser tab open. You can observe the effect of CLI commands and monitor the cluster using the GUI.

 

7. Copy the code snippet and paste it into your SSH shell.

It only takes a few moments to complete the installation. A list of available commands is output when the installation completes.

 

8. Use the AWS CLI to get the private IP addresses of the two private agent nodes found in the DC/OS cluster:

Copy code
aws ec2 describe-instances --region us-west-2 --output text \
--query 'Reservations[0].Instances[*].PrivateIpAddress' \
--filter "Name=tag:Name,Values=Private Agent"

Record the IP addresses. You will be using the private IP addresses to connect to each private agent node.

 

9. Using the first private IP address in place of AGENT_PRIVATE_IP_1, connect to the first private agent using the master node as a proxy:

Copy code
dcos node ssh --master-proxy --private-ip=AGENT_PRIVATE_IP_1

Enter yes to continue each time you are prompted about the uncertain authenticity of the hosts. You will be prompted once for the master, and again for the agent:

alt

The agents are running CoreOS and may report a Failed Unit. You can safely continue with the failed unit being reported because the update engine isn't required for this Lab.

 

10. Change into the /var/lib/dcos directory:

Copy code
cd /var/lib/dcos

The file containing the node attributes is read from this directory, if it exists.

 

11. Create the mesos-slave-common file and define two attributes separated by a semi-colon called rack-id and capabilities:

Copy code
echo "MESOS_ATTRIBUTES=rack-id:rack-1;capabilities:[4-5]" > mesos-slave-common

The rack-id attribute has a text value of rack-1, and the capabilities attribute has a range value of 4-5. The capabilities could represent special hardware or software capabilities of a node. The file must be named mesos-slave-common.

 

12. Remove the current attribute directory:

Copy code
sudo rm -rf /var/lib/mesos/slave/meta/slaves/latest

This will prompt the latest attribute directory to be regenerated the next time the DC/OS agent (sometimes referred to as slave) service is started.

 

13. Restart the DC/OS agent/slave service to generate a new attribute directory:

Copy code
sudo systemctl restart dcos-mesos-slave.service

 

14. Return to the DC/OS GUI, and click on Nodes in the sidebar menu:

alt

 

15. Click on the agent that you connected to in the HOSTNAME column and open the Details tab:

alt

The Attributes for the node are listed here.

 

16. Return to the SSH shell and disconnect from the first private agent node:

Copy code
exit

 

17. Connect to the second private agent node: 

Copy code
dcos node ssh --master-proxy --private-ip=AGENT_PRIVATE_IP_2

where you replace AGENT_PRIVATE_IP_2 with the private IP of the second private agent node. Enter yes when prompted about the authenticity of the second private agent node.

 

18. Enter the following commands to add the same two attributes to the second private agent node, but with different values:

Copy code
cd /var/lib/dcos
echo "MESOS_ATTRIBUTES=rack-id:rack-2;capabilities:[1-3,6-7]" > mesos-slave-common
sudo rm -rf /var/lib/mesos/slave/meta/slaves/latest
sudo systemctl restart dcos-mesos-slave.service

The second private agent node is located in rack-2 and has capabilities 1-3 and 6-7, which don't overlap with the capabilities of the first private agent.

 

19. Disconnect from the second private agent node:

Copy code
exit

 

Summary

In this Lab Step, you learned how to assign attributes to DC/OS nodes. You also used SSH agent forwarding to easily connect to private agent nodes using the publicly available master node as a proxy.