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.
brew tap ivanklee86/homebrew-tap
brew install ivanklee86/tap/argonap
docker run -it --rm ghcr.io/ivanklee86/argonap:latest
go install github.com/ivanklee86/argonap@latest
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)
Projects can be selected by the following CLI flags. Flags can be used multiple times.
--name
will causeargonap
to only make changes to the target AppProject(s).--label
will only select AppProjects where all labels are matched. Labels should be in formatkey=value
. Using this flag multiple times will select projects that match all specified labels.
Passing no options will run the command on all projects.
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": ["*"]
}
]
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)
The clear
command removes all SyncWindows on projects matching selection criteria.
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)