Webinar Q/A: reusing resources across namespaces

We had a great webinar yesterday where Caleb covered What’s new in Sensu Go aimed at current Sensu Classic users. Thanks for everyone who attended, we’ll be posting the video soon for those who coudln’t attend.

Just a reminder for everyone, Sensu Classic EOL is coming up at the end of 2019, and we want to make sure all our existing users are as prepared as possible to make the jump to Sensu Go.

During yesterday’s webinar we had a couple of question that we didn’t have time to address, so I volunteered to rebroadcast them here in the forum. I’m keeping the questions anonymous for now, but if the attendee wants to claim them and reply that’d be great.

Here’s the first question:

Is it possible to reuse easily checks/handler/assets in multiple namespace?

Currently, we can’t have resources scoped into multiple namespaces. But it’s possible to reuse resources from one namespace and create it in another assuming your user has the necessary access to both namespaces.

Let’s assume you are authorized with sensuctl with a user that has at least GET and LIST access for resources in a namespace named ‘prototype’ and as full access for resources in namespace ‘production’.

Here’s an example of how to quickly duplicate a check resource named ‘check_load’
using jq and the wrapped-json version of the resource:
sensuctl check info check_load --format wrapped-json --namespace prototype |jq '.metadata.namespace = "production"' | sensuctl create

This jq invocation will only edit the attribute we want changed. Trying this with sed command can be slightly more brittle because it’s harder to ensure sed won’t match another line in the resource config.

1 Like