Google Cloud Provider (GCP) PostgreSQL Database

Admins may wish to use a Managed Database Service such as Google Cloud Provider (GCP) PostgreSQL Database seperate from their Kasm installation.

This guide provides instructions on how to initialize the database server from a remote machine and then install the Kasm WebApp.

Requirements

  • Google Cloud Provider (GCP) PostgreSQL server running PostgreSQL version 12.

  • Google Cloud Provider (GCP) PostgreSQL either already has a User “kasmapp” in the database “kasm” OR you have SuperUser credentials on the database.

  • Remote Redis server supports Redis version 5.

  • Machine executing initialization and the Web App server can connect to the Google Cloud Provider (GCP) PostgreSQL Database (default port TCP/5432)

  • Web App servers can connect to Redis Server (default port TCP/6379)

Sizing

Requirement

CPUs

RAM

Minimum Requirements

2

4 GB

Suggested Requirements

2

16 GB

When performing a fresh installation

Initializing PostgreSQL Database

  • This can be done from anywhere, but since the script will install docker and other Kasm prerequisites it may be easiest to run the remote DB install from the future Kasm Web App server.

  • Download latest version of Kasm Workspaces to /tmp

  • Extract package and initialize the Database.

cd /tmp

curl -O https://kasm-static-content.s3.amazonaws.com/kasm_release_1.16.0.a1d5b7.tar.gz

tar -xf kasm_release*.tar.gz

sudo bash kasm_release/install.sh \
--accept-eula \
--role init_remote_db \
--db-hostname [DATABASE_HOSTNAME] \
--db-password [DATABASE_KASMAPP_USER_PASSWORD] \
--database-user [DATABASE_USERNAME] \
--database-name [DATABASE_NAME] \
--db-master-user [DATABASE_SUPERUSER_USERNAME] \
--db-master-password [DATABASE_SUPERUSER_PASSWORD]

Note

If the Database already has the User “kasmapp” and database “kasm” created you may omit the -g and -G parameters. The DATABASE_USERNAME and DATABASE_NAME are optional and only required if not using the default kasm/kasmapp settings.

Backing up the Google Cloud Provider (GCP) PostgreSQL Server

  • This script should be run from a Kasm Web App server.

If you are backing up a standalone remote database for Kasm Workspaces 1.11.0 or newer then use the existing db_backup script:

sudo bash /opt/kasm/bin/utils/db_backup -v --backup-file [DESIRED_BACKUP_FILE_LOCATION] -q [DATABASE_HOSTNAME] --path [PATH_TO_KASM_INSTALL]
  • The backup will be present at the location specified with –backup-file

Restoring the Google Cloud Provider (GCP) PostgreSQL server from a backup

  • This script should be ran from a Kasm Web App server or during a Kasm Workspaces upgrade from the server that ran the database clean install step.

  • You will need SuperUser credentials on the database.

  • Make sure that All Kasm Web App and Agent servers have their services stopped.

sudo bash /opt/kasm/1.16.0/bin/utils/db_restore \
--backup-file [LOCATION_OF_BACKUP_FILE] \
--database-hostname [DATABASE_HOSTNAME] \
--database-user [DATABASE_USERNAME] \
--database-name [DATABASE_NAME] \
--path /opt/kasm/1.16.0 \
--database-master-user [DATABASE_MASTER_USER] \
--database-master-password [DATABASE_MASTER_USER_PASSWORD]
  • After the restore is complete restart all Kasm Web App and Agent services.

When performing an upgrade

Important

Before performing an upgrade ensure all Kasm Workspaces Containers/Sessions are stopped on all hosts in your deployment. sudo /opt/kasm/bin/stop Also ensure the “Automatically Enable Agents” is enabled under settings in the Admin Dashboard. These instructions are for upgrading from Kasm Workspaces >= 1.11.0 to 1.16.0.

Database migration

Note

The database migration commands should be run once from the Kasm Web App with access to the remote database. Any additional Kasm Web App server does not need to execute database migrations again.

  • Stop all services:

sudo /opt/kasm/bin/stop
  • Grab and extract the installer for 1.16.0:

cd /tmp

curl -O https://kasm-static-content.s3.amazonaws.com/kasm_release_1.16.0.a1d5b7.tar.gz

tar -xf kasm_release*.tar.gz
  • Generate a database backup:

sudo mkdir -p /opt/kasm/backups/

sudo bash kasm_release/bin/utils/db_backup \
--backup-file /opt/kasm/backups/1.15.0_backup.tar \
--database-hostname [DATABASE_HOSTNAME] \
--database-user [DATABASE_USERNAME] \
--database-name [DATABASE_NAME] \
--path /opt/kasm/current
  • Log into your PostgreSQL server as the master user and remove the database/user:

drop database if exists kasm;
drop user if exists kasmapp;
  • Init the empty DB, restore our backup, and upgrade the database:

sudo bash kasm_release/install.sh \
--accept-eula \
--role init_remote_db \
--db-hostname [DATABASE_HOSTNAME] \
--db-password [DATABASE_KASMAPP_USER_PASSWORD] \
--database-user [DATABASE_USERNAME] \
--database-name [DATABASE_NAME] \
--db-master-user [DATABASE_MASTER_USER] \
--db-master-password [DATABASE_MASTER_USER_PASSWORD]

sudo bash /opt/kasm/1.16.0/bin/utils/db_restore \
--backup-file /opt/kasm/backups/1.15.0_backup.tar \
--database-hostname [DATABASE_HOSTNAME] \
--path /opt/kasm/1.16.0 \
--database-master-user [DATABASE_MASTER_USER] \
--database-user [DATABASE_USERNAME] \
--database-name [DATABASE_NAME] \
--database-master-password [DATABASE_MASTER_USER_PASSWORD]

sudo bash /opt/kasm/1.16.0/bin/utils/db_upgrade \
--database-hostname [DATABASE_HOSTNAME] \
--path /opt/kasm/1.16.0
  • Seed the new images for this installation:

sudo /opt/kasm/1.16.0/bin/utils/db_init \
--database-hostname [DATABASE_HOSTNAME] \
--seed-file /opt/kasm/1.16.0/conf/database/seed_data/default_images_amd64.yaml