Skip to content

Commit

Permalink
Merge pull request #11 from lalithkota/1.0
Browse files Browse the repository at this point in the history
Removed redis dependencies as reorg in upstream. Fixed env vars and i…
  • Loading branch information
pjoshi751 authored Dec 16, 2024
2 parents 03c1df5 + ac4df76 commit dcdc3c7
Show file tree
Hide file tree
Showing 15 changed files with 201 additions and 475 deletions.
54 changes: 38 additions & 16 deletions .github/workflows/publish-trigger.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Publish OpenG2P SR BG Tasks Helm charts
name: Publish OpenG2P Helm charts on

on:
push:
branches-ignore:
tags-ignore:
- '**'
branches:
- 1.*
- develop
- main
workflow_dispatch:
Expand All @@ -12,13 +15,13 @@ on:
default: "*"
type: string


jobs:
generate-charts:
runs-on: ubuntu-latest
env:
SKIP: 'FALSE'
RANCHER_CHART_FILTER: "openg2p.org/add-to-rancher"
FORCE_PUBLISH_CHARTS: "${{ inputs.forcePublishCharts || '' }}"
defaults:
run:
shell: bash
Expand All @@ -27,20 +30,29 @@ jobs:
uses: actions/checkout@v3

- id: files
if: env.FORCE_PUBLISH_CHARTS == ''
uses: jitterbit/get-changed-files@v1

- name: save helm/charts to tmp.txt file
run: |
touch charts-list.txt
for changed_file in ${{ steps.files.outputs.all }}; do
if [[ ${changed_file} =~ ^charts ]]; then
chart_name=$(echo "${changed_file}" | awk -F/ '/^[charts]/{print $2}')
echo $chart_name >> charts-list.txt;
echo "Saved $chart_name chart to charts-list.txt"
fi
done
cat charts-list.txt | sort | uniq > charts-list-unique.txt
mv charts-list-unique.txt charts-list.txt
if [ -n "${FORCE_PUBLISH_CHARTS}" ]; then
for chart in charts/${FORCE_PUBLISH_CHARTS}/; do
chart="${chart#charts/}"
chart="${chart%/}"
echo "$chart" >> charts-list.txt
done
else
for changed_file in ${{ steps.files.outputs.all }}; do
if [[ ${changed_file} =~ ^charts ]]; then
chart_name=$(echo "${changed_file}" | awk -F/ '/^[charts]/{print $2}')
echo $chart_name >> charts-list.txt;
echo "Saved $chart_name chart to charts-list.txt"
fi
done
cat charts-list.txt | sort | uniq > charts-list-unique.txt
mv charts-list-unique.txt charts-list.txt
fi
echo "List of charts to be published";
cat charts-list.txt
Expand All @@ -50,16 +62,26 @@ jobs:
echo "::warning::No Charts to publish";
echo "SKIP=TRUE" >> $GITHUB_ENV
else
for chartpath in charts/*/; do
if [ -f ${chartpath}Chart.yaml ]; then
helm dep up $chartpath
fi
done
RANCHER_CHARTS=()
while IFS= read -r chartpath; do
echo "chartpath: $chartpath"
chartname=$(basename "$chartpath")
if [ -f charts/${chartname}/Chart.yaml ]; then
echo "Chartname: $chartname"
echo "Chartname: $chartname"
helm dep up charts/$chartpath
echo "Chartname: $chartname"
helm dep up charts/$chartpath
helm package charts/$chartpath
is_rancher_chart=$(grep "$RANCHER_CHART_FILTER" charts/${chartpath%*/}/Chart.yaml || true)
if [ -n "$is_rancher_chart" ]; then
RANCHER_CHARTS+=("$chartname")
helm package charts/$chartpath
is_rancher_chart=$(grep "$RANCHER_CHART_FILTER" charts/${chartpath%*/}/Chart.yaml || true)
if [ -n "$is_rancher_chart" ]; then
RANCHER_CHARTS+=("$chartname")
fi
fi
done < charts-list.txt
echo "RANCHER_CHARTS=${RANCHER_CHARTS[@]}" >> $GITHUB_ENV
Expand Down
6 changes: 1 addition & 5 deletions charts/openg2p-sr-bg-tasks-celery-beat-producers/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ apiVersion: v2
name: openg2p-sr-bg-tasks-celery-beat-producers
description: A Helm chart for OpenG2P SR Celery Beat Producers
type: application
version: 1.0.1
version: 1.0.0-develop
appVersion: ""
dependencies:
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
version: 2.x.x
- name: redis
repository: oci://registry-1.docker.io/bitnamicharts
version: 20.x.x
condition: redis.enabled
keywords:
- openg2p-sr-bg-tasks-celery-beat-producers
maintainers:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,94 +1,29 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "g2p-sr-bg.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "g2p-sr-bg.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Return podAnnotations
*/}}
{{- define "g2p-sr-bg.podAnnotations" -}}
{{- if .Values.podAnnotations }}
{{ include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) }}
{{- end }}
{{- if and .Values.metrics.enabled .Values.metrics.podAnnotations }}
{{ include "common.tplvalues.render" (dict "value" .Values.metrics.podAnnotations "context" $) }}
{{- end }}
{{- define "sr-bg-tasks-producer.serviceAccountName" -}}
{{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "g2p-sr-bg.serviceAccountName" -}}
{{ default (printf "%s" (include "common.names.fullname" .)) .Values.serviceAccount.name }}
{{- define "sr-bg-tasks-producer.imagePullSecrets" -}}
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.volumePermissions.image) "global" .Values.global) -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
Render Env values section
*/}}
{{- define "g2p-sr-bg.fullname" -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "g2p-sr-bg.labels" -}}
helm.sh/chart: {{ include "g2p-sr-bg.chart" . }}
{{ include "g2p-sr-bg.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "g2p-sr-bg.selectorLabels" -}}
app.kubernetes.io/name: {{ include "g2p-sr-bg.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "g2p-sr-bg.imagePullSecrets" -}}
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image) "global" .Values.global) -}}
{{- end -}}

{{/*
Return the proper image name
*/}}
{{- define "g2p-sr-bg.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
{{- end -}}

{{/*
Unified template to render environment variables with type checks and possible valueFrom rendering.
*/}}
{{- define "g2p-sr-bg.envVars" -}}
{{- $context := . -}} # We directly use the root context since 'context' was previously just the root passed as 'context'.
{{- $envVars := merge (deepCopy .Values.envVars) (deepCopy .Values.envVarsFrom) dict -}} # Merging all environment variable definitions into a single map.
{{- range $k, $v := $envVars }}
{{- define "sr-bg-tasks-producer.baseEnvVars" -}}
{{- $context := .context -}}
{{- range $k, $v := .envVars }}
- name: {{ $k }}
{{- if or (kindIs "int64" $v) (kindIs "float64" $v) (kindIs "bool" $v) }}
{{- 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 }}
{{- 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 "sr-bg-tasks-producer.envVars" -}}
{{- $envVars := merge (deepCopy .Values.envVars) (deepCopy .Values.envVarsFrom) -}}
{{- include "sr-bg-tasks-producer.baseEnvVars" (dict "envVars" $envVars "context" $) }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ template "common.names.fullname" . }}
name: {{ include "common.names.fullname" . }}
labels: {{- include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
Expand All @@ -17,12 +17,12 @@ spec:
template:
metadata:
{{- if .Values.podAnnotations }}
annotations: {{- include "g2p-sr-bg.podAnnotations" . | nindent 8 }}
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
{{- end }}
labels: {{- include "common.labels.standard" (dict "customLabels" .Values.podLabels "context" $) | nindent 8 }}
spec:
serviceAccountName: {{ template "g2p-sr-bg.serviceAccountName" . }}
{{- include "g2p-sr-bg.imagePullSecrets" . | nindent 6 }}
serviceAccountName: {{ include "sr-bg-tasks-producer.serviceAccountName" . }}
{{- include "sr-bg-tasks-producer.imagePullSecrets" . | nindent 6 }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.hostAliases "context" $) | nindent 8 }}
{{- if .Values.affinity }}
affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.affinity "context" $) | nindent 8 }}
Expand All @@ -35,34 +35,42 @@ spec:
nodeSelector: {{- include "common.tplvalues.render" ( dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.tolerations "context" .) | nindent 8 }}
priorityClassName: {{ .Values.priorityClassName | quote }}
securityContext: {{- if .Values.podSecurityContext.enabled }}
{{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- if .Values.podSecurityContext.enabled }}
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
initContainers:
{{- if .Values.postgresCheckerInit.enabled }}
- name: postgres-checker
image: {{ .Values.postgresCheckerInit.image }}
command:
{{- toYaml .Values.postgresCheckerInit.command | nindent 12 }}
env: {{- include "g2p-sr-bg.envVars" . | nindent 12 }}
env: {{- include "sr-bg-tasks-producer.envVars" . | nindent 12 }}
{{- end }}
{{- if .Values.initContainers }}
{{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }}
{{- end }}
containers:
- name: g2p-sr-bg
image: {{ template "g2p-sr-bg.image" . }}
- name: g2p-sr-bg-producer
image: {{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- include "g2p-sr-bg.envVars" . | nindent 12 }}
resources: {{- if .Values.resources }}
{{- toYaml .Values.resources | nindent 12 }}
env: {{- include "sr-bg-tasks-producer.envVars" . | nindent 12 }}
{{- if .Values.resources }}
resources: {{- toYaml .Values.resources | nindent 12 }}
{{- end }}
{{- if .Values.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
lifecycle: {{- if .Values.lifecycleHooks }}
{{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }}
{{- if .Values.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.startupProbe "enabled") "context" $) | nindent 12 }}
{{- end }}
securityContext: {{- if .Values.containerSecurityContext.enabled }}
{{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.livenessProbe "enabled") "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.probes }}
probes: {{- include "g2p-sr-bg.probes" . | nindent 12 }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.readinessProbe "enabled") "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" .Values.sidecars "context" $) | nindent 8 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "g2p-sr-bg.serviceAccountName" . }}
name: {{ template "sr-bg-tasks-worker.serviceAccountName" . }}
labels: {{- include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
Expand Down
Loading

0 comments on commit dcdc3c7

Please sign in to comment.