Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #50 from kibernetika-ai/heatmap_audience
Browse files Browse the repository at this point in the history
Add realtime heatmap and audience applications
  • Loading branch information
amr-mokhtar authored Apr 8, 2021
2 parents 92a8a47 + 6a8ec01 commit 2d6fd35
Show file tree
Hide file tree
Showing 22 changed files with 1,051 additions and 0 deletions.
83 changes: 83 additions & 0 deletions applications/audience-analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
```text
SPDX-License-Identifier: Apache-2.0
Copyright (c) 2021 Kibernetika, Inc. All rights reserved.
```

# Audience analytics

- [Audience analytics](#audience-analytics)
- [Application Description](#application-description)
- [Repository content](#repository-content)
- [Docker Images](#docker-images)
- [Pre Requisites](#pre-requisites)
- [Installation](#installation)
- [Install the Audience analytics](#install-the-audience-analytics)
- [Producer Application](#producer-application)
- [Check application logs to see if it is running](#check-application-logs-to-see-if-it-is-running)

## Application Description

The Application is a Audience analytics registered in OpenNESS as a consumer application. It uses
a web UI for visualizing heatmap pictures, aggregated heatmap pictures, heatmap video and person statistics from the timeline.
It receives the data and pictures from the producer application "Realtime Heatmap".

## Repository content

The repository contains:

- Helm package for the installation

## Docker Images

Docker images are located at dockerhub:

- kuberlab/audience:latest
- kuberlab/audience-ui:latest

Pre Requisites
---
The application has been tested on the following software, which is also required:

* [OpenNESS](https://github.com/open-ness/specs) Network Edge v20.12.02
* Kubernetes v1.18.4
* Helm v3.1.2
* Installed [nginx-ingress](https://kubernetes.github.io/ingress-nginx/deploy/#using-helm) controller in cluster with nodePort
* Available at least one storage class for storage

## Installation

### Install the Audience analytics

The installation proccess leverage on helm chart. Go to the `helm` folder of the repository, and edit values.yaml:

Notice environment variables:

Notice chart variables:

- api.dns: Domain name for nginx controller
- api.db.password: specify password for the database
- api.authKey: specify random auth key for root API user
- Uncomment persistence.*.storageClass variables and specify an appropriate storageClass used in your cluster

Run the installation:

```bash
helm install realtime-heatmap ./
```

If the installation succeeds, you can check the logs. If everything is ok and DNS is pointed to edge node IP,
then check `<some-node-ip>:<nginx-node-port>` for accessing audience UI using login/password: `admin/<your-auth-key>`

### Producer Application

The Producer application here is the "Realtime Heatmap" application which produces frames, heatmap labeling and
resulting video chunks and sends them to audience service.

### Check application logs to see if it is running

In order to check application logs, you can see directly the pod logs at:

```bash
pod_name=$(kubectl get po -l component=audience-api --no-headers | awk '{print $1}')
kubectl logs -f $pod_name
```
14 changes: 14 additions & 0 deletions applications/audience-analytics/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2021 Kibernetika, Inc. All rights reserved.
Description: Audience exploring system
Engine: gotpl
Home: https://kibernetika.ai
Keywords:
- Artificial Intelligence
- Audience
- Kibernetika
Maintainers:
- Email: [email protected]
Name: Nikolay Mahotkin
Name: audience
Version: 1.0.0
176 changes: 176 additions & 0 deletions applications/audience-analytics/helm/templates/api-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2021 Kibernetika, Inc. All rights reserved.
apiVersion: apps/v1
kind: Deployment
metadata:
name: audience-api
spec:
selector:
matchLabels:
app: audience
component: audience-api
template:
metadata:
labels:
app: audience
component: audience-api
spec:
{{- if .Values.openness.enabled }}
serviceAccountName: heatmap-consumer
initContainers:
- name: certrequester
image: certrequester:1.0
args: [ "--cfg", "/home/certrequester/config/certrequest.json" ]
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: "0.1"
limits:
cpu: "0.1"
memory: "128Mi"
volumeMounts:
- name: config
mountPath: /home/certrequester/config/
- name: certs
mountPath: /home/certrequester/certs/
- name: alpine
image: alpine:3.12.0
command: [ "/bin/sh" ]
args: [ "-c", "cp /root/ca-certrequester/cert.pem /root/certs/root.pem" ]
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: "0.1"
limits:
cpu: "0.1"
memory: "128Mi"
volumeMounts:
- name: ca-certrequester
mountPath: /root/ca-certrequester
- name: certs
mountPath: /root/certs
{{- end }}
containers:
- name: audience-api
image: "{{ printf "%s:%s" .Values.api.Image.Name .Values.api.Image.Tag}}"
readinessProbe:
httpGet:
path: /probe
port: 8088
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 3
successThreshold: 1
failureThreshold: 3
env:
- name: PG_HOST
value: audience-db
- name: PG_USER
value: {{ .Values.api.db.user }}
- name: PG_PWD
value: {{ .Values.api.db.password }}
- name: BASE_URL
value: {{ .Values.api.baseUrl }}
{{- if .Values.openness.enabled }}
- name: OPENNESS_ENABLED
value: "true"
{{- end }}
{{- if .Values.api.authKey }}
- name: AUTH_KEY
value: {{ .Values.api.authKey }}
{{- end }}
{{- if .Values.api.authAllowPublic }}
- name: AUTH_ALLOW_PUBLIC
value: "{{ .Values.api.authAllowPublic }}"
{{- end }}
{{- if .Values.api.dealer.enabled }}
- name: DEALER_ENABLED
value: "{{ .Values.api.dealer.enabled }}"
{{- end }}
{{- if .Values.api.dealer.host }}
- name: DEALER_HOST
value: {{ .Values.api.dealer.host }}
{{- end }}
{{- if .Values.api.dealer.apiPath }}
- name: DEALER_API_PATH
value: {{ .Values.api.dealer.apiPath }}
{{- end }}
{{- if .Values.api.dealer.disableHttps }}
- name: DEALER_DISABLE_HTTPS
value: {{ .Values.api.dealer.disableHttps }}
{{- end }}
{{- if .Values.api.dealer.inferenceWorkspace }}
- name: INFERENCE_WORKSPACE
value: {{ .Values.api.dealer.inferenceWorkspace }}
{{- end }}
{{- if .Values.api.dealer.inferenceName }}
- name: INFERENCE_NAME
value: {{ .Values.api.dealer.inferenceName }}
{{- end }}
{{- if .Values.api.dealer.inferenceVersion }}
- name: INFERENCE_VERSION
value: {{ .Values.api.dealer.inferenceVersion }}
{{- end }}
{{- if .Values.api.dealer.servingWorkspace }}
- name: SERVING_WORKSPACE
value: {{ .Values.api.dealer.servingWorkspace }}
{{- end }}
{{- if .Values.api.dealer.servingName }}
- name: SERVING_NAME
value: {{ .Values.api.dealer.servingName }}
{{- end }}
{{- if .Values.api.dealer.servingToken }}
- name: SERVING_TOKEN
value: {{ .Values.api.dealer.servingToken }}
{{- end }}
{{- if .Values.api.dealer.storageEndpoint }}
- name: STORAGE_ENDPOINT
value: {{ .Values.api.dealer.storageEndpoint }}
{{- end }}
{{- if .Values.api.dealer.storageId }}
- name: STORAGE_ID
value: {{ .Values.api.dealer.storageId }}
{{- end }}
{{- if .Values.api.dealer.storageSecret }}
- name: STORAGE_SECRET
value: {{ .Values.api.dealer.storageSecret }}
{{- end }}
{{- if .Values.api.dealer.storageRegion }}
- name: STORAGE_REGION
value: {{ .Values.api.dealer.storageRegion }}
{{- end }}
{{- if .Values.api.dealer.storageBucket }}
- name: STORAGE_BUCKET
value: {{ .Values.api.dealer.storageBucket }}
{{- end }}
ports:
- containerPort: 8088
name: http
volumeMounts:
- name: images
mountPath: /images
subPath: audience-images
- name: api-upload
mountPath: /upload
subPath: audience-api-upload
{{- if .Values.openness.enabled }}
- name: certs
mountPath: /root/certs/
{{- end }}
volumes:
- name: images
persistentVolumeClaim:
claimName: audience-images
- name: api-upload
persistentVolumeClaim:
claimName: audience-api-upload
{{- if .Values.openness.enabled }}
- name: certs
emptyDir: {}
- name: ca-certrequester
secret:
secretName: ca-certrequester
- name: config
configMap:
name: heatmap-consumer-csr-config
{{- end }}
15 changes: 15 additions & 0 deletions applications/audience-analytics/helm/templates/api-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2021 Kibernetika, Inc. All rights reserved.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: audience-api-upload
spec:
{{- if .Values.persistence.apiUpload.storageClass }}
storageClassName: {{ .Values.persistence.apiUpload.storageClass | quote }}
{{- end }}
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: {{ .Values.persistence.apiUpload.size }}
24 changes: 24 additions & 0 deletions applications/audience-analytics/helm/templates/api-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2021 Kibernetika, Inc. All rights reserved.
apiVersion: v1
kind: Service
metadata:
labels:
app: audience
component: audience-api
name: audience-api
spec:
type: {{ .Values.api.service.type }}
ports:
- name: http
port: 80
{{- if eq .Values.api.service.type "NodePort" }}
{{- if .Values.api.service.nodePort }}
nodePort: {{ .api.service.nodePort }}
{{- end }}
{{- end }}
protocol: TCP
targetPort: 8088
selector:
app: audience
component: audience-api
38 changes: 38 additions & 0 deletions applications/audience-analytics/helm/templates/db-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2021 Kibernetika, Inc. All rights reserved.
apiVersion: apps/v1
kind: Deployment
metadata:
name: audience-db
spec:
selector:
matchLabels:
app: audience
component: audience-db
template:
metadata:
labels:
app: audience
component: audience-db
spec:
containers:
- name: audience-db
image: postgres:9.6.2
env:
- name: POSTGRES_USER
value: {{ .Values.api.db.user }}
- name: POSTGRES_PASSWORD
value: {{ .Values.api.db.password }}
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
ports:
- containerPort: 5432
name: psql
volumeMounts:
- name: db
mountPath: /var/lib/postgresql/data/pgdata
subPath: audience-db
volumes:
- name: db
persistentVolumeClaim:
claimName: audience-db
15 changes: 15 additions & 0 deletions applications/audience-analytics/helm/templates/db-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2021 Kibernetika, Inc. All rights reserved.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: audience-db
spec:
{{- if .Values.persistence.db.storageClass }}
storageClassName: {{ .Values.persistence.db.storageClass | quote }}
{{- end }}
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: {{ .Values.persistence.db.size }}
18 changes: 18 additions & 0 deletions applications/audience-analytics/helm/templates/db-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2021 Kibernetika, Inc. All rights reserved.
apiVersion: v1
kind: Service
metadata:
labels:
app: audience
component: audience-db
name: audience-db
spec:
ports:
- name: psql
port: 5432
protocol: TCP
targetPort: 5432
selector:
app: audience
component: audience-db
Loading

0 comments on commit 2d6fd35

Please sign in to comment.