Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions examples/app/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ app.kubernetes.io/instance: {{ .Release.Name }}
Create the name of the service account to use
*/}}
{{- define "app.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "app.fullname" .) .Values.serviceAccount.name }}
{{- $default := (include "app.fullname" .) }}
{{- with .Values.serviceAccount }}
{{- if .create }}
{{- default $default .name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- default "default" .name }}
{{- end }}
{{- end }}
{{- end }}
6 changes: 6 additions & 0 deletions examples/app/templates/batch-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ spec:
| default .Chart.AppVersion }}
name: pi
resources: {}
nodeSelector: {{- toYaml .Values.batchJob.nodeSelector | nindent 8 }}
restartPolicy: Never
serviceAccountName: {{ default "default" (include "app.serviceAccountName"
.) }}
tolerations: {{- toYaml .Values.batchJob.tolerations | nindent 8 }}
topologySpreadConstraints: {{- toYaml .Values.batchJob.topologySpreadConstraints
| nindent 8 }}
6 changes: 6 additions & 0 deletions examples/app/templates/cron-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,11 @@ spec:
imagePullPolicy: {{ .Values.cronJob.hello.imagePullPolicy }}
name: hello
resources: {}
nodeSelector: {{- toYaml .Values.cronJob.nodeSelector | nindent 12 }}
restartPolicy: OnFailure
serviceAccountName: {{ default "default" (include "app.serviceAccountName"
.) }}
tolerations: {{- toYaml .Values.cronJob.tolerations | nindent 12 }}
topologySpreadConstraints: {{- toYaml .Values.cronJob.topologySpreadConstraints
| nindent 12 }}
schedule: {{ .Values.cronJob.schedule | quote }}
9 changes: 5 additions & 4 deletions examples/app/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ spec:
- mountPath: /var/lib/docker/containers
name: varlibdockercontainers
readOnly: true
nodeSelector: {{- toYaml .Values.fluentdElasticsearch.nodeSelector | nindent 8 }}
serviceAccountName: {{ default "default" (include "app.serviceAccountName" .) }}
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
operator: Exists
tolerations: {{- toYaml .Values.fluentdElasticsearch.tolerations | nindent 8 }}
topologySpreadConstraints: {{- toYaml .Values.fluentdElasticsearch.topologySpreadConstraints
| nindent 8 }}
volumes:
- hostPath:
path: /var/log
Expand Down
4 changes: 4 additions & 0 deletions examples/app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ spec:
resources: {}
nodeSelector: {{- toYaml .Values.myapp.nodeSelector | nindent 8 }}
securityContext: {{- toYaml .Values.myapp.podSecurityContext | nindent 8 }}
serviceAccountName: {{ default "default" (include "app.serviceAccountName" .) }}
terminationGracePeriodSeconds: 10
tolerations: {{- toYaml .Values.myapp.tolerations | nindent 8 }}
topologySpreadConstraints: {{- toYaml .Values.myapp.topologySpreadConstraints | nindent
8 }}
volumes:
- configMap:
name: {{ include "app.fullname" . }}-my-config
Expand Down
6 changes: 6 additions & 0 deletions examples/app/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ spec:
volumeMounts:
- mountPath: /usr/share/nginx/html
name: www
nodeSelector: {{- toYaml .Values.web.nodeSelector | nindent 8 }}
serviceAccountName: {{ default "default" (include "app.serviceAccountName" .)
}}
tolerations: {{- toYaml .Values.web.tolerations | nindent 8 }}
topologySpreadConstraints: {{- toYaml .Values.web.topologySpreadConstraints |
nindent 8 }}
updateStrategy: {}
volumeClaimTemplates:
- metadata:
Expand Down
17 changes: 17 additions & 0 deletions examples/app/values.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
batchJob:
backoffLimit: 4
nodeSelector: {}
pi:
image:
repository: perl
tag: 5.34.0
tolerations: []
topologySpreadConstraints: []
cronJob:
hello:
image:
repository: busybox
tag: "1.28"
imagePullPolicy: IfNotPresent
nodeSelector: {}
schedule: '* * * * *'
tolerations: []
topologySpreadConstraints: []
fluentdElasticsearch:
fluentdElasticsearch:
image:
Expand All @@ -22,6 +28,12 @@ fluentdElasticsearch:
requests:
cpu: 100m
memory: 200Mi
nodeSelector: {}
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
operator: Exists
topologySpreadConstraints: []
kubernetesClusterDomain: cluster.local
myConfig:
dummyconfigmapkey: dummyconfigmapvalue
Expand Down Expand Up @@ -89,6 +101,8 @@ myapp:
tag: v0.8.0
replicas: 3
revisionHistoryLimit: 5
tolerations: []
topologySpreadConstraints: []
myappLbService:
loadBalancerSourceRanges:
- 10.0.0.0/8
Expand Down Expand Up @@ -121,7 +135,10 @@ web:
image:
repository: registry.k8s.io/nginx-slim
tag: "0.8"
nodeSelector: {}
replicas: 2
tolerations: []
topologySpreadConstraints: []
volumeClaims:
www:
requests:
Expand Down
13 changes: 5 additions & 8 deletions examples/operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,12 @@ spec:
nodeSelector: {{- toYaml .Values.controllerManager.nodeSelector | nindent 8 }}
securityContext: {{- toYaml .Values.controllerManager.podSecurityContext | nindent
8 }}
serviceAccountName: {{ include "operator.fullname" . }}-controller-manager
serviceAccountName: {{ default "default" (include "operator.serviceAccountName" .)
}}
terminationGracePeriodSeconds: 10
topologySpreadConstraints:
- matchLabelKeys:
- app
- pod-template-hash
maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
tolerations: {{- toYaml .Values.controllerManager.tolerations | nindent 8 }}
topologySpreadConstraints: {{- toYaml .Values.controllerManager.topologySpreadConstraints
| nindent 8 }}
volumes:
- configMap:
name: {{ include "operator.fullname" . }}-manager-config
Expand Down
2 changes: 1 addition & 1 deletion examples/operator/templates/leader-election-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ roleRef:
name: '{{ include "operator.fullname" . }}-leader-election-role'
subjects:
- kind: ServiceAccount
name: '{{ include "operator.fullname" . }}-controller-manager'
name: '{{ include "operator.serviceAccountName" . }}'
namespace: '{{ .Release.Namespace }}'
2 changes: 1 addition & 1 deletion examples/operator/templates/manager-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ roleRef:
name: '{{ include "operator.fullname" . }}-manager-role'
subjects:
- kind: ServiceAccount
name: '{{ include "operator.fullname" . }}-controller-manager'
name: '{{ include "operator.serviceAccountName" . }}'
namespace: '{{ .Release.Namespace }}'
2 changes: 1 addition & 1 deletion examples/operator/templates/proxy-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ roleRef:
name: '{{ include "operator.fullname" . }}-proxy-role'
subjects:
- kind: ServiceAccount
name: '{{ include "operator.fullname" . }}-controller-manager'
name: '{{ include "operator.serviceAccountName" . }}'
namespace: '{{ .Release.Namespace }}'
6 changes: 4 additions & 2 deletions examples/operator/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{ if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "operator.fullname" . }}-controller-manager
name: {{ include "operator.serviceAccountName" . }}
labels:
{{- include "operator.labels" . | nindent 4 }}
annotations:
{{- toYaml .Values.controllerManager.serviceAccount.annotations | nindent 4 }}
{{- toYaml .Values.serviceAccount.annotations | nindent 4 }}
{{- end }}
16 changes: 13 additions & 3 deletions examples/operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,19 @@ controllerManager:
podSecurityContext:
runAsNonRoot: true
replicas: 1
serviceAccount:
annotations:
k8s.acme.org/some-meta-data: ACME Inc.
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
tolerations: []
topologySpreadConstraints:
- matchLabelKeys:
- app
- pod-template-hash
maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
kubernetesClusterDomain: cluster.local
managerConfig:
controllerManagerConfigYaml: |-
Expand Down Expand Up @@ -89,6 +94,11 @@ secretRegistryCredentials:
secretVars:
var1: ""
var2: ""
serviceAccount:
annotations:
k8s.acme.org/some-meta-data: ACME Inc.
create: true
name: ""
webhookService:
ports:
- port: 443
Expand Down
9 changes: 6 additions & 3 deletions pkg/helm/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@ app.kubernetes.io/instance: {{ .Release.Name }}
Create the name of the service account to use
*/}}
{{- define "<CHARTNAME>.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "<CHARTNAME>.fullname" .) .Values.serviceAccount.name }}
{{- $default := (include "<CHARTNAME>.fullname" .) }}
{{- with .Values.serviceAccount }}
{{- if .create }}
{{- default $default .name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- default "default" .name }}
{{- end }}
{{- end }}
{{- end }}
`
Expand Down
5 changes: 3 additions & 2 deletions pkg/processor/daemonset/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package daemonset

import (
"fmt"
"github.com/arttor/helmify/pkg/processor/pod"
"io"
"strings"
"text/template"

"github.com/arttor/helmify/pkg/processor/pod"

"github.com/arttor/helmify/pkg/helmify"
"github.com/arttor/helmify/pkg/processor"
yamlformat "github.com/arttor/helmify/pkg/yaml"
Expand Down Expand Up @@ -98,7 +99,7 @@ func (d daemonset) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstru
}

nameCamel := strcase.ToLowerCamel(name)
specMap, podValues, err := pod.ProcessSpec(nameCamel, appMeta, dae.Spec.Template.Spec)
specMap, podValues, err := pod.ProcessSpec(nameCamel, appMeta, dae.Spec.Template.Spec, 0)
if err != nil {
return true, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/processor/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (d deployment) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstr
}

nameCamel := strcase.ToLowerCamel(name)
specMap, podValues, err := pod.ProcessSpec(nameCamel, appMeta, depl.Spec.Template.Spec)
specMap, podValues, err := pod.ProcessSpec(nameCamel, appMeta, depl.Spec.Template.Spec, 0)
if err != nil {
return true, nil, err
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/processor/job/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ package job

import (
"fmt"
"io"
"strings"
"text/template"

"github.com/arttor/helmify/pkg/helmify"
"github.com/arttor/helmify/pkg/processor"
"github.com/arttor/helmify/pkg/processor/pod"
yamlformat "github.com/arttor/helmify/pkg/yaml"
"github.com/iancoleman/strcase"
"io"
batchv1 "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"strings"
"text/template"
)

var cronTempl, _ = template.New("cron").Parse(
Expand Down Expand Up @@ -105,7 +106,7 @@ func (p cron) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructure
}

// process job pod template:
podSpecMap, podValues, err := pod.ProcessSpec(nameCamelCase, appMeta, jobObj.Spec.JobTemplate.Spec.Template.Spec)
podSpecMap, podValues, err := pod.ProcessSpec(nameCamelCase, appMeta, jobObj.Spec.JobTemplate.Spec.Template.Spec, 4)
if err != nil {
return true, nil, err
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/processor/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ package job

import (
"fmt"
"io"
"strings"
"text/template"

"github.com/arttor/helmify/pkg/helmify"
"github.com/arttor/helmify/pkg/processor"
"github.com/arttor/helmify/pkg/processor/pod"
yamlformat "github.com/arttor/helmify/pkg/yaml"
"github.com/iancoleman/strcase"
"io"
batchv1 "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"strings"
"text/template"
)

var jobTempl, _ = template.New("job").Parse(
Expand Down Expand Up @@ -104,7 +105,7 @@ func (p job) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured
}
}
// process job pod template:
podSpecMap, podValues, err := pod.ProcessSpec(nameCamelCase, appMeta, jobObj.Spec.Template.Spec)
podSpecMap, podValues, err := pod.ProcessSpec(nameCamelCase, appMeta, jobObj.Spec.Template.Spec, 0)
if err != nil {
return true, nil, err
}
Expand Down
Loading
Loading