Skip to content

Extracting Data from Manifests

This chapter continues from the final setup of the previous tutorial and focuses on hydra local find.

With hydra local find, you can query rendered entities from one app, shape the output with --pick, and narrow the result set with --include and --exclude.

Goal

By the end of this chapter, you can:

  • run hydra local find <app-id> on the existing app setup
  • use --pick to build custom scalar and object output per matched entity
  • use --include and --exclude with CEL expressions
  • access Helm-rendered objects via templateEntity in filters and picks

Prerequisite

Complete Inspect Manifests and Their Templates first.

At the start of this chapter, your directory structure should still match the final step of the previous chapter:

Step 1: Start with hydra local find <app-id>

Run:

hydra local find cluster.app

In this first run, no --pick is set, so Hydra uses the default pick expression id and prints the IDs of the matched entities.

Since no --include or --exclude is used in this call, the output simply contains all defined IDs.

Step 2: Shape the Output with --pick

With --pick, you provide a CEL expression that is evaluated per matched entity to build the YAML result list.

The default value for --pick is id, but you can return custom strings or JSON-like objects.

Example: create strings

hydra local find cluster.app --pick 'name + "@" + ns'

Example: create JSON objects

hydra local find cluster.app --pick '{"group":group, "namespace":ns, "name":name, "version": version}'

Step 3: Use --include and --exclude with templateEntity

--include and --exclude also work on hydra local find.

With templateEntity, you can access the object returned by Helm template rendering. CEL expressions for --include and --exclude must evaluate to boolean values (or key not found). Example include filter:

hydra local find cluster.app --include 'templateEntity.spec.template.spec.containers != null'

The != null at the end is required so the expression evaluates to a boolean value.

This keeps only entries where that field exists. If evaluation hits key not found, those entries are skipped automatically.

When only this include expression is used, no additional filter on kind is active. Because of that, multiple resource kinds can appear in the result.

--exclude works the same way and removes entities that match the expression.

For example:

hydra local find cluster.app --exclude 'kind == "Service"'

Step 4: Use templateEntity inside --pick

You can also use templateEntity in --pick to include rendered data directly in the output.

key not found cases are skipped automatically, so in this scenario --pick can be used instead of --include.

hydra local find cluster.app --pick '{"id":id, "images":templateEntity.spec.template.spec.containers.map(c, c.image)}'

Summary

At the end of this chapter, you can query rendered entities with hydra local find, shape the output with CEL via --pick, and filter against rendered data with --include / --exclude and templateEntity.