Skip to content

Instantly share code, notes, and snippets.

@lkoba
Created December 20, 2019 19:05
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lkoba/e73dcc13bd8d81907b1f4069a19979ec to your computer and use it in GitHub Desktop.
Save lkoba/e73dcc13bd8d81907b1f4069a19979ec to your computer and use it in GitHub Desktop.
#!/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