This container provides a mechanism to execute scripts on the kyso-scs
pod
using the webhook command.
Initially the container includes only two scripts:
-
du.sh
: Simple script to rundu
on organization/team folders (if only the organzation is passed all the teams are shown). -
hardlink.sh
: Script to run the hardlink command from util-linux inside the SCS data directory to replace duplicated files by hardlinks (saves a lot of disk space when files in different versions don’t change).
-
WEBHOOK_WORKDIR
: Unix PATH to the main SCS directory, the value is required and usually will be inside the mount point of thedatadir
volume (i.e. if the volume is mounted in/sftp
theWEBHOOK_WORKDIR
will be/sftp/data/scs
). -
COMMON_TOKEN
: Token expected in theX-Webhook-Token
header when there is no specific token defined; if the variable is not present and the specific token is not available the webhook does not require authentication. -
DU_TOKEN
: Token expected in theX-Webhook-Token
header when calling thedu.sh
script; if the variable is not present theCOMMON_TOKEN
is used. -
HARDLINK_TOKEN
: Token expected in theX-Webhook-Token
header when calling thehardlink.sh
script; if the variable is not present theCOMMON_TOKEN
is used.
The container definition for the StatefulSet
template will be something like
the following:
- name: webhook
image: __SCS_WEBHOOK_IMAGE__
imagePullPolicy: "__IMAGE_PULL_POLICY__"
ports:
- containerPort: 9000
name: webhook-http
env:
- name: WEBHOOK_WORKDIR
value: /sftp/data/scs
volumeMounts:
- mountPath: /sftp
name: __APP__-datadir
Basically we mount the datadir and adjust the WEBHOOK_WORKDIR and publish the
port 9000
.
To be able to access the service we have to add the new service to the ports
spec on the service template:
- name: webhook-http
port: 9000
protocol: TCP
targetPort: 9000
Once that is defined the hooks can be accessed using URLs of the form
http://kyso-scs-svc.$KYSO_SCS_NAMESPACE.svc.cluster.local:9000/hook/{id}
,
where id
can be du
or hardlink
.
With the default configuration the organization
and optional team
that have
to be passed to the command using query parameters org
and team
, i.e.
http://kyso-scs-svc.$ns.svc.cluster.local:9000/hook/du?org=kyso&team=sto
.