Skip to content

Commit

Permalink
add new exstar deploy kind
Browse files Browse the repository at this point in the history
  • Loading branch information
devops-mher committed May 30, 2023
1 parent 254b639 commit 632ec23
Show file tree
Hide file tree
Showing 10 changed files with 232 additions and 6 deletions.
2 changes: 1 addition & 1 deletion charts/backend/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: backend
description: Helm chart scaffolding for Backend applications.
type: application
version: 3.6.1
version: 3.6.2
appVersion: 1.3.0
4 changes: 1 addition & 3 deletions charts/backend/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ spec:

{{- if .Values.cronjob.config.command }}
command:
{{- range $v := .Values.cronjob.config.command }}
- "{{ $v }}"
{{- end }}
{{- toYaml .Values.cronjob.config.command | nindent 14 }}
{{- end }}

{{- if .Values.cronjob.config.args }}
Expand Down
3 changes: 3 additions & 0 deletions charts/backend/templates/extra-list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- if .Values.extraDeploy.enabled -}}
{{- tpl .Values.extraDeploy.yaml . | nindent 0 }}
{{- end }}
16 changes: 15 additions & 1 deletion charts/backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ blackfire:
; blackfire.agent_socket=tcp://blackfire:8307
externalsecrets:
enabled: true
envpath: /tmp
Expand All @@ -278,6 +277,21 @@ externalsecrets:
- DB_HOST
- DB_USERNAME

extraDeploy:
enabled: false
yaml: |
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
cronjob:
enabled: false
schedule: "* * * * *"
Expand Down
2 changes: 1 addition & 1 deletion charts/frontend/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: frontend
description: A frontend Helm chart for Kubernetes
type: application
version: 2.1.4
version: 3.6.2
appVersion: "0.3.10"
17 changes: 17 additions & 0 deletions charts/frontend/templates/configmap-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.cronjob.configMaps }}
{{- range $v := .Values.cronjob.configMaps }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $v.name }}
binaryData:
{{- range $f := $v.files }}
{{- if $f.contentsB64 }}
{{ $f.key }}: "{{ $f.contentsB64 }}"
{{- else }}
{{ $f.key }}: "{{ ($.Files.Get $f.contentsFile) | b64enc }}"
{{- end }}
{{- end }}
---
{{- end }}
{{- end }}
99 changes: 99 additions & 0 deletions charts/frontend/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{{- if .Values.cronjob.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "laravel.fullname" . }}
spec:
schedule: "{{ .Values.cronjob.schedule }}"
concurrencyPolicy: "{{ .Values.cronjob.concurrencyPolicy }}"
failedJobsHistoryLimit: {{ .Values.cronjob.failedJobsHistoryLimit }}
successfulJobsHistoryLimit: {{ .Values.cronjob.successfulJobsHistoryLimit }}

jobTemplate:
spec:
template:
metadata:
labels:
app: {{ include "laravel.fullname" . }}
annotations:
{{- if .Values.cronjob.configMaps }}
{{- range $v := .Values.cronjob.configMaps }}
{{- range $f := $v.files }}
{{- if $f.contentsB64 }}
checksum/{{ $v.name }}-{{ $f.key }}: "{{ $f.contentsB64 | sha256sum }}"
{{- else }}
checksum/{{ $v.name }}-{{ $f.key }}: "{{ ($.Files.Get $f.contentsFile) | b64enc | sha256sum }}"
{{- end }}
{{- end }}
{{- end }}
{{- end }}
spec:
{{- if .Values.cronjob.cloudserviceaccount.deploy }}
serviceAccountName: {{ .Values.cronjob.cloudserviceaccount.name }}
{{- end }}
automountServiceAccountToken: true

{{- if not .Values.cronjob.image.isRepositoryPublic }}
imagePullSecrets:
- name: {{ .Values.cronjob.dockerconfigjson.name }}
{{- end }}

restartPolicy: "{{ .Values.cronjob.restartPolicy }}"

{{- if .Values.cronjob.configMaps }}
volumes:
{{- range $v := .Values.cronjob.configMaps }}
- configMap:
name: {{ $v.name }}
optional: false
name: {{ $v.name }}
{{- end }}
{{- end }}
{{- with .Values.cronjob.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: "{{ include "laravel.fullname" . }}"
image: "{{ .Values.cronjob.image.repository }}:{{ .Values.cronjob.image.tag }}"
imagePullPolicy: {{ default "IfNotPresent" .Values.cronjob.image.pullPolicy }}

{{- if .Values.cronjob.config.command }}
command:
{{- toYaml .Values.cronjob.config.command | nindent 14 }}
{{- end }}

{{- if .Values.cronjob.config.args }}
args:
{{- range $v := .Values.cronjob.config.args }}
- "{{ $v }}"
{{- end }}
{{- end }}

{{- if .Values.cronjob.config.env }}
env:
{{- range $k, $v := .Values.cronjob.config.env }}
- name: "{{ $k }}"
value: "{{ $v }}"
{{- end }}
{{- end }}

{{- if .Values.cronjob.config.secrets }}
envFrom:
- secretRef:
name: {{ .Release.Name }}-cronjob-secret
{{- end }}

{{- if .Values.cronjob.configMaps }}
volumeMounts:
{{- range $v := .Values.cronjob.configMaps }}
- mountPath: "{{ $v.mountPath }}"
{{- if $v.mountPropagation }}
mountPropagation: {{ $v.mountPropagation }}
{{- else }}
mountPropagation: None
{{- end }}
name: {{ $v.name }}
{{- end }}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions charts/frontend/templates/extra-list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- if .Values.extraDeploy.enabled -}}
{{- tpl .Values.extraDeploy.yaml . | nindent 0 }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/frontend/templates/secret-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.cronjob.config.secrets }}
apiVersion: v1
kind: Secret
metadata:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}-cronjob-secret
type: Opaque
data:
{{- range $k, $v := .Values.cronjob.config.secrets }}
{{ $k }}: "{{ $v | b64enc }}"
{{- end }}
{{- end }}
80 changes: 80 additions & 0 deletions charts/frontend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,83 @@ secretenv:
env: dev
product: application

extraDeploy:
enabled: false
yaml: |
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
cronjob:
enabled: false
schedule: "* * * * *"
concurrencyPolicy: "Forbid"
restartPolicy: "Never"
failedJobsHistoryLimit: 10
successfulJobsHistoryLimit: 1
nodeSelector: {}
image:
repository: "busybox"
tag: "latest"
# -- Whether the repository is public
isRepositoryPublic: true
# -- The image pullPolicy to use
pullPolicy: "IfNotPresent"

config:
command: []
# - "/bin/sh"
args: []
# - "-c"
# - "echo 'Environment $(hello_env)! Secret $(username).'"

# -- Map of environment variables to use within the job
env: {}
# hello_env: "world"

# -- Map of secrets that will be exposed as environment variables within the job
secrets: {}
# username: "password"

# -- List of config maps to mount to the deployment
configMaps: []
# - name: "volume-1"
# mountPath: "/etc/config" # Must be unique
# mountPropagation: None # If unset will default to 'None'
# files: []
# - key: "file.cfg" # Key must be unique for each file
# contentsB64: "" # The file contents which have already been base-64 encoded
# contentsFile: "" # The path to a local file (note: contentsB64 will take precedence if not-empty)

dockerconfigjson:
# -- Name of the secret to use for the private repository
name: "snowplow-cron-job-dockerhub"
# -- Username for the private repository
username: ""
# -- Password for the private repository
password: ""
# -- Repository server URL
server: "https://index.docker.io/v1/"
# -- Email address for user of the private repository
email: ""

cloudserviceaccount:
# -- Whether to create a service-account
deploy: false
# -- Name of the service-account to create
name: "snowplow-cron-job-service-account"
aws:
# -- IAM Role ARN to bind to the k8s service account
roleARN: ""
gcp:
# -- Service Account email to bind to the k8s service account
serviceAccount: ""

0 comments on commit 632ec23

Please sign in to comment.