Resources: Discovering the Environment

Updated 4 months ago by Shoreline

Discovering Resources

One of the foundational things we need to understand as operators is how a workload is mapped to underlying infrastructure.  Getting that information is easy with one of the most simple and useful commands in Op:  Resource.  Resource allows us to query our environment to understand which hosts, pods, containers, and other resources are present.  For example, to get all of the hosts in our environment:

op> resource(type="HOST")

Op is all about not repeating ourselves.  “Fat fingering” incorrect commands is widely known to be the cause of some of the most disruptive outages.  Operators also don't have time in the heat of a Sev 1 incident to remember long and complex commands.  When we have a useful command like the above in Op, we can easily create a shorthand for it by creating a named resource query.  In this example, we create a named query called “host.”

op> resource host = resource(type="HOST")

Now we can run host simply as:

op> host

This shows the real power of Op.  The operator is able to build up, layer by layer, more and more powerful commands.

Filtering and Drilling Down on Resources

Let's build on the host query. We can filter the returned resources in Op not only by type, but also by tag.  For example, to get all of our hosts in AZ us-west-2a we would add (pipe):

op> host | az="us-west-2a"

Op resources are also aware of their relationships to other resources.  Often this is one of the most crucial aspects of debugging.  For example, let's grab all of the containers in all of the pods on our hosts in us-west-2a and filter them to our Envoy sidecars:

op> host | az=”us-west-2b” | .pod | .container | container_name="istio-proxy"


How did we do?