-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* set ldap to use recursive search. Set flags for log level. * Added helm chart * bumped chart version * fxied restart policy * fixed config file line * fixd name of yaml file * fixed viewer, editor -> view, edit * Added exit code logic * add dev environment * formatting * open file with 'with' keyword * formatting * removed unused filter, fixed login, name and email being arrays and thus crashing the script * updated apiVersion of cronjob --------- Co-authored-by: Oliver Isaac <[email protected]> Co-authored-by: Jens Plüddemann <[email protected]>
- Loading branch information
1 parent
26fb21a
commit 79a3c5c
Showing
20 changed files
with
1,438 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,4 +133,9 @@ dmypy.json | |
.lock | ||
.idea | ||
/shelf/ | ||
/workspace.xml | ||
/workspace.xml | ||
|
||
# Nix | ||
.devenv | ||
.direnv | ||
.envrc |
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
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
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/ |
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,23 @@ | ||
apiVersion: v2 | ||
name: grafana-ldap-sync | ||
description: A Helm chart for Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 1.0.4 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
appVersion: 1.0.0 |
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,2 @@ | ||
template: | ||
helm3 template . --values=./values.example.yaml --debug |
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 @@ | ||
This helm chart deploys a cronjob which runs on, by default, a 30 minute schedule. |
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,62 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "grafana-ldap-sync.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 "grafana-ldap-sync.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 "grafana-ldap-sync.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "grafana-ldap-sync.labels" -}} | ||
helm.sh/chart: {{ include "grafana-ldap-sync.chart" . }} | ||
{{ include "grafana-ldap-sync.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "grafana-ldap-sync.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "grafana-ldap-sync.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "grafana-ldap-sync.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "grafana-ldap-sync.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- 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,74 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ include "grafana-ldap-sync.fullname" . }}-config | ||
labels: | ||
{{- include "grafana-ldap-sync.labels" . | nindent 4 }} | ||
stringData: | ||
config.yaml: | | ||
config: | ||
{{- .Values.config | toYaml | nindent 6 }} | ||
{{- if .Values.csvContent }} | ||
permissions.csv: {{ .Values.csvContent | quote }} | ||
{{- else }} | ||
{{- $comment := "In this case we need to generate the CSV usign some crazy logic" }} | ||
permissions.csv: | | ||
{{- $perms := list ( list "ZBV/LDAP-Gruppe" "Grafana-Team-Name" "Grafana-Team-ID" "Grafana-Folder-Name" "Grafana-Folder-UUID" "Grafana-Folder-Permissions" ) }} | ||
{{- $teams := .Values.teams }} | ||
{{- $folders := .Values.folders }} | ||
{{- $addTeamsToAll := .Values.addTeamsToAll }} | ||
{{- range $teamName, $groups := $teams }} | ||
{{- $comment := "This is how we default the group list to the team name" }} | ||
{{- if not $groups }} | ||
{{- $groups = list $teamName }} | ||
{{- end }} | ||
{{- $comment := "Ensure that every permission level exists for every folder" }} | ||
{{- range $permLevel, $teamsToAdd := $addTeamsToAll }} | ||
{{- range $folderName, $permission := $folders }} | ||
{{- if not ( get $permission $permLevel ) }} | ||
{{- $permission = set $permission $permLevel ( list ) }} | ||
{{- $folders = set $folders $folderName $permission }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{- range $folderName, $permission := $folders }} | ||
{{- $comment := "This is how we default the permission" }} | ||
{{- if not $permission }} | ||
{{- $permission = dict "admin" ( list $folderName ) }} | ||
{{- end }} | ||
{{- range $permLevel, $permTeams := $permission }} | ||
{{- $comment := "If the user decides to use Admin we must ensure it is lowercase" }} | ||
{{- $permLevel = lower $permLevel }} | ||
{{- $comment := "This is how we use the addTeamsToAll so that a team can be added to all folders" }} | ||
{{- $teamsToAdd := ( get $addTeamsToAll $permLevel ) }} | ||
{{- if $teamsToAdd }} | ||
{{- $permTeams = concat $permTeams $teamsToAdd }} | ||
{{- end }} | ||
{{- range $t := $permTeams }} | ||
{{- if eq ( toString $t ) $teamName }} | ||
{{- range $group := $groups }} | ||
{{- $ldapGroup := $group }} | ||
{{- $grafanaTeamName := $teamName }} | ||
{{- $grafanaTeamID := 1 }} | ||
{{- $grafanaFolderName := $folderName }} | ||
{{- $grafanaFolderUUID := $folderName | lower | replace " " "-" }} | ||
{{- $grafanaFolderPermissions := title $permLevel }} | ||
{{- $perms = append $perms ( list $ldapGroup $grafanaTeamName $grafanaTeamID $grafanaFolderName $grafanaFolderUUID $grafanaFolderPermissions ) }} | ||
{{- end }} {{- $comment := "End range $groups" }} | ||
{{- end }} {{- $comment := "end if eq $teamname" }} | ||
{{- end }} {{- $comment := "end range $teams" }} | ||
{{- end }} {{- $comment := "end range $permission" }} | ||
{{- end }} {{- $comment := "end range $folders" }} | ||
{{- end }} {{- $comment := "end range $teams" }} | ||
{{- range $perm := $perms }} | ||
{{- $perm | join "," | nindent 4 }} | ||
{{- end }} | ||
{{- end }} {{- $comment := "End if .csvContent" }} | ||
|
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,102 @@ | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: {{ include "grafana-ldap-sync.fullname" . }} | ||
labels: | ||
{{- include "grafana-ldap-sync.labels" . | nindent 4 }} | ||
spec: | ||
startingDeadlineSeconds: {{ .Values.cronJob.startingDeadlineSeconds }} | ||
schedule: {{ .Values.cronJob.schedule | quote }} | ||
successfulJobsHistoryLimit: {{ .Values.cronJob.successfulJobsHistoryLimit }} | ||
suspend: {{ .Values.cronJob.suspend }} | ||
concurrencyPolicy: {{ .Values.cronJob.concurrencyPolicy }} | ||
failedJobsHistoryLimit: {{ .Values.cronJob.failedJobsHistoryLimit }} | ||
jobTemplate: | ||
metadata: | ||
labels: | ||
{{- include "grafana-ldap-sync.labels" . | nindent 8 }} | ||
spec: | ||
activeDeadlineSeconds: 120 | ||
template: | ||
metadata: | ||
{{- with .Values.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
labels: | ||
{{- include "grafana-ldap-sync.selectorLabels" . | nindent 12 }} | ||
spec: | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
serviceAccountName: {{ include "grafana-ldap-sync.serviceAccountName" . }} | ||
restartPolicy: {{ .Values.restartPolicy }} | ||
{{- with .Values.securityContext }} | ||
securityContext: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- with .Values.extraInitContainers }} | ||
{{- toYaml . | nindent 10 }} | ||
{{- end }} | ||
containers: | ||
{{- with .Values.extraContainers }} | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
- name: {{ .Chart.Name }} | ||
{{- with .Values.securityContext }} | ||
securityContext: | ||
{{- toYaml . | nindent 16 }} | ||
{{- end }} | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
args: | ||
- --config=/config/config.yaml | ||
- --bind=/config/permissions.csv | ||
- --log-level={{ .Values.logLevel }} | ||
{{- if .Values.dryRun }} | ||
- --dry-run | ||
{{- end }} | ||
{{- with .Values.extraArgs }} | ||
{{- toYaml . | nindent 14 }} | ||
{{- end }} | ||
|
||
{{- with .Values.resources }} | ||
resources: | ||
{{- toYaml . | nindent 16 }} | ||
{{- end }} | ||
volumeMounts: | ||
- name: config | ||
mountPath: /config | ||
readOnly: true | ||
{{- with .Values.extraVolumeMounts }} | ||
{{- toYaml . | nindent 14 }} | ||
{{- end }} | ||
{{- with .Values.extraContainerConfig }} | ||
{{- toYaml . | nindent 14 }} | ||
{{- end }} | ||
{{- with .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- with .Values.affinity }} | ||
affinity: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- with .Values.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
volumes: | ||
- name: config | ||
secret: | ||
secretName: {{ include "grafana-ldap-sync.fullname" . }}-config | ||
{{- with .Values.extraVolumes }} | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
--- | ||
{{- range $man := .Values.extraManifests }} | ||
{{- toYaml $man }} | ||
--- | ||
{{- end }} | ||
|
12 changes: 12 additions & 0 deletions
12
deploy/helm/grafana-ldap-sync/templates/serviceaccount.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,12 @@ | ||
{{- if .Values.serviceAccount.create -}} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "grafana-ldap-sync.serviceAccountName" . }} | ||
labels: | ||
{{- include "grafana-ldap-sync.labels" . | nindent 4 }} | ||
{{- with .Values.serviceAccount.annotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- end }} |
Oops, something went wrong.