-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added crontab for github teams discovery (#63)
* Added crontab for github teams discovery * Added SSL exception and team parent details * Added SSL exception in else part * updated to correct the env population * Added newline at the end of file * Corrected closing end for outer if * Removed hyphens completely to resolve pipeline error * Update _github_teams_discovery_envs.tpl Debug 1 * Update _github_teams_discovery_envs.tpl * Update _github_teams_discovery_envs.tpl debug 3 * Update _github_teams_discovery_envs.tpl * Update _github_teams_discovery_envs.tpl * Update _github_teams_discovery_envs.tpl * Added discoveryCronJob section in values file * Update github-teams-discovery-cronjob.yaml * Update github-teams-discovery-cronjob.yaml Corrected if values discoveryCronJob enabled * Renamed file names to make it generic * Added discoveryCronJob section in all values file * removed cron section from values-dev and prod files and added include to get the complete section in yaml file from values in env * Update values-dev.yaml Regressed values-dev.yaml changes * Corrected file exactly same as hmpps-github-discovery indentation * Corrected env name * Corrected job name from github-teams-discovery-crontab-jobs to github-teams-discovery-job * Updated to run at every 6 hrs * Changed entrypoint.sh to github_teams_discovery.py * Added latest instead of tag for image * Added image and port details * Corrected the image path in values * Added steps to run the requirements * Added non root user to install requirements.txt * Added python3 instead of python in command * Debugging pip_install logs * Added env part back * Added github_teams_discovery.py with dockerfile * Commented job execution for github discovery for cron testing * Added Entrypoint in Dockerfile * Reverted Dockerfile * Commented file get section
- Loading branch information
1 parent
d04f2d1
commit 158fce7
Showing
6 changed files
with
173 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
helm_deploy/hmpps-github-discovery/templates/_discovery_cron_job_envs.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{- define "discoveryCronJob.envs" -}} | ||
{{- if .discoveryCronJob.namespace_secrets -}} | ||
env: | ||
{{- range $secret, $envs := .discoveryCronJob.namespace_secrets }} | ||
{{- range $key, $val := $envs }} | ||
- name: {{ $key }} | ||
valueFrom: | ||
secretKeyRef: | ||
key: {{ trimSuffix "?" $val }} | ||
name: {{ $secret }}{{ if hasSuffix "?" $val }} | ||
optional: true{{ end }} {{- end }} | ||
{{- end }} | ||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "app.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- 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. | ||
*/}} | ||
{{- define "app.fullname" -}} | ||
{{- if .Values.fullnameOverride -}} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- $name := default .Chart.Name .Values.nameOverride -}} | ||
{{- if contains $name .Release.Name -}} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "app.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create a string from a list of values joined by a comma | ||
*/}} | ||
{{- define "app.joinListWithComma" -}} | ||
{{- $local := dict "first" true -}} | ||
{{- range $k, $v := . -}}{{- if not $local.first -}},{{- end -}}{{- $v -}}{{- $_ := set $local "first" false -}}{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "app.labels" -}} | ||
helm.sh/chart: {{ include "app.chart" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
app.kubernetes.io/name: {{ include "app.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "app.selectorLabels" -}} | ||
app: {{ include "app.name" . }} | ||
release: {{ .Release.Name }} | ||
{{- end }} |
44 changes: 44 additions & 0 deletions
44
helm_deploy/hmpps-github-discovery/templates/discovery-cron-job.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{{- if .Values.discoveryCronJob.enabled -}} | ||
# --- | ||
# apiVersion: v1 | ||
# kind: ConfigMap | ||
# metadata: | ||
# name: github-teams-discovery-script | ||
# data: | ||
# github_teams_discovery.py: |- | ||
# {{ .Files.Get "github_teams_discovery.py" | indent 4 }} | ||
|
||
--- | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: github-teams-discovery | ||
spec: | ||
schedule: "20 */6 * * *" | ||
concurrencyPolicy: Forbid | ||
failedJobsHistoryLimit: 5 | ||
startingDeadlineSeconds: 600 | ||
successfulJobsHistoryLimit: 5 | ||
jobTemplate: | ||
spec: | ||
ttlSecondsAfterFinished: 345600 | ||
template: | ||
spec: | ||
containers: | ||
- name: github-teams-discovery | ||
image: ghcr.io/ministryofjustice/hmpps-github-discovery | ||
command: ["python", "-u", "/app/github_teams_discovery.py"] | ||
env: | ||
- name: PATH | ||
value: "/home/appuser/.local:/usr/local/bin:$PATH" | ||
securityContext: | ||
capabilities: | ||
drop: | ||
- ALL | ||
runAsNonRoot: true | ||
allowPrivilegeEscalation: false | ||
seccompProfile: | ||
type: RuntimeDefault | ||
{{- include "discoveryCronJob.envs" .Values | nindent 14 }} | ||
restartPolicy: Never | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters