AMS with PostgreSQL in Kubernetes Quick-Start Guide

AMS with PostgreSQL in Kubernetes Quick-Start Guide

book

Article ID: KB0071186

calendar_today

Updated On:

Products Versions
TIBCO Streaming 10.6 and later

Description

In some cases, it may be desirable to deploy both your AMS server and its PostgreSQL database (which is used to persist AMS user/role/artifact details) in the same Kubernetes cluster. This can often be useful during initial testing of your AMS configuration, where you may need to repeatedly drop and re-create the PostgreSQL database between tests. Follow the steps below to configure your AMS server application to interact with your PostgreSQL database server in a Kubernetes environment.

Resolution

1. Use the Bitnami Helm charts to deploy a new postgres database. From a command prompt, run:
 
helm install ams-db bitnami/postgresql --set auth.postgresPassword="P@ssw0rd!" --set auth.database="ams"

This will deploy a new postgres server, where the 'postgres' admin user's password is 'P@ssw0rd!'. It will also create a new database named 'ams'.

2. Edit the Database section in AMS.conf under $STREAMBASE_HOME/ams/docker-image/src/main/resources/conf/AMS.conf:
 
Database {
        databaseType = "${ams.Database.databaseType:-POSTGRES}"
        hostPort = "${ams.Database.hostPort:-ams-db-postgresql:5432}"
        databaseName = "${ams.Database.databaseName:-ams}"
        userName = "${ams.Database.userName:-postgres}"
        password = "${ams.Database.password:-P@ssw0rd!}"
    }

3. Build your AMS docker image by running..
 
mvn clean install

..from $STREAMBASE_HOME/ams/docker-image/.

4. Load your image to your Kubernetes container registry. Your Kubernetes administrator may need to assist with this step. 

5. Deploy your AMS server:
 
kubectl apply -f - <<!
apiVersion: apps/v1
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: service-update
rules:
- apiGroups: [""]
  resources: ["services", "pods"]
  verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
---
apiVersion: apps/v1
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: service-update
subjects:
- kind: User
  name: system:serviceaccount:default:default
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: ClusterRole
  name: service-update
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ams-app-deployment
  labels:
    app: ams
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ams
  template:
    metadata:
      labels:
        app: ams
    spec: 
      containers:
      - name: ams-app
        image: tibco/ams:1.6.4
        ports:
        - containerPort: 2185
---
apiVersion: apps/v1
kind: Service
apiVersion: v1
metadata:
  name: ams-service
spec:
  selector:
    app: ams
  ports:
    - port: 5000 # Default port for image
      targetPort: 2185
!

Here, we are deploying a single AMS v1.6.4 node on Kubernetes port 2185. We have also configured a Cluster Role and Cluster Role Binding to allow the Artifact Discovery Service (ADS) to work properly, and discover other StreamBase application nodes in the cluster as needed.

6. Forward an available local port (e.g. 2185) to the AMS Kubernetes service port (5000) so that additional client machines may connect to this AMS server:
 
kubectl port-forward --address 0.0.0.0 --namespace default service/ams-service 2185:5000


You may now connect to your AMS service on port 2185. 

To shut down and remove the database, simply uninstall it with helm between tests:
 

helm uninstall ams-db

Issue/Introduction

This article outlines the steps needed to quickly spin up a new PostgreSQL database server to be used for an Artifact Management Server (AMS) application. This guidance is meant to address the use-case where the AMS server and the PostgreSQL database server both need to run in the same Kubernetes cluster.