> For the complete documentation index, see [llms.txt](https://ztrust.gitbook.io/livestreamiq/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ztrust.gitbook.io/livestreamiq/readme/2.-installation/2.4-orchestration-installation.md).

# 2.4 Orchestration Installation

The setup of Orchestration Installation includes:

* Application deployment
* Database deployment
* Persistent storage
* Internal service networking
* External exposure (Ingress / Route)

### 1.  Pre-Requisite

A functional Kubernetes or OpenShift cluster with at least one node must be available.

Additionally, the following must be ensured:

1. kubectl (for Kubernetes) or oc CLI (for OpenShift) installed
2. A default StorageClass configured for Persistent Volumes
3. Container image available:<br>

   ```
   docker/livestreamiq/livestreqmiq:latest
   ```
4. Cluster has network access to pull images from any registry
5. Basic understanding of YAML manifests and Kubernetes objects

### 2.  Installation steps for Kubernetes

Step 1: Create Persistent Volume Claim (Database Storage)

1. Apply the PVC for PostgreSQL storage:<br>

   ```yaml
   apiVersion: v1
   kind: PersistentVolumeClaim
   metadata:
     name: postgres-pvc
   spec:
     accessModes:
       - ReadWriteOnce
     resources:
       requests:
         storage: 100Gi
   ```

Step 2: Deploy PostgreSQL (TimescaleDB)

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - name: postgres
          image: timescale/timescaledb:latest-pg16
          ports:
            - containerPort: 5432
          env:
            - name: POSTGRES_USER
              value: postgres
            - name: POSTGRES_PASSWORD
              value: StrongPassword123
            - name: POSTGRES_DB
              value: lvs
          command: ["postgres", "-c", "shared_preload_libraries=timescaledb"]
          volumeMounts:
            - name: pgdata
              mountPath: /var/lib/postgresql/data
      volumes:
        - name: pgdata
          persistentVolumeClaim:
            claimName: postgres-pvc
```

Step 3: Create PostgreSQL Service

```yaml
apiVersion: v1
kind: Service
metadata:
  name: postgres
spec:
  selector:
    app: postgres
  ports:
    - port: 5432
      targetPort: 5432
  type: ClusterIP
```

Step 4: Deploy LivestreamIQ Application

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: livestreamiq
spec:
  replicas: 2
  selector:
    matchLabels:
      app: livestreamiq
  template:
    metadata:
      labels:
        app: livestreamiq
    spec:
      containers:
        - name: livestreamiq
          image: docker/livestreamiq/livestreqmiq:latest
          ports:
            - containerPort: 8080
          env:
            - name: LVS_DB_URL
              value: "r2dbc:postgresql://postgres:5432/lvs"
            - name: LVS_DB_USERNAME
              value: postgres
            - name: LVS_DB_PASSWORD
              value: StrongPassword123
            - name: ALLOW_ORIGIN
              value: "*"
```

Step 5: Create Application Service

```yaml
apiVersion: v1
kind: Service
metadata:
  name: livestreamiq
spec:
  selector:
    app: livestreamiq
  ports:
    - port: 80
      targetPort: 8080
  type: ClusterIP
```

Step 6: Expose Application

**Kubernetes (Ingress)**

```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: livestreamiq-ingress
spec:
  rules:
    - host: livestreamiq.local
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: livestreamiq
                port:
                  number: 80
```

### 3. Installation steps Openshift

1. **Prerequisites**
   1. OpenShift Cluster
   2. Project created\
      Example-  *Project Name :* `lvs`
2. The Timescale DB  installation steps are  provided below:\
   Step -1: Create Secret

   1. Navigate\
      **Workloads      &#x20; →      &#x20; Secrets      &#x20;→      &#x20;Create Secret**
   2. Name: `postgresql`
   3. Add:<br>

      | Key                | Value      |
      | ------------------ | ---------- |
      | POSTGRES\_USER     | postgres   |
      | POSTGRES\_PASSWORD | admin\@123 |
      | POSTGRES\_DB       | lvs        |
   4. Then, Click **Create.**  &#x20;

   \
   Step-2: Create ConfigMap

   1. Navigate:\
      **Workloads      &#x20;→      &#x20;ConfigMaps      &#x20;→      &#x20;Create ConfigMap**
   2. Name: **`postgres-config`**
   3. Data: `PGDATA=/var/lib/postgresql/data/pgdata`
   4. Then, Click **`Create`**

   Step-3: Create TimescaleDB Deployment

   1. Navigate\
      \*\*Workloads      &#x20; →

      &#x20; Deployments  →

      &#x20; Create Deployment\*\*<br>

      ![](/files/dG2DS6LsaWkvPzIghtQz)
   2. fill the General fields

      1. Name: `postgresql`
      2. Strategy: `Rolling Update`
      3. Leave defaults

      ```
      Max Unavailable
      25%
      Max Surge
      25%
      ```
   3. fill the Image fields\
      Use: `timescale/timescaledb:latest-pg16`
   4. fill the Environment Variables\
      Add the following:<br>

      ```
      Port
      Add Container Port
      5432
      Protocol
      TCP
      ```

      1. Volume: Create Persistent Volume Claim

      2. Mount Path: `/var/lib/postgresql/data`

      3. PVC Name: `timescaledb-pvc`

      4. Size: `100Gi`<br>

         ![](/files/EJ54lo7wSDppQkg2KzGa)

         ![](/files/sDBZRo51t3IQvHkFuGan)

      5. Then, Click **Create.**

   \
   Step 4 - Expose TimescaleDB Service

   1. Navigate:\
      **Networking  →&#x20;      &#x20;Service  →  Create Service**
   2. Past the yml code in the code editor.<br>

      1. ```yaml
         apiVersion: v1
         kind: Service
         metadata:
           name: postgresql-service
           namespace: bidyut-nayak-dev
         spec:
           selector:
             app: postgresql
           ports:
             - protocol: TCP
               port: 5432
               targetPort: 5432

           type: ClusterIP
         ```

      &#x20;  &#x20;
   3. &#x20;Then, Click the **Create** button<br>

      ![](/files/oXhbGV9OZfMaaB8MO609)

### 4. Deploy LiveStreamIQ Application

The Deploy LVS Application installation steps are  provided below:

Step 1: Create Database Secret

1. Navigate:\
   **Workloads   &#x20; →   &#x20; Secrets  →   &#x20; Create Secret**
2. Set Name like `lvs-db-secret`\
   Add the following keys:<br>

   | Key               | Value             |
   | ----------------- | ----------------- |
   | LVS\_DB\_USERNAME | postgres          |
   | LVS\_DB\_PASSWORD | StrongPassword123 |
3. Click **Create**.

Step 2: Create ConfigMap

1. Navigate:\
   **Workloads   &#x20; →   &#x20; ConfigMaps   &#x20; →   &#x20; Create ConfigMap**
2. Set Name: example - `lvs-config`
3. Add details:<br>

   | key           | value                               |
   | ------------- | ----------------------------------- |
   | LVS\_DB\_URL  | r2dbc:postgresql://postgres:5432/vs |
   | ALLOW\_ORIGIN | \*                                  |
4. Click **Create**.

Step 3: Create Deployment

1. Navigate:\
   **Workloads   &#x20; →   &#x20; Deployments   &#x20; →  Create Deployment**
2. Fill the General value:

   1. Set Name: Example - `lvs`
   2. Set Deployment Strategy: Example- `Rolling Update`
   3. Set Image: Example - `docker.io/your-org/lvs:latest`

   It’s private image create pullimage secret and implement it

Step 4: Go to advance use the pulling image secrete

1. Replace with your actual image.
   1. Container Port
      1. Add: `8080`
   2. Protocol: `TCP`
2. Set Environment Variables:

   1. Configure the following environment variables.\
      From ConfigMap:<br>

      | Environment variable | Source                                 |
      | -------------------- | -------------------------------------- |
      | LVS\_DB\_URL         | ConfigMap → lvs-config → LVS\_DB\_URL  |
      | ALLOW\_ORIGIN        | ConfigMap → lvs-config → ALLOW\_ORIGIN |
   2. For Secret variables: <br>

      | Environment Variable | Source                                     |
      | -------------------- | ------------------------------------------ |
      | LVS\_DB\_USERNAME    | Secret → lvs-db-secret → LVS\_DB\_USERNAME |
      | LVS\_DB\_PASSWORD    | Secret → lvs-db-secret → LVS\_DB\_PASSWORD |

      ![](/files/kn8qRJLf1sKfksukBcQG)

Step 5: Expose the Service

1. Go to the **Networking -> service -> Create service**

2. Copy the yml file in the code editor<br>

   ```yaml
   apiVersion: v1
   kind: Service
   metadata:
     name: lvs-service
     namespace: bidyut-nayak-dev
   spec:
     selector:
       app: lvs
     ports:
       - protocol: TCP
         port: 80
         targetPort: 8080

     type: ClusterIP
   ```

   <br>

   ![](/files/GA4ID7qd0yEdIwz8T01Q)

3. Click the create button

Step 6: Set&#x20;

1. Create a Route\
   **Networking   &#x20; →   &#x20; Routes   &#x20; →   &#x20; create Route**\
   \
   Ensure Form view is selected.
2. Configure the RouteLeave the remaining fields with their default values.<br>

   | Field value     | Name                            |
   | --------------- | ------------------------------- |
   | Name            | lvs                             |
   | Service         | Select lvs-service              |
   | Target Port     | Select 8080                     |
   | Secure Route    | Check the Secure Route Checkbox |
   | TLS Termination | Select Edge                     |
3. If the User have DNS, then config in hostname&#x20;
4. Click Create.

### 5. Open the Application

&#x20;After the route is created:

1. Navigate to Networking → Routes.
2. Click the newly created lvs route.
3. The route details page displays the Location (URL).
4. Click the URL to open the LVS application in your browser.\
   Example: [https://lvs.apps.cluster.example.com](https://lvs.apps.cluster.example.com/)<br>

   ![](/files/TeEEJk8Mj1B5FQbyJ8J3)

   ![](/files/N5HfErSRTO6mTzGGnfUk)

   ![](/files/TxCIlss7Y6qYbU9Y9t6h)

### 6. Set Configuration:

1. Database Configuration&#x20;
   1. Database used: PostgreSQL with TimescaleDB extension
   2. Default database name: lvs
   3. Connection handled using internal Kubernetes DNS: `postgres:5432`
2. Application Configuration
   1. Environment variables:<br>

      | Variable          | Description                  |
      | ----------------- | ---------------------------- |
      | LVS\_DB\_URL      | JDBC/R2DBC connection string |
      | LVS\_DB\_USERNAME | Database username            |
      | LVS\_DB\_PASSWORD | Database password            |
      | ALLOW\_ORIGIN     | CORS configuration           |
3. Networking
   1. PostgreSQL is internal only (ClusterIP)
   2. LivestreamIQ is exposed via:
   3. Ingress (Kubernetes)
   4. Route (OpenShift)

### 7.  Best practice

1. Security
   1. Do NOT expose PostgreSQL externally
   2. Move credentials to Kubernetes Secrets
   3. Restrict ALLOW\_ORIGIN instead of using "\*" in production
2. Reliability
   1. Use at least 2 replicas for LivestreamIQ
   2. Enable readiness and liveness probes
   3. Use persistent storage for PostgreSQL
3. Scalability
   1. Enable Horizontal Pod Autoscaler (HPA) for LivestreamIQ
   2. Separate database storage using high-performance PVC
   3. Consider read replicas for PostgreSQL if load increases
