Installing and using Applications and Software
Research sometimes leads to applications that are worth sharing with the world or that need real-world interaction to further their development or that just need several machines: some to execute/test the application, others to develop/train the application.
You should, from the start, have the complete picture in mind about what to do where: the (as minimal as possible) runtime machine that (eventually) is accessible from the outside world versus the (more complete) internal development machines and the way data is shared between them. See the schematic overview below.
Usually, the first thing to do is to fine-tune it internally, in or from within the departmental intranet. See the section below about installing software.
Making your Application available to the World
Once you have your application up and running internally, you can make it available to the outside world. This should be done by means of a web interface (either in your application itself or with a web frontend that uses/calls your application). The web interface is then made available by means of a proxy service - see the departmental OpenStack documentation for typical use.
In this way, there is an extra (security) layer between the (anonymous) users on the internet and (the machine that runs) your application.
The proxy service is known by the public URLs that you want to use for your application/project. You can have several URLs, such that you can keep using the same official URL overall, but migrate from older to newer versions as needed: first test a newer version with a newer URL and if it works as expected, make the official URL point to the new version as well. Or have several versions side by side.
The URLs you want to use do not need to be known from the start - you can set up / add as you go - the first steps are probably from within the departmental intranet directly to the runtime backend machine anyway - but do not wait too long, the step from direct internal interaction to external interaction via proxy service might not be as trivial as thought at first sight.
Installing Software
On departmental system group administered computers, you don't have admin rights / sudo rights / root access. At first it might seem challenging to install software without those rights / access. But there are a number of ways with which this might be easier than initially thought.
The general overview of installing software on system group administered computers provides more details - but below is a shorter overview. Do notice that the same principles are in use on both physical and virtual machines - they are managed in exactly the same way.
- by far the easiest way of installing software is by means of Ubuntu/Debian packages from an Ubuntu or other trusted 3rd party repository
- just let us know which package (and if needed from which repository) and we will configure it to be installed on the machine(s) you need
- if your software is not available in such a repository, then it might be available in Python PIP/virtualenv format or in AppImage package
- these formats (and possibly others as well) can be used to install and use software with an unprivileged account
- if your software is also not available in such a format, then you might be able to install it from source or distribution yourself, in a (sub)directory of your choice (in your own home dir, another local dir, a shared network dir, ...)
- if your software also cannot be installed in this way (e.g. because it really needs sudo to be installed), you might be able to install and use it in a container
- the container itself is executed (started, stopped, ...) by means of your (or another) unprivileged account
- but within the container you can install and configure software as (the) root (user of the container)
- finally, if your software also cannot be installed in a container, then your last resort is to apply for and use a departmental OpenStack project in which you can create, configure and use your own virtual machines in which you do have admin rights / sudo rights / root access - but then you are completely on your own for managing the entire virtual machines (OS and applications)
Do notice that your responsability and effort increases from top to bottom: very little in the first option and a lot in the last option. We strongly advise to really try to stay as high in this list as possible ;-)
Tuning your Application
Sometimes applications need more configuring than just some config files. Data-sets might need tuning, models might need training, ... Often quite some resources are needed to do so. In that case it might be best to do this kind of tuning/training on other machines than the one(s) that run(s) your application. Moreover the tuning/training might need software or data that you'ld rather not expose to the outside world.
So besides the machine where your application is running and the proxy server where your application is accessible for the outside world, you can also have machine(s) where your application is developed/tuned/trained. Usually such development machines are located in the departmental intranet and (application) data is made available from and to your application via a shared (NetApp) data volume.
The (minimal) runtime machines are fundamentally different from the (powerfull) intranet development machines:
- the runtime machines are accessible from the internet (be it in an indirect way) - it is departmental policy that such machines are limited: they cannot access the internet themselves, unless in very restricted, explicit ways and they only have the software installed that is really needed there
- the intranet development machines are not restricted, can access the internet and other intranet resources and can have any (version of) software installed - it is departmental policy that such machines are not accessible from the internet
These very basic security rules limit the possible damage that can be done and are therefore very basic but strong pillars.
Schematic Overview
+----+ +--------+
|user| --- |internet|
+----+ +--------+
| +----------------+[2a]
[1]+-------------+ |your application|
|proxy service| ---[2b] on minimal |
+-------------+ |runtime machine |
+----------------+
| +-----------------+[4]
[3]+-----------+ | powerfull |
| runtime | --- |intranet machines|
|data volume| | for development |
+-----------+ +-----------------+
|
+-----------+[5]
|development|
|data volume|
+-----------+
- [1] the proxy service is known by the names that you want to use publicly:
- https://yourproject.be/
- https://yourproject.cs.kuleuven.be/
- https://yourproject-v1.cs.kuleuven.be/
- ...
- https://yourproject.cs.kuleuven.be/version-1/
- https://yourproject.cs.kuleuven.be/version-2/
- https://yourproject.cs.kuleuven.be/something-else/
- ...
- [2a] the runtime machine has a typical 'backend' name and [2b] offers its service(s) on specific port(s)
- [3] the runtime data volume holds the (minimal) data needed for the application
- if the runtime data is small enough, it can be stored on the file system of the runtime machine itself
- [4] the intranet machines are most probably existing (CPU/GPU) compute servers
- software is / can be installed in the runtime and development machines in exactly the same way
- [5] the development data volume typically holds more/other data: archive of older versions, training data, ...
- runtime and development data can be combined on the same volume by using separate sub-directories but this lowers security: the other/training data might be accessible for/via the web interface as well
- in some exceptional cases direct access from the internet to the runtime machine is needed but this lowers security
Implementation Details
Firewall Issues
The development machines are intranet machines and they therefore have direct access to all machines, including internet - no firewalls need to be opened or special ports need to be used.
The minimal runtime machines however, are usually located in a restricted firewall zone and they are therefore 1) not directly accessible via SSH from the internet and 2) do not have access themselves to the internet.
As explained in the departmental OpenStack documentation (see More details in the Ready-to-Run/Managed Instances section), you probably need to specify the port 2222 when using SSH and you can do so only via departmental OpenVPN or SSH or intranet servers.
If the runtime machines need access to resources on the internet (e.g. to build containers or so) the departmental proxy should be used - probably and by preference, the unauthenticated one, only if needed the authenticated one. If additional sites must be added to the unauthenticated configuration, please contact helpdesk.
In a nut-shell:
ssh -p 2222 account@machine.cs.kuleuven.be ssh -p 2222 -J login@ssh.cs.kuleuven.be account@machine.cs.kuleuven.be http_proxy=http://oauthproxy.cs.kuleuven.be:8008/ https_proxy=http://oauthproxy.cs.kuleuven.be:8008/ pip install ...
Using several accounts
In a minimal setup only a single private/unprivileged account is created/used on a runtime machine, but if you have several applications that are hosted/run on the same runtime machine or if you want to separate configuration from run-time, it might be wise to use separate accounts for each application/task - just ask/contact helpdesk to sort it out.
Often a separate account app-run is used to actually run the application, where as an account app-conf is used to configure the application. In some (rare) cases also an account app-data can be used if you even want to separate the conf responsibility from the data/content responsibility.
In this way, if your app is abused or infected, no harm can be done to either data or configuration (unless you explicitly made them writable for the run-account) - this might be important: sometimes infected sites/apps are used to infect others, which is more difficult if the run-account has no write-permission on conf or data.
In a nut-shell: consider to use separate app-run and app-conf accounts and if needed/applicable others (like app-data or app-install) as well.
Automatic start @reboot
If you want to start up your application(s) at boot-time, so that you do not need to intervene manually each time the host your application is running on is rebooted, you must create a start-up script and have it called at boot-time. An example of such a start-up script is shown below - YMMV depending on the exact context.
Calling the start-up script at boot-time can be done in either an @reboot crontab or in a cs-localservices boot-script. Both can be configured in the departmental system-administration configuration. In this way such boot-time scripts are 1) installed/activated automatically by the systems-management platform and 2) in a similar way on all systems. You can of course also create your own @reboot crontab - you then have complete control yourself but you then are also on your own. Ask helpdesk for help if you want to include your automatic boot-time startup-script in the system-administration configuration.
A third option is to use a user-level systemd service unit file - if you want to pursue this option, please contact helpdesk and/or see below.
In a nut-shell: decide how to start your application(s) at boot-time: @reboot crontab, cs-localservices boot-script or systemd user-level unit file.
When writing your own start-script, do take into account that modern Linux systems use a massive parallel boot procedure, so not all required services (e.g. network) are guaranteed to be active when your service is started - you might need an additional sleep or explicit wait when starting.
Time line
- decide on a good name - it will probably be used for the runtime machine, the account(s) on the runtime machine, the data volume(s) and the public URL(s) - e.g.:
- runtime machine: X-section-hera.cs.kuleuven.be or X-backend.cs.kuleuven.be
- accounts: Xrun and Xconf
- proxy: X.cs.kuleuven.be
- ask helpdesk to create/install the runtime machine, its accounts and possibly the data volume(s)
- if specific software is needed, decide whether to have it installed system wide by helpdesk or install it yourself using the account(s)
- if the runtime machine is an OpenStack virtual machine, ask helpdesk to open the port where your application is listening on - by default OpenStack virtual machines are completely blocked by the internal OpenStack firewall
- install and configure your application from within departmental networks or via VPN
- when your application is ready, ask helpdesk to activate the public URL(s) on the proxy service of your section/research group
Example boot-time start-up script
You need to create (or maybe your service already has it) a start/stop script that accepts (at least) the start and stop arguments as in the example below:
#!/bin/bash
case "$1" in
# start and stop are obligatory
start)
/path/to/your/service options-to-start ...
;;
stop)
# If possible/needed uncomment the line below
# and implement the right way to stop the service.
# This is not really needed because at shutdown
# all remaining processes are sent the TERM signal anyway
# but this start/stop script MUST accept the stop
# argument to avoid unnecessary errors/warnings.
# Whether or not you actually implement the stop action
# is up to you (but might be handy while testing ;-)
# /path/to/your/service options-to-stop ...
;;
# the arguments below are optional but might be handy for yourself
# these arguments are not used by the start/stop sequence as executed
# at boot/shutdown-time and are therefore only meant for manual/command line
# use by the service owner/maintainer
restart)
"$0" stop
sleep 2
"$0" start
;;
status)
# commands to give the status of your service: running/stopped/how busy/...
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
exit 1
;;
esac
Example systemd user configuration
Create and activate your app as a service:
loginctl enable-linger $USER vi ~/.config/systemd/user/myapp.service [Unit] Description=My Personal App [Service] ExecStart=/path/to/my/app start ExecStop=/path/to/my/app stop [Install] WantedBy=default.target systemctl --user enable myapp systemctl --user start myapp
You might want to add other systemd sections or config. Logs can be read with:
journalctl --user -u myapp.service

