Created
October 12, 2019 22:27
-
-
Save nexus166/3ed9afa0254c3cceacc06944a27e5558 to your computer and use it in GitHub Desktop.
clean one-time container run in kube
This file contains hidden or 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
| #!/usr/bin/env bash | |
| function k8run() { | |
| set -xu; | |
| IMAGE="${1}"; | |
| PODNAME=$(basename "${IMAGE}" | tr ':' '-'); | |
| _ARGS=("${@:2}"); | |
| KUBE_ARGS=$(printf '"%s", ' "${_ARGS[@]}"); | |
| PRIVILEGED="${PRIVILEGED:-false}"; | |
| kubectl run "${PODNAME}-${USER}" --restart=Never -it --rm --attach --image overriden --overrides ' | |
| { | |
| "spec": { | |
| "containers": [ | |
| { | |
| "name": "'"${PODNAME}"'", | |
| "image": "'"${IMAGE}"'", | |
| "command": [ '"${KUBE_ARGS%??}"' ], | |
| "stdin": true, | |
| "tty": true, | |
| "securityContext": { | |
| "privileged": '"${PRIVILEGED}"' | |
| } | |
| } | |
| ], | |
| "tolerations": [ | |
| { | |
| "effect": "NoSchedule", | |
| "key": "node-role.kubernetes.io/master" | |
| } | |
| ] | |
| } | |
| }'; | |
| set +xu | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment