Skip to content

Commit

Permalink
Reporting-Init: Helm chart added, docker added. Module-wise Connector…
Browse files Browse the repository at this point in the history
…s: updated

Signed-off-by: Lalith Kota <[email protected]>
  • Loading branch information
lalithkota committed Jun 19, 2024
1 parent 730d51e commit a1852e7
Show file tree
Hide file tree
Showing 54 changed files with 1,263 additions and 918 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{json,yml,yaml,rst,md}]
[*.{yml,yaml,rst,md}]
indent_size = 2
62 changes: 46 additions & 16 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,65 @@ jobs:
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets.docker_hub_organisation || 'openg2p' }}
SERVICE_NAME: reporting-opensearch-kafka-connector
OS_KAFKA_CONNECTOR_SERVICE_NAME: reporting-opensearch-kafka-connector
REPORTING_INIT_SERVICE_NAME: reporting-init-shell-tools
steps:
- uses: actions/checkout@v3
- name: Docker build
- name: Docker build OS Kafka Connector
run: |
BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')
IMAGE_ID=$NAMESPACE/$SERVICE_NAME
OS_KAFKA_CONNECTOR_IMAGE_ID=$NAMESPACE/$OS_KAFKA_CONNECTOR_SERVICE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$BRANCH_NAME
OS_KAFKA_CONNECTOR_IMAGE_ID=$(echo $OS_KAFKA_CONNECTOR_IMAGE_ID | tr '[A-Z]' '[a-z]')
OS_KAFKA_CONNECTOR_VERSION=$BRANCH_NAME
if [[ $BRANCH_NAME == master || $BRANCH_NAME == main ]]; then
VERSION=develop
OS_KAFKA_CONNECTOR_VERSION=develop
fi
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_ENV
echo VERSION=$VERSION >> $GITHUB_ENV
echo OS_KAFKA_CONNECTOR_IMAGE_ID=$OS_KAFKA_CONNECTOR_IMAGE_ID
echo OS_KAFKA_CONNECTOR_VERSION=$OS_KAFKA_CONNECTOR_VERSION
echo OS_KAFKA_CONNECTOR_IMAGE_ID=$OS_KAFKA_CONNECTOR_IMAGE_ID >> $GITHUB_ENV
echo OS_KAFKA_CONNECTOR_VERSION=$OS_KAFKA_CONNECTOR_VERSION >> $GITHUB_ENV
cd opensearch-kafka-connector
docker build . \
--file Dockerfile \
--tag $IMAGE_ID:$VERSION
--tag $OS_KAFKA_CONNECTOR_IMAGE_ID:$OS_KAFKA_CONNECTOR_VERSION
if [[ '${{ secrets.docker_hub_token }}' != '' && '${{ secrets.docker_hub_actor }}' != '' ]]; then
export DOCKER_PUSH="true"
echo DOCKER_PUSH=$DOCKER_PUSH >> $GITHUB_ENV
export OS_KAFKA_CONNECTOR_DOCKER_PUSH="true"
echo OS_KAFKA_CONNECTOR_DOCKER_PUSH=$OS_KAFKA_CONNECTOR_DOCKER_PUSH >> $GITHUB_ENV
fi
- name: Docker push
if: env.DOCKER_PUSH == 'true'
- name: Docker push OS Kafka Connector
if: env.OS_KAFKA_CONNECTOR_DOCKER_PUSH == 'true'
run: |
echo "${{ secrets.docker_hub_token }}" | docker login -u ${{ secrets.docker_hub_actor }} --password-stdin
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}
docker push ${{ env.OS_KAFKA_CONNECTOR_IMAGE_ID }}:${{ env.OS_KAFKA_CONNECTOR_VERSION }}
- name: Docker build Reporting Init
run: |
BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')
REPORTING_INIT_IMAGE_ID=$NAMESPACE/$REPORTING_INIT_SERVICE_NAME
# Change all uppercase to lowercase
REPORTING_INIT_IMAGE_ID=$(echo $REPORTING_INIT_IMAGE_ID | tr '[A-Z]' '[a-z]')
REPORTING_INIT_VERSION=$BRANCH_NAME
if [[ $BRANCH_NAME == master || $BRANCH_NAME == main ]]; then
REPORTING_INIT_VERSION=develop
fi
echo REPORTING_INIT_IMAGE_ID=$REPORTING_INIT_IMAGE_ID
echo REPORTING_INIT_VERSION=$REPORTING_INIT_VERSION
echo REPORTING_INIT_IMAGE_ID=$REPORTING_INIT_IMAGE_ID >> $GITHUB_ENV
echo REPORTING_INIT_VERSION=$REPORTING_INIT_VERSION >> $GITHUB_ENV
cd reporting-init-docker
docker build . \
--file Dockerfile \
--tag $REPORTING_INIT_IMAGE_ID:$REPORTING_INIT_VERSION
if [[ '${{ secrets.docker_hub_token }}' != '' && '${{ secrets.docker_hub_actor }}' != '' ]]; then
export REPORTING_INIT_DOCKER_PUSH="true"
echo REPORTING_INIT_DOCKER_PUSH=$REPORTING_INIT_DOCKER_PUSH >> $GITHUB_ENV
fi
- name: Docker push Reporting Init
if: env.REPORTING_INIT_DOCKER_PUSH == 'true'
run: |
echo "${{ secrets.docker_hub_token }}" | docker login -u ${{ secrets.docker_hub_actor }} --password-stdin
docker push ${{ env.REPORTING_INIT_IMAGE_ID }}:${{ env.REPORTING_INIT_VERSION }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OpenG2P Reporting
This repository contains components for OpenG2P Reporting system. Refer to [OpenG2P Docs](https://docs.openg2p.org/v/1.1) for details of the reporting framework and installation of the same.
This repository contains components for OpenG2P Reporting system. Refer to [OpenG2P Docs](https://docs.openg2p.org) for details of the reporting framework and installation of the same.

# License
This repository is licensed under [MPL-2.0](LICENSE).
Expand Down
6 changes: 3 additions & 3 deletions charts/debezium/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ containerPort: 8083
startupProbe:
enabled: true
httpGet:
path: /connectors
path: /
port: 8083
initialDelaySeconds: 0
periodSeconds: 10
Expand All @@ -80,7 +80,7 @@ startupProbe:
livenessProbe:
enabled: true
httpGet:
path: /connectors
path: /
port: 8083
initialDelaySeconds: 20
periodSeconds: 30
Expand All @@ -91,7 +91,7 @@ livenessProbe:
readinessProbe:
enabled: true
httpGet:
path: /connectors
path: /
port: 8083
initialDelaySeconds: 0
periodSeconds: 10
Expand Down
6 changes: 3 additions & 3 deletions charts/opensearch-kafka-connector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ containerPort: 8083
startupProbe:
enabled: true
httpGet:
path: /connectors
path: /
port: 8083
initialDelaySeconds: 0
periodSeconds: 10
Expand All @@ -80,7 +80,7 @@ startupProbe:
livenessProbe:
enabled: true
httpGet:
path: /connectors
path: /
port: 8083
initialDelaySeconds: 20
periodSeconds: 30
Expand All @@ -91,7 +91,7 @@ livenessProbe:
readinessProbe:
enabled: true
httpGet:
path: /connectors
path: /
port: 8083
initialDelaySeconds: 0
periodSeconds: 10
Expand Down
2 changes: 2 additions & 0 deletions charts/reporting-init/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
charts/
Chart.lock
23 changes: 23 additions & 0 deletions charts/reporting-init/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
12 changes: 12 additions & 0 deletions charts/reporting-init/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v2
name: reporting-init
description: A Helm chart for initializing OpenG2P Reporting connectors.
type: application
version: 0.0.0-develop
dependencies:
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
version: 2.x.x
icon: https://openg2p.github.io/openg2p-helm/openg2p-logo.png
annotations:
catalog.cattle.io/display-name: "OpenG2P Reporting Init"
3 changes: 3 additions & 0 deletions charts/reporting-init/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Reporting Init

Helm chart for installing reporting connectors and initialize other required elements.
Empty file.
1 change: 1 addition & 0 deletions charts/reporting-init/questions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
questions: []
42 changes: 42 additions & 0 deletions charts/reporting-init/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{/*
Render Env values section
*/}}
{{- define "reporting-init.baseEnvVars" -}}
{{- $context := .context -}}
{{- range $k, $v := .envVars }}
- name: {{ $k }}
{{- if or (kindIs "int64" $v) (kindIs "float64" $v) (kindIs "bool" $v) }}
value: {{ $v | quote }}
{{- else if kindIs "string" $v }}
value: {{ include "common.tplvalues.render" ( dict "value" $v "context" $context ) | squote }}
{{- else }}
valueFrom: {{- include "common.tplvalues.render" ( dict "value" $v "context" $context ) | nindent 4}}
{{- end }}
{{- end }}
{{- end -}}

{{- define "reporting-init.envVars" -}}
{{- $envVars := merge (deepCopy .Values.envVars) (deepCopy .Values.envVarsFrom) -}}
{{- include "reporting-init.baseEnvVars" (dict "envVars" $envVars "context" $) }}
{{- end -}}

{{/*
Return command
*/}}
{{- define "reporting-init.commandBase" -}}
{{- if or .command .args }}
{{- if .command }}
command: {{- include "common.tplvalues.render" (dict "value" .command "context" .context) }}
{{- end }}
{{- if .args }}
args: {{- include "common.tplvalues.render" (dict "value" .args "context" .context) }}
{{- end }}
{{- else if .startUpCommand }}
command: ["/reporting-init/startup-command.sh"]
args: []
{{- end }}
{{- end -}}

{{- define "reporting-init.command" -}}
{{- include "reporting-init.commandBase" (dict "command" .Values.command "args" .Values.args "startUpCommand" .Values.startUpCommand "context" $) }}
{{- end -}}
16 changes: 16 additions & 0 deletions charts/reporting-init/templates/configmap-startup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if and .Values.startUpCommand (not (or .Values.command .Values.args)) }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "common.names.fullname" . }}-startup
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
startup-command.sh: |-
{{- include "common.tplvalues.render" (dict "value" .Values.startUpCommand "context" $) | nindent 4 }}
{{- end }}
99 changes: 99 additions & 0 deletions charts/reporting-init/templates/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "common.names.fullname" . }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-weight": "0"
"helm.sh/hook-delete-policy": before-hook-creation
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- if .Values.backoffLimit }}
backoffLimit: {{ .Values.backoffLimit }}
{{- end }}
template:
metadata:
{{- if .Values.podAnnotations }}
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8}}
{{- end }}
labels: {{- include "common.labels.standard" . | nindent 8 }}
{{- if .Values.podLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }}
{{- end }}
spec:
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image) "global" .Values.global) | nindent 6 }}
{{- if .Values.serviceAccount.name }}
serviceAccountName: {{ .Values.serviceAccount.name }}
{{- end }}
{{- if .Values.podSecurityContext.enabled }}
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
restartPolicy: Never
{{- if .Values.initContainers }}
initContainers:
{{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }}
{{- end }}
containers:
- name: reporting-init
image: {{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- include "reporting-init.command" . | nindent 10 }}
{{- if .Values.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
env: {{- include "reporting-init.envVars" . | nindent 12 }}
volumeMounts:
{{- if .Values.startUpCommand }}
- name: start-up-command-config-map
mountPath: /reporting-init/startup-command.sh
subPath: startup-command.sh
{{- end }}
{{- if .Values.debeziumConnectorConfigMap }}
- name: debezium-conn-config-map
mountPath: /reporting-init/config/debezium-connectors
{{- end }}
{{- if .Values.opensearchConnectorConfigMap }}
- name: os-kafka-conn-config-map
mountPath: /reporting-init/config/opensearch-connectors
{{- end }}
{{- if .Values.dashboardsConnectorConfigMap }}
- name: dashboards-config-map
mountPath: /reporting-init/config/opensearch-dashboards
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" .Values.sidecars "context" $) | nindent 8 }}
{{- end }}
volumes:
{{- if .Values.startUpCommand }}
- name: start-up-command-config-map
configMap:
name: {{ include "common.names.fullname" . }}-startup
defaultMode: 0755
{{- end }}
{{- if .Values.debeziumConnectorConfigMap }}
- name: debezium-conn-config-map
configMap:
name: {{ .Values.debeziumConnectorConfigMap }}
{{- end }}
{{- if .Values.opensearchConnectorConfigMap }}
- name: os-kafka-conn-config-map
configMap:
name: {{ .Values.opensearchConnectorConfigMap }}
{{- end }}
{{- if .Values.dashboardsConnectorConfigMap }}
- name: dashboards-config-map
configMap:
name: {{ .Values.dashboardsConnectorConfigMap }}
{{- end }}
{{- if .Values.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
{{- end }}
Loading

0 comments on commit a1852e7

Please sign in to comment.