Skip to content

Intercepts kubectl on dangerous verbs for contexts defined as critical

Notifications You must be signed in to change notification settings

andymotta/kubectl-confirm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kubectl-confirm

kubectl-confirm is a utility that helps you prevent accidental dangerous operations on critical Kubernetes contexts. It works by intercepting kubectl commands and checking the context and verb against a list of critical contexts and dangerous verbs specified in a configuration file.

Quick Start

  1. cp sample_config.yaml ~/kube-confirm-config.yaml
  2. Update your .zshrc or a sourced file with the following Zsh function:
    function kubectl() {
        if [ $# -lt 1 ]; then
            command kubectl
        else
            local context=$(command kubectl config current-context | cut -d/ -f2)
            kubectl-confirm "${context}" "$1"
            local exit_code=$?
            if [ $exit_code -eq 0 ]; then
                command kubectl "$@"
            fi
        fi
    }
  3. Optionally set KUBECTL_CONFIRM_CONFIG in .zshrc to a custom path
    export KUBECTL_CONFIRM_CONFIG=/path/to/your/config.yaml

About

Intercepts kubectl on dangerous verbs for contexts defined as critical

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages