Skip to content

Commit

Permalink
(BREAKING CHANGE) Change jobs, cronJobs, servicemonitors to map (
Browse files Browse the repository at this point in the history
  • Loading branch information
evgkrsk authored Apr 14, 2022
1 parent 56a0995 commit 741e5de
Show file tree
Hide file tree
Showing 19 changed files with 133 additions and 82 deletions.
1 change: 1 addition & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
yaml-files:
- '*.yaml'
- '*.yml'
- '.yamllint'

rules:
braces:
Expand Down
4 changes: 4 additions & 0 deletions charts/universal-chart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.0.0 - April 14, 2022

* `jobs`, `cronJobs` and `servicemonitors` now is maps, where key is a name

## 2.0.1 - April 8, 2022

* quote integer/float values in configmaps
Expand Down
2 changes: 1 addition & 1 deletion charts/universal-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
description: Nixys universal Helm chart for deploy your apps to Kubernetes
name: universal-chart
version: 2.0.1
version: 3.0.0
maintainers:
- name: Roman Andreev
email: [email protected]
Expand Down
9 changes: 4 additions & 5 deletions charts/universal-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ Secret `data` object is a map where value can be a string, json or base64 encode
| `hooksGeneral.affinity` | Affinity for Hook Job; replicas pods assignment (ignored if defined on Hook level) | `{}` |
| `hooksGeneral.dnsPolicy` | DnsPolicy for Hook Job pods (ignored if defined on Hook level) | `""` |

`hooks` is a map of the Helm Hooks Jobs parameters, where key is a name of job.
`hooks` is a map of the Helm Hooks Jobs parameters, where key is a name of hook.

| Name | Description | Value |
|---------------------------|------------------------------------------------------------------------------------------|-----------------------------|
Expand Down Expand Up @@ -307,7 +307,7 @@ Secret `data` object is a map where value can be a string, json or base64 encode
| `jobsGeneral.affinity` | Affinity for Job; replicas pods assignment (ignored if defined on Job level) | `{}` |
| `jobsGeneral.dnsPolicy` | DnsPolicy for Job pods (ignored if defined on Job level) | `""` |

`jobs` is a list of the Jobs parameters.
`jobs` is a map of the Jobs parameters, where key is a name of job.

| Name | Description | Value |
|---------------------------|------------------------------------------------------------------------------------------|-----------|
Expand Down Expand Up @@ -358,7 +358,7 @@ Secret `data` object is a map where value can be a string, json or base64 encode
| `cronJobsGeneral.affinity` | Affinity for CronJob; replicas pods assignment (ignored if defined on CronJob level) | `{}` |
| `cronJobsGeneral.dnsPolicy` | DnsPolicy for CronJob pods (ignored if defined on CronJob level) | `""` |

`cronJobs` is a list of the Jobs parameters.
`cronJobs` is a map of the Cronjobs parameters, where key is a name of cronjob.

| Name | Description | Value |
|------------------------------|-----------------------------------------------------------------------------------------|-----------|
Expand Down Expand Up @@ -392,11 +392,10 @@ Secret `data` object is a map where value can be a string, json or base64 encode

### ServiceMonitors parameters

`servicemonitors` is a list of the ServiceMonitor parameters.
`servicemonitors` is a map of the ServiceMonitor parameters, where key is a name.

| Name | Description | Value |
|-----------------------|------------------------------------------|-------|
| `name` | Name of the ServiceMonitor | `""` |
| `labels` | Extra ServiceMonitor labels | `{}` |
| `endpoints` | Array of ServiceMonitor endpoints | `[]` |
| `extraSelectorLabels` | Extra selectorLabels for select workload | `{}` |
Expand Down
58 changes: 58 additions & 0 deletions charts/universal-chart/results/cronJobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,61 @@ spec:
volumes:
[]
restartPolicy: Never
---
# Source: universal-chart/templates/cronjob.yml
apiVersion: batch/v1
kind: CronJob
metadata:
name: test-check2
namespace: "default"
labels:
app.kubernetes.io/name: test
app.kubernetes.io/instance: test
app.kubernetes.io/managed-by: Helm
annotations:
spec:
schedule: "null"
jobTemplate:
spec:
template:
metadata:
labels:
annotations:
spec:
affinity:
nodeAffinity:
{}
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/name: test
app.kubernetes.io/instance: test
namespaces:
- "default"
topologyKey: kubernetes.io/hostname
weight: 1
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/name: test
app.kubernetes.io/instance: test
namespaces:
- "default"
topologyKey: kubernetes.io/hostname
weight: 1

containers:
- name: check22
image: nginx:latest
imagePullPolicy: IfNotPresent
command: ["just", "check2"]
volumeMounts:

[]
volumes:
[]
restartPolicy: Never
2 changes: 1 addition & 1 deletion charts/universal-chart/results/sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ spec:
weight: 1

containers:
- name: sample-migrations
- name: migrations
image: busybox:latest
imagePullPolicy: Always
command: ["alembic", "upgrade", "head"]
Expand Down
2 changes: 1 addition & 1 deletion charts/universal-chart/results/servicemonitors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
kind: ServiceMonitor
apiVersion: monitoring.coreos.com/v1
metadata:
name: test-test
name: test-mysm
namespace: "default"
labels:
app.kubernetes.io/name: test
Expand Down
5 changes: 4 additions & 1 deletion charts/universal-chart/samples/cronJobs.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
cronJobs:
- name: check
check:
command: "just check"
envSecrets:
- secret-envs
envConfigmaps:
- envs
check2:
name: check22
command: "just check2"
2 changes: 1 addition & 1 deletion charts/universal-chart/samples/jobs.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
jobs:
- name: migrations
migrations:
activeDeadlineSeconds: 120
backoffLimit: 2
command: "alembic upgrade head"
Expand Down
8 changes: 4 additions & 4 deletions charts/universal-chart/samples/servicemonitors.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
servicemonitors:
- name: test
mysm:
endpoints:
- interval: 30s
port: exporter
path: /metrics
- interval: 30s
port: exporter
path: /metrics
extraSelectorLabels:
app: nginx
labels:
Expand Down
16 changes: 4 additions & 12 deletions charts/universal-chart/templates/cronjob.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{{- $CJ := list -}}
{{- if .Values.cronJobs -}}
{{- if kindIs "string" .Values.cronJobs -}}
{{- $CJ = fromYaml (printf "cronJobs:\n%s" .Values.cronJobs) -}}
{{- else if kindIs "slice" .Values.cronJobs -}}
{{- $CJ = .Values.cronJobs -}}
{{- end -}}
{{- $general := $.Values.cronJobsGeneral -}}
{{- range $i, $job := $CJ }}
{{- $cjName := include "helpers.app.fullname" (dict "name" .name "context" $) }}
{{- range $name, $job := .Values.cronJobs }}
{{- $cjName := include "helpers.app.fullname" (dict "name" $name "context" $) }}
{{- if .commandDurationAlert }}
---
apiVersion: monitoring.coreos.com/v1
Expand Down Expand Up @@ -145,7 +138,7 @@ spec:
{{- with .initContainers}}
initContainers:
{{- range . }}
- name: {{ .name | default $cjName }}
- name: {{ .name | default $name }}
image: {{ .image | default $.Values.defaultImage }}:{{ .imageTag | default $.Values.defaultImageTag }}
imagePullPolicy: {{ .imagePullPolicy | default $.Values.defaultImagePullPolicy }}
{{- with .containerSecurityContext }}
Expand Down Expand Up @@ -191,7 +184,7 @@ spec:
{{- if .containers -}}{{- $containers = .containers -}}{{- else -}}{{- $containers = append list . -}}{{- end }}
containers:
{{- range $containers }}
- name: {{ .name | default $cjName }}
- name: {{ .name | default $name }}
image: {{ .image | default $.Values.defaultImage }}:{{ .imageTag | default $.Values.defaultImageTag }}
imagePullPolicy: {{ .imagePullPolicy | default $.Values.defaultImagePullPolicy }}
{{- with .containerSecurityContext }}
Expand Down Expand Up @@ -236,4 +229,3 @@ spec:
volumes: {{- include "helpers.volumes.renderVolume" (dict "value" . "general" $general "context" $) | indent 10}}
restartPolicy: {{ .restartPolicy | default "Never" }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/universal-chart/templates/extra.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- range .Values.extraDeploy }}
---
{{ include "helpers.tplvalues.render" (dict "value" . "context" $) }}
{{- end }}
{{- end }}
6 changes: 3 additions & 3 deletions charts/universal-chart/templates/helm-hooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ spec:
{{- with .initContainers}}
initContainers:
{{- range . }}
- name: {{ .name | default $hookName }}
- name: {{ .name | default $name }}
image: {{ .image | default $.Values.defaultImage }}:{{ .imageTag | default $.Values.defaultImageTag }}
imagePullPolicy: {{ .imagePullPolicy | default $.Values.defaultImagePullPolicy }}
{{- with .containerSecurityContext }}
Expand Down Expand Up @@ -140,7 +140,7 @@ spec:
{{- if .containers -}}{{- $containers = .containers -}}{{- else -}}{{- $containers = append list . -}}{{- end }}
containers:
{{- range $containers }}
- name: {{ .name | default $hookName }}
- name: {{ .name | default $name }}
image: {{ .image | default $.Values.defaultImage }}:{{ .imageTag | default $.Values.defaultImageTag }}
imagePullPolicy: {{ .imagePullPolicy | default $.Values.defaultImagePullPolicy }}
{{- with .containerSecurityContext }}
Expand Down Expand Up @@ -181,4 +181,4 @@ spec:
{{- end }}
volumes: {{- include "helpers.volumes.renderVolume" (dict "value" . "general" $general "context" $) | indent 6}}
restartPolicy: {{ .restartPolicy | default "Never" }}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/universal-chart/templates/helpers/_affinities.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ requiredDuringSchedulingIgnoredDuringExecution:
{{- include "helpers.affinities.pods.hard" $ -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/universal-chart/templates/helpers/_workloads.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ envFrom:

{{- define "helpers.workload.checksum" -}}
{{ . | toString | sha256sum }}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/universal-chart/templates/ingress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ spec:
{{- include "helpers.tplvalues.render" ( dict "value" .extraTls "context" $ ) | nindent 2 }}
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
16 changes: 4 additions & 12 deletions charts/universal-chart/templates/job.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{{- $j := list -}}
{{- if .Values.jobs -}}
{{- if kindIs "string" .Values.jobs -}}
{{- $j = fromYaml (printf "jobs:\n%s" .Values.jobs) -}}
{{- else if kindIs "slice" .Values.jobs -}}
{{- $j = .Values.jobs -}}
{{- end -}}
{{- $general := $.Values.jobsGeneral -}}
{{- range $i, $job := $j }}
{{- $jobName := include "helpers.app.fullname" (dict "name" .name "context" $) }}
{{- range $name, $job := .Values.jobs }}
{{- $jobName := include "helpers.app.fullname" (dict "name" $name "context" $) }}
{{- if .commandDurationAlert }}
---
apiVersion: monitoring.coreos.com/v1
Expand Down Expand Up @@ -122,7 +115,7 @@ spec:
{{- with .initContainers}}
initContainers:
{{- range . }}
- name: {{ .name | default $jobName }}
- name: {{ .name | default $name }}
image: {{ .image | default $.Values.defaultImage }}:{{ .imageTag | default $.Values.defaultImageTag }}
imagePullPolicy: {{ .imagePullPolicy | default $.Values.defaultImagePullPolicy }}
{{- with .containerSecurityContext }}
Expand Down Expand Up @@ -168,7 +161,7 @@ spec:
{{- if .containers -}}{{- $containers = .containers -}}{{- else -}}{{- $containers = append list . -}}{{- end }}
containers:
{{- range $containers }}
- name: {{ .name | default $jobName }}
- name: {{ .name | default $name }}
image: {{ .image | default $.Values.defaultImage }}:{{ .imageTag | default $.Values.defaultImageTag }}
imagePullPolicy: {{ .imagePullPolicy | default $.Values.defaultImagePullPolicy }}
{{- with .containerSecurityContext }}
Expand Down Expand Up @@ -213,4 +206,3 @@ spec:
volumes: {{- include "helpers.volumes.renderVolume" (dict "value" . "general" $general "context" $) | indent 6}}
restartPolicy: {{ .restartPolicy | default "Never" }}
{{- end }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/universal-chart/templates/servicemonitor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{- range $.Values.servicemonitors }}
{{- range $name, $sm := .Values.servicemonitors }}
---
kind: ServiceMonitor
apiVersion: monitoring.coreos.com/v1
metadata:
name: {{ include "helpers.app.fullname" (dict "name" .name "context" $) }}
name: {{ include "helpers.app.fullname" (dict "name" $name "context" $) }}
namespace: {{ $.Release.Namespace | quote }}
labels:
{{- include "helpers.app.labels" $ | nindent 4 }}
Expand Down
Loading

0 comments on commit 741e5de

Please sign in to comment.