Kubectl Repl Versions Save

💁 Kubectl wrapper with variables. Run commands without pasting ids.

1.7

5 years ago

Changes since last stable release (1.6):

  • Empty lines and lines beginning with a comment (#) are no longer send to the underlying kubectl (#12, #13)

Many thanks to @walfie for the changes! 🥇

Complete changelog since the previous release: https://github.com/Mikulas/kubectl-repl/compare/1.6...1.7

This release is also available as a Docker image: https://hub.docker.com/r/mikulas/kubectl-repl/

1.6

5 years ago

Changes since last stable release (1.4):

  • Improved placement of context and namespace options in the final bash command
    • Formerly, kubectl-repl used to insert those options directly after kubectl such as kubectl --namespace=default plugin-name. This was however incompatible with kubectl plugins (see https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/).
    • Now the options are placed after the command names, but before other options. Continuing with the previous example, now the final command would be kubectl plugin-name --namespace=default.
  • Fixes #10 Objects with hyphens seem to break

A practical example of a kubectl plugin is an executable named kubectl-old somewhere in your $PATH such as this:

#!/usr/bin/env bash
set -eu
kubectl get "$@" --sort-by=.metadata.creationTimestamp

That allows you to call kubectl old pods (get pods sorted by creation time) in addition to the original kubectl get pods (sorted by name). In kubectl-repl, this of course simplifies to invoking old pods. Note the the plugin cannot be called kubectl-get-sorted for example, because the builtin commands cannot be overshadowed even when the longest executable filename rule would take place.

Complete changelog since the previous release: https://github.com/Mikulas/kubectl-repl/compare/1.4...1.6

This release is also available as a Docker image: https://hub.docker.com/r/mikulas/kubectl-repl/

1.5

5 years ago

recalled

1.4

5 years ago

Changes since last stable release (1.1):

  • Added indexed variables. Now it's possible to access all columns in the output.
    • The syntax is $var:index, eg $1:2` to access the second column of first variable.
    • The main short syntax $var still works (and will always work). It defaults to $var:1.
    • This is meant mostly for non-standard output, such as --all-namespaces which puts namespace on the first column and unique resource name on the second column.
# beta kube-system get pods --all-namespaces
  	NAMESPACE        NAME                READY STATUS   RESTARTS  AGE
$1 	kube-monitoring  logspout-ds-9l4pw   1/1   Running  36        4d
$2 	kube-monitoring  logspout-ds-b2pws   1/1   Running  9         3d
$3 	kube-monitoring  logspout-ds-gs4nv   1/1   Running  0         4d
# beta kube-system ; echo $1
kube-monitoring
# beta kube-system ; echo $1:2
logspout-ds-9l4pw
  • Support for cluster switching #3
    • A new -context=string flag was introduced, which passed the context to all invoked kubectl commands. This greatly simplifies managing multiple clusters: an operator can have multiple shells opened at once with different contexts.
    • Example usage: ./kubectl-repl -context=beta
  • GCP / GKE Not supported #8
    • Repl wrapped every command around kubectl, but namespace selector communicated directly with the cluster through the golang SDK. In 2830fe35ab8a5c43d6e9243257abca1876ab4454 this was refactored to also use kubectl. This solves many issues, including authentication and state persistence with KUBECONFIG.
  • If machine output is detected (json, yaml), lines are not prefixed and saved to variables. Same with --help.
  • Similarity matching fixes.
  • Added autocomplete dictionary to Docker rlwrap.

Complete changelog since the previous release: https://github.com/Mikulas/kubectl-repl/compare/1.1...1.4

This release is also available as a Docker image: https://hub.docker.com/r/mikulas/kubectl-repl/

1.3-alpha

5 years ago

resolved issues:

  • Support for cluster switching #3
    • A new -context=string flag was introduced, which passed the context to all invoked kubectl commands. This greatly simplifies managing multiple clusters: an operator can have multiple shells opened at once with different contexts.
    • Example usage: ./kubectl-repl -context=beta
  • GCP / GKE Not supported #8
    • Repl wrapped every command around kubectl, but namespace selector communicated directly with the cluster through the golang SDK. In 2830fe35ab8a5c43d6e9243257abca1876ab4454 this was refactored to also use kubectl. This solves many issues, including authentication and state persistence with KUBECONFIG.

1.2-alpha.2

5 years ago

This is a botched release with broken features, removed

Original content
  • removed dynamic watch mode introduced in alpha 1

    • The output was too wonky and the utility was minimal.
  • added support for KUBECONFIG env variable

    • Consists of two parts, separated by a colon (:). The first part sets path to kube config (defaults to $HOME/.kube/config). The other part overrides current context.
    • Example: KUBECONFIG="$PROJECT/kubecfg.yaml:prod" use context prod defined in custom config

Wrapper for kubectl-repl with context as inline parameter:

#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

if [[ $# -ne 1 ]]; then
    echo "Usage: $0 context"
    exit 1
fi

CTX="$1"
export KUBECONFIG="$HOME/.kube/config:$CTX"
rlwrap kubectl-repl

1.2-alpha

6 years ago
  • dynamic watch mode

    • Overrides existing lines based on first column, which is assumed to be an identifier. This greatly simplifies the output as it's immediately obvious how many resources exist and what state they are in. 9a44cf9
  • if machine output is detected (json, yaml), lines are not prefixed and saved to variables

  • similarity matching fixes

1.1

6 years ago

resolved issues:

  • docker container now contains kubectl - Thanks to /u/preflightsiren
  • readme now correctly refers to ~/.kube instead of .kops

No changes were made to the REPL itself.

Complete changelog since the previous release: https://github.com/Mikulas/kubectl-repl/compare/1.0...1.1

This release is also available as a Docker container: https://hub.docker.com/r/mikulas/kubectl-repl/

1.0

6 years ago

resolved issues:

  • Stream support for --watch and --follow #6
  • Interactive commands are unavailable (exec -it) #7
  • Int signal (^C) now only kills invoked process, not whole repl
  • Stderr is no longer silenced in get commands
  • Add -version flag

While version 1.0 is considered stable, it's feature set is not fixed and will evolve. REPL should only be used for interactive work, not in scripts. For that, either use kubernetes api directly or kubectl yaml/json output.

Complete changelog since the previous release: https://github.com/Mikulas/kubectl-repl/compare/0.2...1.0

This release is also available as a Docker container: https://hub.docker.com/r/mikulas/kubectl-repl/

0.2

6 years ago

resolved issues:

  • Variable substitution boundaries #5

new features:

Complete changelog since the previous release: https://github.com/Mikulas/kubectl-repl/compare/0.1...0.2

This release is also available as a Docker container: https://hub.docker.com/r/mikulas/kubectl-repl/