<mohammadrony>

Foreach

Installation

kubectl krew install foreach

Configuration

Disable prompt for cli session

tee -a ~/.bashrc << EOF # ~/.zshrc
export KUBECTL_FOREACH_DISABLE_PROMPTS=true
EOF

Usage

kubectl foreach -h

Disable prompt for a command

kubectl foreach -q -- ...

Get pods for all context in default namespace

kubectl foreach -- get pods

Context a, b, c nodes

kubectl foreach a b c -- get nodes

Context having foo in name

kubectl foreach /foo/ -- get nodes

Context not having foo in name

kubectl foreach ^/foo/ -- get nodes

Update context name with parameter

kubectl foreach -I _ /foo/ -- --context=_ get pods