/argonap

CLI to make 🐙 take a quick 💤

Primary LanguageGoMIT LicenseMIT

argonap

GitHub ReleaseCI codecovGo Reference

Example

CLI to make 🐙 take a quick 💤

aka

ArgoCD SyncWindows are great for addressing those whacky situations that somehow pop up in real life:

  • Holidays
  • Failovers
  • Maintainance
  • Emergencies where you just want to run lots and lots of kubectl commands
  • Some (or all) of the above!🤣

argonap allows you to create and clear SyncWindows across multiple projects from the comfort of the command line.

Installation

Homebrew

brew tap ivanklee86/homebrew-tap
brew install ivanklee86/tap/argonap

Docker Image

docker run -it --rm ghcr.io/ivanklee86/argonap:latest

Go

go install github.com/ivanklee86/argonap@latest

Authentication

argonap uses a JWT to authenticate to ArgoCD. This can be configured in the Helm chart as follows:

configs:
  cm:
    accounts.YOUR_ACCOUNT_NAME: apiKey

  rbac:
    policy.csv: |
      p, role:argonap, projects, get, *, allow
      p, argonap, projects, update, *, allow
      g, YOUR_ACCOUNT_NAME, role:argonap

A JWT can be then generated using the ArgoCD CLI using the following command:

argocd login # Using username/password or SSO
argocd account generate-token --account YOUR_ACCOUNT

argonap flags can be set via environment variables with the format ARGONAP_[flag but replace - with _] e.g. ARGONAP_AUTH_TOKEN. This allows you to store the auth token securely and pass it to the CLI using your favorite local secrets solution (e.g. 1Password CLI)

Selection

Projects can be selected by the following CLI flags. Flags can be used multiple times.

  • --name will cause argonap to only make changes to the target AppProject(s).
  • --label will only select AppProjects where all labels are matched. Labels should be in format key=value. Using this flag multiple times will select projects that match all specified labels.

Passing no options will run the command on all projects.

Usage

set

The set command takes a file that contain a list SyncWindows to add to projects matching the selection criteria. The file should be a JSON file containing items that match the SyncWindows struct.

Example file:

[
    {
        "kind": "deny",
        "schedule": "00 3 * * *",
        "duration": "1h",
        "namespaces": ["*"]
    }
]

Help

Set SyncWindows from file

Usage:
  argonap set [flags]

Flags:
      --file string   Path to file with SyncWindows to configure
  -h, --help          help for set

Global Flags:
      --auth-token string       JWT Authentication Token
      --insecure                Don't validate SSL certificate on client request
      --label strings           Labels to filter projects on in format 'key=value'.  Can be used multiple times.
      --name strings            Project names to update.  If specified, label filtering will not apply.  Can be used multiple times.
      --server-address string   ArgoCD server address
      --timeout int             Context timeout in seconds. (default 240)
      --workers int             # of parallel workers. (default 4)

clear

The clear command removes all SyncWindows on projects matching selection criteria.

Help

Clear SyncWindows on all AppProjects.

Usage:
  argonap clear [flags]

Flags:
  -h, --help   help for clear

Global Flags:
      --auth-token string       JWT Authentication Token
      --insecure                Don't validate SSL certificate on client request
      --label strings           Labels to filter projects on in format 'key=value'.  Can be used multiple times.
      --name strings            Project names to update.  If specified, label filtering will not apply.  Can be used multiple times.
      --server-address string   ArgoCD server address
      --timeout int             Context timeout in seconds. (default 240)
      --workers int             # of parallel workers. (default 4)