Run in Toolforge kubernetes
Change-Id: If3807c75119c75e9f10f06b58963c30c8ec82e88
This commit is contained in:
parent
bb7c70931c
commit
2df53d9713
4 changed files with 98 additions and 6 deletions
|
@ -1,3 +0,0 @@
|
|||
#!/bin/bash
|
||||
cd ~/ircservserv
|
||||
time jsub -N build -mem 2G -sync y -cwd cargo build --release
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/bash
|
||||
cd ~/ircservserv-config
|
||||
/data/project/ircservserv/ircservserv/target/release/ircservserv
|
33
toolforge/deployment.yaml
Normal file
33
toolforge/deployment.yaml
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
# Run ircservserv on kubernetes
|
||||
# Adapted from stashbot's deployment file
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: ircservserv
|
||||
namespace: tool-ircservserv
|
||||
labels:
|
||||
name: ircservserv
|
||||
toolforge: tool
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
name: ircservserv
|
||||
toolforge: tool
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
name: ircservserv
|
||||
# Mount NFS
|
||||
toolforge: tool
|
||||
spec:
|
||||
containers:
|
||||
- name: ircservserv
|
||||
image: docker-registry.tools.wmflabs.org/toolforge-buster-standalone:latest
|
||||
command: [ "/data/project/ircservserv/ircservserv-config/toolforge/manage.sh", "run" ]
|
||||
workingDir: /data/project/ircservserv
|
||||
env:
|
||||
- name: HOME
|
||||
value: /data/project/ircservserv
|
||||
imagePullPolicy: Always
|
65
toolforge/manage.sh
Normal file
65
toolforge/manage.sh
Normal file
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/env bash
|
||||
# Management script for ircservserv kubernetes processes
|
||||
# Adapted from stashbot scripts
|
||||
|
||||
set -e
|
||||
|
||||
DEPLOYMENT=ircservserv
|
||||
POD_NAME=ircservserv
|
||||
|
||||
APP_DIR=/data/project/ircservserv/ircservserv
|
||||
CONFIG_DIR=/data/project/ircservserv/ircservserv-config
|
||||
CONFIG=${CONFIG_DIR}/toolforge/deployment.yaml
|
||||
|
||||
KUBECTL=/usr/bin/kubectl
|
||||
|
||||
_get_pod() {
|
||||
$KUBECTL get pods \
|
||||
--output=jsonpath={.items..metadata.name} \
|
||||
--selector=name=${POD_NAME}
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo "Starting ircservserv k8s deployment..."
|
||||
$KUBECTL create --validate=true -f ${CONFIG_DIR}/deployment.yaml
|
||||
;;
|
||||
run)
|
||||
date +%Y-%m-%dT%H:%M:%S
|
||||
echo "Running ircservserv..."
|
||||
cd ${CONFIG_DIR}
|
||||
${APP_DIR}/target/release/ircservserv
|
||||
;;
|
||||
stop)
|
||||
echo "Stopping the Kubernetes deployment..."
|
||||
$KUBECTL delete deployment ${DEPLOYMENT}
|
||||
# FIXME: wait for the pods to stop
|
||||
;;
|
||||
restart)
|
||||
echo "Restarting the running pod..."
|
||||
exec $KUBECTL delete pod $(_get_pod)
|
||||
;;
|
||||
status)
|
||||
echo "Active pods:"
|
||||
exec $KUBECTL get pods -l name=${POD_NAME}
|
||||
;;
|
||||
tail)
|
||||
exec $KUBECTL logs -f $(_get_pod)
|
||||
;;
|
||||
attach)
|
||||
echo "Attaching to pod..."
|
||||
exec $KUBECTL exec -i -t $(_get_pod) -- /bin/bash
|
||||
;;
|
||||
compile)
|
||||
echo "Compiling ircservserv on the grid..."
|
||||
cd ${APP_DIR}
|
||||
time jsub -N build -mem 2G -sync y -cwd cargo build --release
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status|tail|attach|compile}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
Loading…
Reference in a new issue