shorten the name of the job considerably.
this will allow for repos that have names much longer than before since a job's name can only be up to 63 characters long and the distinguishing name of the job was taking up 51 of those.
This commit is contained in:
parent
bf8e415b48
commit
e94e9f55d2
|
@ -23,7 +23,7 @@ export IMAGE=alpine/git:latest
|
||||||
export CONTEXT="$(echo "${2#*://}" | cut -d / -f 1)"
|
export CONTEXT="$(echo "${2#*://}" | cut -d / -f 1)"
|
||||||
export NS="$(echo "${2#*://}" | cut -d / -f 2)"
|
export NS="$(echo "${2#*://}" | cut -d / -f 2)"
|
||||||
export REPO="$(echo "${2#*://}" | cut -d / -f 3)"
|
export REPO="$(echo "${2#*://}" | cut -d / -f 3)"
|
||||||
export RUNID="$(uuid)"
|
export RUNID="$(dd if=/dev/random bs=600 count=1 status=none | base64 | tr -dc a-z0-9 | cut -c 1-6)"
|
||||||
|
|
||||||
while read -r cmd arg rest; do
|
while read -r cmd arg rest; do
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
|
@ -53,6 +53,7 @@ read
|
||||||
echo
|
echo
|
||||||
$SUBCOMMAND
|
$SUBCOMMAND
|
||||||
"
|
"
|
||||||
|
# if you named your pod FILTERME_HFOIQJF, I apologize
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
---
|
---
|
||||||
|
@ -67,13 +68,13 @@ spec:
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 1Gi
|
storage: 1Gi
|
||||||
storageClassName: longhorn
|
storageClassName: ${GIT_REMOTE_K8S_STORAGECLASS-FILTERME_HFOIQJF}
|
||||||
volumeMode: Filesystem
|
volumeMode: Filesystem
|
||||||
---
|
---
|
||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: Job
|
kind: Job
|
||||||
metadata:
|
metadata:
|
||||||
name: ${REPO}-git-connector-${RUNID}
|
name: ${REPO}-gitc${RUNID}
|
||||||
namespace: ${NS}
|
namespace: ${NS}
|
||||||
labels:
|
labels:
|
||||||
git.kn8v.com/runid: ${RUNID}
|
git.kn8v.com/runid: ${RUNID}
|
||||||
|
@ -98,18 +99,19 @@ spec:
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: ${REPO}
|
claimName: ${REPO}
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
' | yq ea '(.. | select(tag == "!!str")) |= envsubst' | kubectl --context "$CONTEXT" apply -f - 1>&2
|
' | grep -v FILTERME_HFOIQJF | yq ea '(.. | select(tag == "!!str")) |= envsubst' | kubectl --context "$CONTEXT" apply -f - 1>&2
|
||||||
|
|
||||||
KILLLOGS=:
|
KILLLOGS=:
|
||||||
|
|
||||||
finalize() {
|
finalize() {
|
||||||
kubectl --context "$CONTEXT" delete job -n "$NS" "${REPO}-git-connector-${RUNID}" 1>&2
|
kubectl --context "$CONTEXT" delete job -n "$NS" "${REPO}-gitc${RUNID}" 1>&2
|
||||||
$KILLLOGS
|
$KILLLOGS
|
||||||
exit # must exit for INT and TERM.
|
exit # must exit for INT and TERM.
|
||||||
}
|
}
|
||||||
trap finalize INT TERM
|
trap finalize INT TERM
|
||||||
|
|
||||||
kubectl --context "$CONTEXT" wait job "${REPO}-git-connector-${RUNID}" --for jsonpath=.status.ready=1 1>&2
|
kubectl --context "$CONTEXT" wait job "${REPO}-gitc${RUNID}" --for jsonpath=.status.ready=1 1>&2
|
||||||
(echo;cat) | kubectl --context "$CONTEXT" attach -i -q -n "$NS" "job/${REPO}-git-connector-${RUNID}"
|
(echo;cat) | kubectl --context "$CONTEXT" attach -i -q -n "$NS" "job/${REPO}-gitc${RUNID}"
|
||||||
|
|
||||||
# also finalize on exit
|
# also finalize on exit
|
||||||
finalize
|
finalize
|
||||||
|
|
Loading…
Reference in New Issue
Block a user