Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
Expand configuration options for service account
Browse files Browse the repository at this point in the history
The present introduces support for imagePullSecrets and ServiceAccount annotations

Signed-off-by: Danil Mironov <[email protected]>
  • Loading branch information
patrungel committed Jul 7, 2020
1 parent 4f91298 commit e58e014
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 30 deletions.
2 changes: 1 addition & 1 deletion incubator/kube-downscaler/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: kube-downscaler
apiVersion: v1
version: 0.4.2
version: 0.5.0
appVersion: 19.10.1
description: A Helm chart for kube-downscaler
home: https://github.com/hjacobs/kube-downscaler
Expand Down
49 changes: 26 additions & 23 deletions incubator/kube-downscaler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,32 @@ The command removes all the Kubernetes components associated with the chart and

The following tables lists the configurable parameters of the kube-downscaler chart and their default values.

| Parameter | Description | Default |
| ----------------------- | ---------------------------------------------------------------------------------------------------- | --------------------------------------- |
| `replicaCount` | Number of replicas to run | `1` |
| `name` | How to name resources created by this chart | `kube-downscaler` |
| `debug.enable` | Do you want to start the downscaler in debug mode | `false` |
| `namespace.active_in` | Which namespace does the downscaler scans for deployment/statefulsets to downscale (`''` equals all) | `''` |
| `interval` | Interval between scans, in seconds | `60` |
| `image.repository` | Downscaler container image repository | `hjacobs/kube-downscaler` |
| `image.tag` | Downscaler container image tag | `19.10.1` |
| `image.pullPolicy` | Downscaler container image pull policy | `IfNotPresent` |
| `nodeSelector` | Node labels for downscaler pod assignment | `{}` |
| `tolerations` | Downscaler pod toleration for taints | `[]` |
| `affinity` | Downscaler pod affinity | `{}` |
| `podAnnotations` | Annotations to be added to downscaler pod | `{}` |
| `podLabels` | Labels to be added to downscaler pod | `{}` |
| `resources` | Downscaler pod resource requests & limits | `{}` |
| `securityContext` | SecurityContext to apply to the downscaler pod | `{}` |
| `rbac.create` | If true, create & use RBAC resources | `true` |
| `rbac.serviceAccountName` | ServiceAccount downscaler will use (ignored if rbac.create=true) | `default` |
| `downscaleResources` | Resources the downscaler is allowed to manage | `[deployments, statefulsets]` |
| `excludedDeployments` | Deployments to exclude from the downscaler | `[]` |
| `excludedNamespaces` | Namespaces to exclude from the downscaler | `[]` |
| `extraArgs` | Add extra args to docker command | `[]` |
| Parameter | Description | Default |
| ---------------------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------- |
| `replicaCount` | Number of replicas to run | `1` |
| `name` | How to name resources created by this chart | `kube-downscaler` |
| `debug.enable` | Do you want to start the downscaler in debug mode | `false` |
| `namespace.active_in` | Which namespace does the downscaler scans for deployment/statefulsets to downscale (`''` equals all) | `''` |
| `interval` | Interval between scans, in seconds | `60` |
| `image.repository` | Downscaler container image repository | `hjacobs/kube-downscaler` |
| `image.tag` | Downscaler container image tag | `19.10.1` |
| `image.pullPolicy` | Downscaler container image pull policy | `IfNotPresent` |
| `nodeSelector` | Node labels for downscaler pod assignment | `{}` |
| `tolerations` | Downscaler pod toleration for taints | `[]` |
| `affinity` | Downscaler pod affinity | `{}` |
| `podAnnotations` | Annotations to be added to downscaler pod | `{}` |
| `podLabels` | Labels to be added to downscaler pod | `{}` |
| `resources` | Downscaler pod resource requests & limits | `{}` |
| `securityContext` | SecurityContext to apply to the downscaler pod | `{}` |
| `rbac.create` | If true, create & use RBAC resources | `true` |
| `serviceAccount.create` | If true, create & use a ServiceAccount | `""` |
| `serviceAccount.name` | Custom ServiceAccount name | `""` |
| `serviceAccount.annotations` | Custom annotations for the ServiceAccount. Ignored if serviceAccount.create is false. | `{}` |
| `imagePullSecretsNames` | List of names for imagePullSecrets to use. | `[]` |
| `downscaleResources` | Resources the downscaler is allowed to manage | `[deployments, statefulsets]` |
| `excludedDeployments` | Deployments to exclude from the downscaler | `[]` |
| `excludedNamespaces` | Namespaces to exclude from the downscaler | `[]` |
| `extraArgs` | Add extra args to docker command | `[]` |

> **Tip**: You can use the default [values.yaml](values.yaml)
Expand Down
7 changes: 7 additions & 0 deletions incubator/kube-downscaler/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ Create chart name and version as used by the chart label.
{{- define "kube-downscaler.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "kube-downscaler.serviceAccountName" -}}
{{ default (include "kube-downscaler.fullname" .) .Values.serviceAccount.name }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ roleRef:
name: "{{ template "kube-downscaler.fullname" . }}"
subjects:
- kind: ServiceAccount
name: "{{ template "kube-downscaler.fullname" . }}"
name: {{ include "kube-downscaler.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end -}}
10 changes: 9 additions & 1 deletion incubator/kube-downscaler/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ spec:
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.imagePullSecretsNames }}
imagePullSecrets:
{{- range $secretName := . }}
- name: {{ $secretName }}
{{- end }}
{{- end }}
{{- with .Values.securityContext }}
securityContext:
{{ toYaml . | indent 8 }}
Expand All @@ -68,4 +74,6 @@ spec:
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
serviceAccountName: {{ if .Values.rbac.create }}{{ template "kube-downscaler.fullname" . }}{{ else }}"{{ .Values.rbac.serviceAccountName }}"{{ end }}
{{- if or .Values.serviceAccount.create .Values.serviceAccount.name }}
serviceAccountName: {{ include "kube-downscaler.serviceAccountName" . }}
{{- end }}
9 changes: 7 additions & 2 deletions incubator/kube-downscaler/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{{ if .Values.rbac.create -}}
{{ if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "kube-downscaler.fullname" . }}
name: {{ include "kube-downscaler.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "kube-downscaler.name" . }}
helm.sh/chart: {{ include "kube-downscaler.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end}}
{{- end -}}
13 changes: 11 additions & 2 deletions incubator/kube-downscaler/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,23 @@ interval: 60
rbac:
# If true, create & use RBAC resources
create: true
# Ignored if rbac.create is true
serviceAccountName: default

serviceAccount:
# If true, create & use a ServiceAccount
create: true
# If not set and create is true, a name is generated using the fullname template
name: ""
# Custom annotations for the ServiceAccount. Ignored if serviceAccount.create is false.
annotations: {}

image:
repository: hjacobs/kube-downscaler
tag: 19.10.1
pullPolicy: IfNotPresent

# Names of imagePullSecrets to use.
imagePullSecretsNames: []

resources:
limits: {}
requests: {}
Expand Down

0 comments on commit e58e014

Please sign in to comment.