Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: K8s-like contexts or AWS cli-like sections #2316

Closed
asachs01 opened this issue Nov 12, 2018 · 8 comments
Closed

Feature Request: K8s-like contexts or AWS cli-like sections #2316

asachs01 opened this issue Nov 12, 2018 · 8 comments
Assignees
Milestone

Comments

@asachs01
Copy link

In using Sensu Go, I've created several clusters that I would love to be able to switch back and forth between. Currently, I have to reconfigure Sensu every time in order to switch. Would it be possible to implement contexts/sections in my config so that I can make switching between clusters a non-issue?

@calebhailey
Copy link

calebhailey commented May 6, 2020

I would also love this! In the interim, my workaround has been to switch sensuctl configs as I change directories from one project to another using direnv. <3 https://direnv.net/

Upon $ cd /projects/customers/acme-inc the local .envrc updates sensuctl config to the acme-inc backend, namespace, user, tls cert, or all of the above!).

@DoctorOgg
Copy link

I would love to have this feature, as a have a local sense-go running at home for testing and others for work and some volunteer work, it would be nice to have my workstation setup to talk to all of them without games to switch out configs. Please prioritize this feature.

@ichilton
Copy link

I would really like this too!

@tarunptala
Copy link

+1

@calebhailey
Copy link

Quick update on this issue, for those of you who are following along at home: we're still working on longer-term plans around a first-class implementation here (e.g. something similar to kubectl config use-context switching). In the shorter/immediate term we're also considering a stopgap proposal to add sensuctl support for reading a single environment variable: $SENSU_CONFIG_DIR. This would enable "context switching" using simple OS primitives like environment variables.

In the interim, the following workaround assumes familiarity with direnv and should give you a preview of what to expect if we simply add support for the $SENSU_CONFIG_DIR environment variable:

  1. Create a wrapper script for sensuctl:

    #!/bin/sh
    /usr/local/bin/sensuctl ${@} --config-dir ${SENSU_CONFIG_DIR}
    

    NOTE: if we add sensuctl support for reading $SENSU_CONFIG_DIR, you wouldn't need this wrapper script.

  2. Configure an alias or modify your $PATH to call this script. You can do this in your user profile, or add the following line to your .envrc files (again, assumes familiarity with tools like direnv):

    export PATH=/path/to/wrapper/bin/:$PATH
    

    NOTE: same comment as above, if/when we add support for $SENSU_CONFIG_DIR, you won't need to modify your path.

  3. Add $SENSU_CONFIG_DIR to your .envrc files!

    Example file tree:

    sensu/
    ├── us-central-1/
    │   ├── .envrc
    │   └── .sensu
    │       ├── cluster
    │       └── profile
    ├── us-east-1/
    │   ├── .envrc
    │   └── .sensu
    │       ├── cluster
    │       └── profile
    └── us-west-1/
        ├── .envrc
        └── .sensu
            ├── cluster
            └── profile
    

    Now sensuctl will automatically switch "contexts" (i.e. which sensu-backend you're connected to) as you switch directories!

  4. Profit? 😅

I hope this helps!

@portertech portertech added this to the 6.3.0 milestone Nov 23, 2020
@portertech portertech modified the milestones: 6.3.0, 6.4.0 Dec 7, 2020
@portertech portertech modified the milestones: 6.4.0, 6.5.0 Feb 5, 2021
@calebhailey calebhailey modified the milestones: 6.5.0, 6.6.0 Apr 19, 2021
@calebhailey
Copy link

Hello, all 👋 sorry for the radio silence here.

We did manage to sneak in a related sensuctl enhancement in 6.3.0 (#4256) so you can now sensuctl --api-url xxx --api-key xxx entity list without a pre-configured sensuctl. The --api-url and --api-key flags will also override your local sensuctl configuration.

We did not add support for the SENSU_API_KEY environment variable in the 6.3.0 release (an omission on my part), so we'll get that remedied in an upcoming release, along with support for SENSU_CONFIG_DIR (as outlined in this issue). These environment variables, along with the ability to seed new clusters with an API Key (#4162), should help simplify "multi cluster management". These improvements should land in 5.5.0 or 5.6.0.

We are still interested in a first class "contexts" command (or similar) for Sensu Go in the long term, but #4256 and the related upcoming enhancements should make multi cluster management significantly easier in the interim.

@calebhailey calebhailey modified the milestones: 6.next, 6.9.0 Aug 19, 2022
@portertech
Copy link
Contributor

TODO:

  • Add support for the SENSU_API_KEY and SENSU_CONFIG_DIR environment variables

@c-kruse c-kruse self-assigned this Sep 26, 2022
@c-kruse
Copy link
Contributor

c-kruse commented Sep 26, 2022

:) TODONE! Thanks @fguimond for adding this about a year ago: #4393

This has been functional since 6.4.3 and appears to work rather well.

@c-kruse c-kruse closed this as completed Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants