Created
December 20, 2019 19:05
-
-
Save lkoba/e73dcc13bd8d81907b1f4069a19979ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eo pipefail | |
json=`cat $1 | y2j` | |
overrides=`echo "$json" | jq "{spec}"` | |
name=`echo "$json" | jq -r ".metadata.name"` | |
labels=`echo "$json" | jq -r '.metadata.labels | keys[] as $k | "\($k)=\(.[$k])"' | paste -sd "," -` | |
image=`echo "$json" | jq -r ".spec.containers[0].image"` | |
shift | |
kubectl run "$name" -it --rm --image="$image" --labels="$labels" --restart=Never --overrides="$overrides" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good and simple workaround solution until
kubectl
provides the ability (which will most likely be never...) to run kubernetes pod manifests interactively.However, beware as this does not take into account:
A lot of parsing is still needed to actually correctly convert a usual pod manifest into a
kubectl run
command.