Git Product home page Git Product logo

multi-tenancy's Introduction

Multi-tenancy Assets for IBM Clients to build SaaS

This repo contains multi-tenancy assets for IBM clients and partners to build SaaS (Software as a Service).

Project Structure

Introduction

A key benefit of the cloud is the ability to deploy software for multiple consumers without having to install it redundantly on-premises. When software is provided as a managed service (SaaS), costs can be reduced for the deployments and the operations of applications. Additionally SaaS can be scaled and new consumers can be added easily.

In order to leverage these advantages, applications need to be designed, so that they can support multiple tenants. Often tenants are not single users, but clients of SaaS providers with their own corporate authentication mechanisms. When running SaaS for multiple tenants, it's often required to keep the workloads isolated from each other for security reasons. For example, typically separate databases are used for tenants.

At the same time common deployment and operation models are required, so that new SaaS versions can be deployed to different tenants in an unique and efficient way.

This project aims to support IBM partners to build SaaS for different platforms including Kubernetes, OpenShift, Serverless, Satellite, AWS and Azure. The used sample application, which contains two containers, is the same one for all platforms. The CI/CD mechanisms slightly differentiate between the platforms.

Platform Options

The following diagram shows the different platform options. At this point the repo contains the IBM Cloud platforms.

More options are planned to be added. For example with Satellite the SaaS application can be deployed on-premises to client data centers, but managed centrally. Additionally the same SaaS application can be deployed on other managed OpenShift services like AWS ROSA and Azure ARO.

Serverless on IBM Cloud

The easiest way to get started is to use serverless. The repo describes how to use IBM Code Engine to run the application logic, IBM App ID for authentication, IBM Postgres for persistence and IBM Toolchain for CI/CD. Scripts are provided to make the setup as easy as possible.

Managed Kubernetes and OpenShift on IBM Cloud

For more advanced cloud-native applications Kubernetes and OpenShift can be used. Compute isolation can be done either by sharing clusters and using Kubernetes namespaces/OpenShift projects or by having separate clusters for tenants. For authentication the managed services App ID and Postgres can be used, but they can also be replaced by other managed services or services running within the clusters.

For CI/CD the IBM DevSecOps reference architecture based on IBM Toolchain is used which is also the internal IBM standard and which guarantees compliance for regulated industries.

Sample Application

The project comes with a simple e-commerce example application. A SaaS provider might have one client selling books, another one selling shoes.

Documentation

You can access the easier navigable and consumable version of the documentation by pressing this button

Repositories

This repo is the 'parent repo' including documentation and global configuration. The other four repos contain the implementation of the microservices and the serverless pipelines.

Getting Started

The easiest way to get started is to set up the sample application for two tenants on the IBM Cloud using serverless technology. The following diagram describes the serverless architecture of the simple e-commerce application which has two images (backend and frontend).

Isolated Compute:

  • One frontend container per tenant
  • One backend container per tenant
  • One App ID instance per tenant
  • One Postgres instance (with one database) per tenant

Shared CI/CD:

  • One code base for frontend and backend services
  • One image for frontend service
  • One image for backend service
  • One toolchain for all tenants (with four pipelines)

Used IBM Services:

  • IBM Code Engine
  • IBM Container Registry
  • IBM App ID
  • IBM Postgres
  • IBM Toolchain

Used Technologies:

  • Quarkus
  • Vue.js and nginx
  • Bash scripts

Initial Deployment Scripts

Scripts and provided to set up all services and the application automatically. Follow this step by step guide to set up everything using local bash scripts.

Deployments of Updates via CI/CD

Additionally pipelines are provided to re-deploy the backend and frontend services when their implementations have changed. Follow this step by step guide to set up the pipelines.

multi-tenancy's People

Contributors

aairom avatar deleeuwblue avatar karimdeif avatar nheidloff avatar stevemar avatar thomassuedbroecker avatar timroster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multi-tenancy's Issues

Invocations of Scripts

Does is make sense to change how parameters are passed to scripts?

echo "************************************"
echo " Display parameter"
echo "************************************"
echo ""
echo "Parameter count : $@"
echo "Parameter zero 'name of the script': $0"
echo "---------------------------------"
echo "Code Engine project name : $1"
echo "---------------------------------"
echo "App ID service instance name : $2"
echo "App ID service key name : $3"
echo "---------------------------------"
echo "Application Service Catalog name : $4"
echo "Application Frontend name : $5"
echo "Application Service Catalog image: $6"
echo "Application Frontend image : $7"
echo "Application Frontend category : $8"
echo "---------------------------------"
echo ""
# **************** Global variables set by parameters
# Code Engine
export PROJECT_NAME=$1
# App
export YOUR_SERVICE_FOR_APPID=$2
export APPID_SERVICE_KEY_NAME=$3
# ecommerce application names
export SERVICE_CATALOG_NAME=$4
export FRONTEND_NAME=$5
# ecommerce application container registry
export SERVICE_CATALOG_IMAGE=$6
export FRONTEND_IMAGE=$7
export FRONTEND_CATEGORY=$8

Could we have one local file with all env variables rather than passing them in a certain order? And then we do a 'source' at the beginning of the scripts.

That would also help with deleting the right resources later.

And it would help when we break down the 500+ lines scripts in multiple ones.

Remove invocation of orders endpoint

fetch(this.apiUrlOrders)
.then((response) => response.json())
.then((json) => {
this.amountLineItems = 0;
if (json[0]) {
json[0].lineitems.forEach((lineItem) => {
this.amountLineItems = this.amountLineItems + lineItem.quantity;
});
}
})
.catch((error) => {
console.error(error);
});

Remove noise in code and logs

There are a lot of log and debug statements. Would be good to remove some of them. For example

echo ""
echo "**********************************"
echo "Step 5"
echo "**********************************"
echo "Execute java command "
echo "**********************************"
echo ""
java -Xmx128m \
-Xscmaxaot100m \
-XX:+IdleTuningGcOnIdle \
-Xtune:virtualized \
-Xscmx128m \
-Xshareclasses:cacheDir=/opt/shareclasses \
-jar \
/deployments/quarkus-run.jar

And let's remove unused code, e.g.

#java -Xmx128m \
# -Xscmaxaot100m \
# -XX:+IdleTuningGcOnIdle \
# -Xtune:virtualized \
# -Xscmx128m \
# -Xshareclasses:cacheDir=/opt/shareclasses \
# -D_POSTGRES_1=${POSTGRES_1} \
# -D_POSTGRES_2=${POSTGRES_2} \
# -D_CERT_FILE_NAME=${CERT_FILE_NAME} \
# - cp D_CERT_FILE_NAME \
# -jar \
# /deployments/quarkus-run.jar

Show URLs

With all the different endpoints it's easier to get lost and finding the right ones. Can we have something like a 'show-urls.sh' scripts that shows all URLs in one place?

postgresql table loads failing on code engine deployment

When running ce-install-application.sh , there appear to be certification validation errors when establishing the connection to load table data. Messages like the following appear:

Type         Connection String   
PostgreSQL   postgres://admin:$PASSWORD@8b6c161e-d5c5-4380-9652-45c6b6f857d7.c0v4phir0ah9ul9trho0.databases.appdomain.cloud:30911/ibmclouddb?sslmode=verify-full   
CLI          PGPASSWORD=$PASSWORD PGSSLROOTCERT=./286a39f3-e1b8-4381-a83b-08ca9153eae0 psql 'host=8b6c161e-d5c5-4380-9652-45c6b6f857d7.c0v4phir0ah9ul9trho0.databases.appdomain.cloud port=30911 dbname=ibmclouddb user=admin sslmode=verify-full'   
-------------------------
Create table in postgres using (create-populate-tenant-b.sql)
-------------------------

#!/bin/bash

PGPASSWORD=<redacted> PGSSLROOTCERT=286a39f3-e1b8-4381-a83b-08ca9153eae0 psql 'host=8b6c161e-d5c5-4380-9652-45c6b6f857d7.c0v4phir0ah9ul9trho0.databases.appdomain.cloud port=30911 dbname=ibmclouddb user=ibm_cloud_0ef5ca9b_978d_47f6_b48a_939027e2a295 sslmode=verify-full' -a -f create-populate-tenant-b.sql------------------------------
Verify the given entries and press return
------------------------------
psql: error: connection to server at "8b6c161e-d5c5-4380-9652-45c6b6f857d7.c0v4phir0ah9ul9trho0.databases.appdomain.cloud" (163.75.67.118), port 30911 failed: SSL error: certificate verify failed

The problem can be seen from the output - the generated CLI example has a preceding ./ for the PGSSLROOTCERT environment variable, whereas the actual command run does not.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.