Skip to content

Instantly share code, notes, and snippets.

@ignlg
Forked from lkoba/run-yaml.sh
Created February 22, 2023 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ignlg/a579e7e47041f894a8f18a2ce1817f87 to your computer and use it in GitHub Desktop.
Save ignlg/a579e7e47041f894a8f18a2ce1817f87 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eo pipefail
json=$(y2j <"$1")
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