A collection of plugins for kubectl integration (for Kubectl versions >= 1.12.0)
- These plugins are for kubectl versions at or above 1.12.0 only. Check your version via
kubectl version
- For versions below 1.12.0, use the 1.11.0 branch.
- To upgrade your kubectl version via homebrew:
brew upgrade kubectl
, or via gcloud:gcloud components update
- Some plugins require jq ( brew/apt/yum install jq )
- All coding was written to maintain compatibility across both BSD and GNU.
git clone https://github.com/jordanwilson230/kubectl-plugins.git
cd kubectl-plugins
./install-kubectl-plugins.sh
source ~/.bash_profile
rm -rf ~/.kube/plugins/jordanwilson230
ex '+g/jordanwilson230/d' -cwq ~/.bash_profile
- Like kubectl exec, but offers a --user flag to exec as root (or any other user)
- 'ssh' is a misnomer (it works by mounting a docker socket as a volume), but it's easier to work with as a command.
- Kudos to mikelorant for thinking of the docker socket! :)
Option | Required | Description | Example |
---|---|---|---|
-h | N | Show usage | kubectl ssh -h |
-p | Y | Pod name. The -p flag can be omitted if no other flags are passed (i.e., kubectl ssh kafka-0 ) |
kubectl -p kafka-0 |
-u | N | User to exec as. Defaults to root | kubectl ssh -u kafka -p kafka-0 |
-c | N | Specify container within pod | kubectl ssh -c burrow-metrics -p kafka-0 |
-- | N | Pass an optional command. Defaults to /bin/sh | kubectl ssh kafka -- ls /etc/burrow |
- View current namespace:
kubectl switch
- Switch namespace:
kubectl switch preprod
- Switch cluster:
kubectl switch cluster staging
- List and select from all available clusters:
kubeclt switch cluster -l
Option | Required | Description | Example |
---|---|---|---|
-l | N | List available clusters and prompts for selection. Can only be used when cluster is passed. |
kubNctl switch cluster -l |
-h | N | Show usage | kubectl switch -h |
- Displays a warning prompt when issuing commands in a flagged cluster or namespace
- Commands that trigger the prompt include
create, scale, delete, apply, etc.,
- Flag a namespace:
kubectl prompt add -n production
- Flag a cluster:
kubectl prompt add -c my-cluster
- List flagged environments:
kubectl prompt list
- Clear flagged environments:
kubectl prompt remove
- View description:
kubectl prompt
Note: When removing the prompt plugin, delete the line beginning with function kubectl()
and KUBECTL_*_PROMPT
in your ~/.bash_profile.
- Outputs the node name, node IP, and Pod IP for a given resource. Search is performed against common labels (defaults to app, name, component)
Example: kubectl ip cassandra
- Displays total uptime for pods/statefulsets in the current namespace.
Example: kubectl uptime