ITS Lab Server Administration and DevOps
Use this guide as a checklist when provisioning and configuring a Linux developer VM in the ITS lab. Follow current infrastructure and security-team procedures if they differ from the steps below.
Before you begin
- Connect to the required legacy OCF VPN before accessing vSphere.
- Confirm the VM name and an available IP address with the infrastructure team.
- Have access to the approved VM template, Portainer, Keeper, and the developer setup scripts.
1. Clone the VM in vSphere
- In vSphere, clone the approved VM template.
- Name the VM
VDITSWEB0<number>-<initials>(for example,VDITSWEB02-MK). - Select the OCF folder.
- Choose
ocf_haand host192.168.0.19. - Select the
Unity_Servers_ITSWEBstorage configuration. - Select No cloning options.
The remaining configuration can be completed from the VM console after cloning.
2. Configure the VM
The template’s default static IP is 172.18.10.99. Assign an address approved
for the VM before changing the network configuration. The reference guide
indicates addresses in the 172.18.10.81–172.18.10.89 range; confirm the
current allocation with the infrastructure team. A ping alone does not
guarantee that an address is unused.
Open the VM console and sign in using the approved administrator credentials. The reference guide identifies
itsdevordevas the template’s administrator account.Edit the Netplan configuration:
sudo nano /etc/netplan/01-static-ip.yamlUpdate the address and any related network settings to match the allocation. Save the file and apply the configuration using the approved procedure.
Set the hostname:
sudo nano /etc/hostnameUse the corresponding lowercase hostname, for example
vsitsweb02-mk. Keep the hostname consistent across inventory, Portainer, DNS, and Keeper.Reboot the VM:
sudo reboot
Docker DNS
The reference guide notes that Docker on the template should use DNS server
172.18.10.80 and public resolver 8.8.8.8. Confirm the required configuration
with the infrastructure team before changing Docker settings. Back up the
existing /etc/docker/daemon.json, preserve any other settings in that file,
then restart Docker if the configuration is updated.
3. Connect the VM to Portainer
After the VM is available on the Web Team VPN:
- Open Portainer.
- Go to Environments and select Add environment.
- Select the agent option currently approved for the environment. The reference guide uses Agent (legacy).
- Enter the VM name and its agent address, in the form
<VM-IP>:9001. - Add the environment to the appropriate group, such as Development or Infrastructure.
If the current Portainer setup requires an Edge Agent, generate its setup command in the authorized Portainer interface for this VM. Do not copy agent tokens or generated credentials into this documentation.
4. Configure domains and SSL
- Add the new developer VM’s domain to Caddy through the infrastructure server.
- SSH into the infrastructure server
VSITSWEB01and locate the Caddy configuration folder. Find the config file where the new subdomain should be added and point it to the VM’s IP address. - Add the new domain to the config file, then force an update of the file or restart the Docker Compose setup.
- Sign in to the VM’s Nginx Proxy Manager at
https://domains.<initials>.lab.itsdev.ca, replacing<initials>with the developer’s initials. Retrieve the login from the Nginx Proxy Managers record in Keeper. - Update the example/test proxy host to use the developer’s intended subdomain and service port.
- Open the test domain in a browser and confirm that it responds as expected.
Each VM has an Nginx Proxy Manager instance for managing project domains and ports. Coordinate Caddy-side DNS/proxy changes with the infrastructure team.
5. Install security tooling and refresh SSH access
Run the approved its-devops-dev-user-setup scripts from their provided
directory:
Enroll the VM in Datto EDR:
cd its-devops-dev-user-setup ./security-step-1-datto-apps.shThe reference guide identifies the ITS Datto EDR instance as itsmai7219.infocyte.com. Notify the ITS Security Team when the new Linux VM has been enrolled so they can confirm that its hostname appears.
Refresh the SSH certificate:
./security-step-2-reset-ssh.shFollow the terminal’s installation instructions. Store the generated certificate and required connection details in the appropriate Keeper record, in the ITS Lab 2026 folder. Use a record name such as
vsitsweb02-mk - SSH.Confirm that SSH access works before attaching the certificate file to the Keeper record. Never put private keys, certificates, or generated tokens in this documentation.
If the scripts lack execute permission, verify the script source and follow the approved procedure to make them executable before running them.
6. Verify and clean up
Before handing off the VM, confirm:
- The VM has the approved IP address and hostname.
- The VM is reachable over SSH using the refreshed certificate.
- The Portainer environment is connected and in the correct group.
- The developer’s test domain responds through Nginx Proxy Manager and Caddy.
- Datto EDR enrollment has been confirmed by the ITS Security Team.
Then remove the example/test container. After confirming the setup and certificate work, remove the temporary setup scripts from the directory in which they were unpacked:
pwd
rm -r -- its-devops-dev-user-setup
Check that pwd shows the expected parent directory before running the removal
command. The template includes a Docker cleanup timer; check its status with:
systemctl status docker-cleanup.timer
Ongoing maintenance: memory safeguards
A developer VM froze with suspected runaway memory usage. The following safeguards close lingering VS Code remote sessions weekly and enable proactive memory-pressure handling. They do not establish the cause of the freeze or replace investigation of recurring memory growth.
Close VS Code remote sessions Sunday at midnight
Run this setup as the developer account that owns the VS Code remote server,
not as root. Save work before the scheduled shutdown: it disconnects remote
sessions and stops processes whose executable lives under that account’s
~/.vscode-server/, including matching language servers and extension hosts.
It does not target every process launched from a VS Code terminal or other
VS Code server installation paths. Reconnecting starts the remote server again.
mkdir -p ~/bin
cat > ~/bin/restart-vscode-server.sh <<'EOF'
#!/bin/sh
dir="$HOME/.vscode-server/"
list() {
for p in $(pgrep -u "$(id -u)"); do
e=$(readlink "/proc/$p/exe" 2>/dev/null) || continue
case "$e" in "$dir"*) echo "$p" ;; esac
done
}
pids=$(list)
[ -z "$pids" ] && exit 0
kill -TERM $pids 2>/dev/null
sleep 30
pids=$(list)
[ -n "$pids" ] && kill -KILL $pids 2>/dev/null
logger -t vscode-restart "VS Code server stopped by weekly cron"
EOF
chmod +x ~/bin/restart-vscode-server.sh
( crontab -l 2>/dev/null; echo '0 0 * * 0 $HOME/bin/restart-vscode-server.sh' ) | crontab -
crontab -l
0 0 * * 0 runs at 00:00 on Sunday in the cron daemon’s configured timezone,
normally the VM’s local timezone. Check it with timedatectl. The original
entry, 0 3 * * 0, runs at 03:00 Sunday, not midnight.
The installation command appends an entry, so run it only once. Use
crontab -e to replace an existing 03:00 entry or remove duplicates.
The script sends SIGTERM, allows 30 seconds to exit, then sends SIGKILL
to any matching processes that remain. To verify the next scheduled shutdown:
crontab -l
journalctl -t vscode-restart --since '7 days ago'
No log entry is written when no matching processes are running. A manual test
also disconnects VS Code; run ~/bin/restart-vscode-server.sh from a separate
SSH session or the VM console after saving work. To disable the schedule,
remove its entry with crontab -e.
Enable proactive out-of-memory handling
On an Ubuntu/Debian VM using systemd, run the following script in Bash from
a separate SSH session or the VM console. It requires sudo access, cgroup v2,
and kernel Pressure Stall Information (PSI). Review existing slice drop-ins
before running it: these commands overwrite the two named 10-oomd.conf files.
systemd-oomd selects eligible descendant cgroups and kills their processes;
it is not a per-process memory limit or a guarantee against freezes. A selected
user-session cgroup can include VS Code and other developer processes, so
unsaved work may be lost. The memory-pressure rule applies under user.slice;
the root-slice swap rule can affect eligible cgroups elsewhere on the VM.
Coordinate this host-wide change with the infrastructure team.
#!/bin/bash
set -euo pipefail
[ "$(stat -fc %T /sys/fs/cgroup)" = cgroup2fs ] || { echo "Needs cgroup v2"; exit 1; }
[ -r /proc/pressure/memory ] || { echo "Kernel memory-pressure tracking (PSI) not available"; exit 1; }
if ! swapon --show | grep -q .; then echo "Warning: no swap configured, so the swap rule will never fire"; fi
sudo apt-get update
sudo apt-get install -y systemd-oomd
sudo mkdir -p /etc/systemd/system/-.slice.d /etc/systemd/system/user.slice.d
printf '[Slice]\nManagedOOMSwap=kill\n' | sudo tee /etc/systemd/system/-.slice.d/10-oomd.conf
printf '[Slice]\nManagedOOMMemoryPressure=kill\nManagedOOMMemoryPressureLimit=50%%\n' | sudo tee /etc/systemd/system/user.slice.d/10-oomd.conf
sudo systemctl daemon-reload
sudo systemctl reload dbus
sudo systemctl enable systemd-oomd
sudo systemctl restart systemd-oomd
sudo oomctl
The 50% setting is a sustained PSI memory-pressure threshold, not 50% of RAM usage. The pressure duration and swap threshold use the installed systemd defaults unless configured separately. Without swap, the swap rule cannot fire, although the memory-pressure rule remains available.
Verify the service, effective configuration, and monitored cgroups:
systemctl status systemd-oomd --no-pager
systemctl cat -- -.slice user.slice
sudo oomctl
sudo journalctl -u systemd-oomd --since '7 days ago' --no-pager
Confirm that oomctl lists the intended monitored slices. If the VM freezes
again or oomd repeatedly kills sessions, review its journal and investigate
memory consumers before changing thresholds. Keep VM-console access available
in case a user session is terminated.
To undo these slice settings, restore any previous versions of the two
drop-ins, or remove them if this procedure created them, then run
sudo systemctl daemon-reload. Disable systemd-oomd only after confirming
that no other VM policy relies on it.
Troubleshooting
If SSH is unavailable, the firewall (ufw) may have blocked the connection.
Use the vSphere console to investigate, and coordinate with the infrastructure
team to restore access through the approved firewall procedure. Do not disable
the firewall or clear rules without confirming the impact.