Compare commits
6 Commits
3b6d1f3f84
...
work-in-pr
Author | SHA1 | Date | |
---|---|---|---|
|
460cfe6254 | ||
|
d226951ba8 | ||
|
6694e1dde9 | ||
|
c7af9dc1ee | ||
|
f89dd485b8 | ||
|
3ed5cd92a9 |
12
README.md
12
README.md
@@ -12,9 +12,14 @@ kubectl plugin list
|
|||||||
```
|
```
|
||||||
|
|
||||||
## kubectl-rsh
|
## kubectl-rsh
|
||||||
|
Creates a pod on the node and executes a shell on that node.
|
||||||
|
|
||||||
|
You need cluster admin rights and privileged pod execution rights
|
||||||
|
|
||||||
|
```
|
||||||
Usage:
|
Usage:
|
||||||
kubectl rsh [nodeName]
|
kubectl rsh [nodeName]
|
||||||
|
```
|
||||||
|
|
||||||
### Variables
|
### Variables
|
||||||
| Name | Default | Desciption |
|
| Name | Default | Desciption |
|
||||||
@@ -23,3 +28,10 @@ Usage:
|
|||||||
| KUBECTL_RSH_IMAGE_TAG | latest | Image tag to use |
|
| KUBECTL_RSH_IMAGE_TAG | latest | Image tag to use |
|
||||||
| KUBECTL_RSH_NAMESPACE | default | Namespace to create the rsh pod in |
|
| KUBECTL_RSH_NAMESPACE | default | Namespace to create the rsh pod in |
|
||||||
| KUBECTL_RSH_POD_CREATE_TIMEOUT | 3 | Minutes to wait before failing to create pod |
|
| KUBECTL_RSH_POD_CREATE_TIMEOUT | 3 | Minutes to wait before failing to create pod |
|
||||||
|
|
||||||
|
## kubectl-deprecated_api
|
||||||
|
Lists APIs flagged as deprecated
|
||||||
|
```
|
||||||
|
Usage:
|
||||||
|
kubectl deprecated-api
|
||||||
|
```
|
||||||
|
7
kubectl-deprecated_api
Executable file
7
kubectl-deprecated_api
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if ! command -v prom2json > /dev/null; then
|
||||||
|
echo "You need prom2json to use this command"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
kubectl get --raw /metrics | prom2json | jq -c '.[] | select(.name=="apiserver_requested_deprecated_apis").metrics[].labels' | column -t -s'{}[],"'
|
@@ -23,7 +23,7 @@ if [[ "$1" == "version" ]];then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" == "--help" ]; then
|
if [[ "$1" == "--help" ]]; then
|
||||||
print_help
|
print_help
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@@ -75,6 +75,6 @@ function remove_pod(){
|
|||||||
trap remove_pod EXIT
|
trap remove_pod EXIT
|
||||||
|
|
||||||
echo "Waiting for pod to be ready..."
|
echo "Waiting for pod to be ready..."
|
||||||
kubectl wait -n "$KUBECTL_RSH_NAMESPACE" --for=condition=Ready --timeout ${KUBECTL_RSH_POD_CREATE_TIMEOUT}m "$POD" >/dev/null
|
kubectl wait -n "$KUBECTL_RSH_NAMESPACE" --for=condition=Ready --timeout "${KUBECTL_RSH_POD_CREATE_TIMEOUT}m" "$POD" >/dev/null
|
||||||
|
|
||||||
kubectl attach -n "$KUBECTL_RSH_NAMESPACE" -it "$POD"
|
kubectl attach -n "$KUBECTL_RSH_NAMESPACE" -it "$POD"
|
||||||
|
23
kubectl_complete-rsh
Executable file
23
kubectl_complete-rsh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# If we are completing a flag, use Cobra's builtin completion system.
|
||||||
|
# To know if we are completing a flag we need the last argument starts with a `-` and does not contain an `=`
|
||||||
|
args=("$@")
|
||||||
|
lastArg=${args[((${#args[@]}-1))]}
|
||||||
|
if [[ "$lastArg" == -* ]]; then
|
||||||
|
if [[ "$lastArg" != *=* ]]; then
|
||||||
|
kubectl ns __complete "$@"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# TODO Make sure we are not completing the value of a flag.
|
||||||
|
# TODO Only complete a single argument.
|
||||||
|
# Both are pretty hard to do in a shell script. The better way to do this would be to let
|
||||||
|
# Cobra do all the completions by using `cobra.ValidArgsFunction` in the program.
|
||||||
|
# But the below, although imperfect, is a nice example for plugins that don't use Cobra.
|
||||||
|
|
||||||
|
kubectl get nodes --no-headers -o custom-columns=":metadata.name"
|
||||||
|
|
||||||
|
# Turn off file completion. See the ShellCompDirective documentation within
|
||||||
|
# https://github.com/spf13/cobra/blob/main/shell_completions.md#completion-of-nouns
|
||||||
|
echo :4
|
||||||
|
fi
|
Reference in New Issue
Block a user