Manually adding a node to the Skydive topology via the Skydive client

Skydive is a real-time open-source network topology and protocol analyzer. It aims to provide a comprehensive way to understand what is happening in the network infrastructure.

To pique your interest, here are a couple of screenshots about Skydive. Further down, there will be a post introducing Skydive.

Manually adding a node to the Skydive topology via the Skydive client

Manually adding a node to the Skydive topology via the Skydive client

Post "Introduction to skydive.network" on Habr.

Skydive displays the network topology by receiving network events from Skydive agents. Have you ever wondered how to add or display network components that are outside of the Skydive agent network or non-network objects such as TOR, data storage, etc.? Worry no more, thanks to the Node rule API.

Starting from version 0.20, Skydive provides a Node rule API that can be used to create new nodes and edges and to update the metadata of existing nodes. The Node rule API is split into two APIs: the Node rule API and the Edge rule API. The Node rule API is used to create a new node and update the metadata of an existing node. The Edge rule API is used to create a boundary between two nodes, i.e., it connects two nodes.

In this blog, we will explore two use cases, one of which is a network component that is not part of the Skydive network. The second case is a non-network component. Before that, we will review some basic ways to use the topology rule API.

Creating a Skydive Node

To create a node, you need to specify a unique node name and a valid node type. You can also provide some additional parameters.

skydive client node-rule create --action="create" --node-name="node1" --node-type="fabric" --name="node rule1"
{
  "UUID": "ea21c30f-cfaa-4f2d-693d-95159acb71ed",
  "Name": "node rule1",
  "Description": "",
  "Metadata": {
    "Name": "node1",
    "Type": "fabric"
  },
  "Action": "create",
  "Query": ""
}

Updating Skydive Node Metadata

To update the metadata of an existing node, you need to provide a Gremlin query to select the nodes for which you want to update the metadata. Based on your query, you can update the metadata of one or more nodes using a single node rule.

skydive client node-rule create --action="update" --name="update rule" --query="G.V().Has('Name', 'node1')" --metadata="key1=val1, key2=val2"
{
  "UUID": "3e6c0e15-a863-4583-6345-715053ac47ce",
  "Name": "update rule",
  "Description": "",
  "Metadata": {
    "key1": "val1",
    "key2": "val2"
  },
  "Action": "update",
  "Query": "G.V().Has('Name', 'node1')"
}

Creating an edge in Skydive

To create an edge, you must specify the source and destination nodes and the type of relation. For creating a child node, the relation type should be ownership, and similarly, for creating a layer2 relation, the relation type should be layer2. You can create more than one relation between two nodes, but the type of relation must be different.

skydive client edge-rule create --name="edge" --src="G.v().has('TID', '2f6f9b99-82ef-5507-76b6-cbab28bda9cb')" --dst="G.V().Has('TID', 'd6ec6e2f-362e-51e5-4bb5-6ade37c2ca5c')" --relationtype="both"
{
  "UUID": "50fec124-c6d0-40c7-42a3-2ed8d5fbd410",
  "Name": "edge",
  "Description": "",
  "Src": "G.v().has('TID', '2f6f9b99-82ef-5507-76b6-cbab28bda9cb')",
  "Dst": "G.V().Has('TID', 'd6ec6e2f-362e-51e5-4bb5-6ade37c2ca5c')",
  "Metadata": {
    "RelationType": "both"
  }
}

First Use Case

In this case, we will look at how to display a non-network device in the skydive topology. Let’s consider that we have a data storage device that needs to be represented in the skydive topology diagram with some useful metadata.

We just need to create a node rule to add the device to the topology. We can include the device metadata as part of the create command or subsequently create one or more update node rule commands.

Run the node rule command below to add the storage device to the topology schema.

skydive client node-rule create --action="create" --node-name="sda" --node-type="persistentvolume" --metadata="DEVNAME=\/dev\/sda,DEVTYPE=disk,ID.MODEL=SD_MMC, ID.MODEL ID=0316, ID.PATH TAG=pci-0000_00_14_0-usb-0_3_1_0-scsi-0_0_0_0, ID.SERIAL SHORT=20120501030900000, ID.VENDOR=Generic-, ID.VENDOR ID=0bda, MAJOR=8, MINOR=0, SUBSYSTEM=block, USEC_INITIALIZED=104393719727"

Run the edge rule command below to link the created node with the host node.

skydive client edge-rule create --src="G.V().Has('Name', 'node1')" --dst="G.V().Has('Name', 'sda')" --relationtype="ownership"

After the above commands, you can now see the device visible on the skydive topology diagram with the specified metadata, as shown in the figure below.

Manually adding a node to the Skydive topology via the Skydive client

Second Use Case

In this case, we will see how to add a network device that is not part of the skydive network. Let's consider this example. We have two skydive agents running on two different hosts, and to connect these two hosts, we need a TOR switch. Even if we can achieve this by defining the structure and link nodes in the configuration file, let's see how we can do the same using topology API rules.

Without a TOR switch, the two agents will appear as two separate nodes with no links, as shown in the figure below.

Manually adding a node to the Skydive topology via the Skydive client

Now, run the following Node Rule commands to create the TOR switch and the ports.

skydive client node-rule create --node-name="TOR" --node-type="fabric" --action="create"
skydive client node-rule create --node-name="port1" --node-type="port" --action="create"
skydive client node-rule create --node-name="port2" --node-type="port" --action="create"

As you can see, the TOR switch and ports have been created and added to the skydive topology, and now the topology will look as shown in the figure below.

Manually adding a node to the Skydive topology via the Skydive client

Now, run the following Edge Rule commands to create a link between the TOR switch, port 1, and the public interface of host 1.

skydive client edge-rule create --src="G.V().Has('Name', 'TOR')" --dst="G.V().Has('Name', 'port1')" --relationtype="ownership"
skydive client edge-rule create --src="G.V().Has('Name', 'TOR')" --dst="G.V().Has('Name', 'port1')" --relationtype="layer2"
skydive client edge-rule create --src="G.V().Has('TID', '372c254d-bac9-50c2-4ca9-86dcc6ce8a57')" --dst="G.V().Has('Name', 'port1')" --relationtype="layer2"

Run the following commands to create a link between the TOR switch, port 2, and the public interface of host 2.

skydive client edge-rule create --src="G.V().Has('Name', 'TOR')" --dst="G.V().Has('Name', 'port2')" --relationtype="layer2"
skydive client edge-rule create --src="G.V().Has('Name', 'TOR')" --dst="G.V().Has('Name', 'port2')" --relationtype="ownership"
skydive client edge-rule create --src="G.V().Has('TID', '50037073-7862-5234-4996-e58cc067c69c')" --dst="G.V().Has('Name', 'port2')" --relationtype="layer2"

Now, ownership and layer2 links are being created between the TOR switch and the port, as well as layer2 links between the agents and the ports. Now the final topology will look as shown in the figure below.

Manually adding a node to the Skydive topology via the Skydive client

Now, the two hosts/agents are correctly connected, and you can check the connection or create a shortest path capture between the two hosts.

P.S. Link to the original post

Looking for people who could write posts about other Skydive features.
Telegram chat on skydive.network.

Source: habr.com

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster