From cd063f671507744439ecb47ef88cca27aa9b2d60 Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Thu, 27 Jun 2019 19:23:56 -0400 Subject: [PATCH] [stable/logstash] Create a ServiceAccount and add arguments (#14536) Signed-off-by: Marc Sensenich --- stable/logstash/Chart.yaml | 2 +- stable/logstash/README.md | 17 ++++++++++------- stable/logstash/serviceaccount.yaml | 0 stable/logstash/templates/_helpers.tpl | 11 +++++++++++ stable/logstash/templates/serviceaccount.yaml | 11 +++++++++++ stable/logstash/templates/statefulset.yaml | 5 +++++ stable/logstash/values.yaml | 11 +++++++++++ 7 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 stable/logstash/serviceaccount.yaml create mode 100644 stable/logstash/templates/serviceaccount.yaml diff --git a/stable/logstash/Chart.yaml b/stable/logstash/Chart.yaml index 1ef16f0bcebe..226005c8ce75 100644 --- a/stable/logstash/Chart.yaml +++ b/stable/logstash/Chart.yaml @@ -3,7 +3,7 @@ description: Logstash is an open source, server-side data processing pipeline icon: https://www.elastic.co/assets/blt86e4472872eed314/logo-elastic-logstash-lt.svg home: https://www.elastic.co/products/logstash name: logstash -version: 2.0.0 +version: 2.1.0 appVersion: 7.1.1 sources: - https://www.docker.elastic.co diff --git a/stable/logstash/README.md b/stable/logstash/README.md index aff0e12604ac..0785d5db5ea0 100644 --- a/stable/logstash/README.md +++ b/stable/logstash/README.md @@ -69,8 +69,8 @@ Please review the following links that expound on current best practices. The following table lists the configurable parameters of the chart and its default values. -| Parameter | Description | Default | -| --------------------------- | -------------------------------------------------- | ------------------------------------------------ | +| Parameter | Description | Default | +| ------------------------------- | -------------------------------------------------- | ------------------------------------------------ | | `replicaCount` | Number of replicas | `1` | | `podDisruptionBudget` | Pod disruption budget | `maxUnavailable: 1` | | `updateStrategy` | Update strategy | `type: RollingUpdate` | @@ -101,7 +101,7 @@ The following table lists the configurable parameters of the chart and its defau | `podLabels` | Pod labels | `{}` | | `extraEnv` | Extra pod environment variables | `[]` | | `extraInitContainers` | Add additional initContainers | `[]` | -| `podManagementPolicy` | podManagementPolicy of the StatefulSet | `OrderedReady` | +| `podManagementPolicy` | podManagementPolicy of the StatefulSet | `OrderedReady` | | `livenessProbe` | Liveness probe settings for logstash container | (see `values.yaml`) | | `readinessProbe` | Readiness probe settings for logstash container | (see `values.yaml`) | | `persistence.enabled` | Enable persistence | `true` | @@ -109,8 +109,8 @@ The following table lists the configurable parameters of the chart and its defau | `persistence.accessMode` | Access mode for PVCs | `ReadWriteOnce` | | `persistence.size` | Size for PVCs | `2Gi` | | `volumeMounts` | Volume mounts to configure for logstash container | (see `values.yaml`) | -| `volumes` | Volumes to configure for logstash container | [] | -| `terminationGracePeriodSeconds` | Duration the pod needs to terminate gracefully | `30` +| `volumes` | Volumes to configure for logstash container | [] | +| `terminationGracePeriodSeconds` | Duration the pod needs to terminate gracefully | `30` | | `exporter.logstash` | Prometheus logstash-exporter settings | (see `values.yaml`) | | `exporter.logstash.enabled` | Enables Prometheus logstash-exporter | `false` | | `elasticsearch.host` | ElasticSearch hostname | `elasticsearch-client.default.svc.cluster.local` | @@ -122,5 +122,8 @@ The following table lists the configurable parameters of the chart and its defau | `inputs` | Logstash inputs configuration | beats | | `filters` | Logstash filters configuration | `nil` | | `outputs` | Logstash outputs configuration | elasticsearch | -| `securityContext.fsGroup` | Group ID for the container | `1000` | -| `securityContext.runAsUser` | User ID for the container | `1000` | +| `securityContext.fsGroup` | Group ID for the container | `1000` | +| `securityContext.runAsUser` | User ID for the container | `1000` | +| `args` | Additional arguments to pass to Logstash | `1000` | +| `serviceAccount.create` | Specifies if a ServiceAccount should be created | `true` | +| `serviceAccount.name` | The name of the ServiceAccount to use | `""` | diff --git a/stable/logstash/serviceaccount.yaml b/stable/logstash/serviceaccount.yaml new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stable/logstash/templates/_helpers.tpl b/stable/logstash/templates/_helpers.tpl index d88fb24b24dd..ab5d4fa08f06 100644 --- a/stable/logstash/templates/_helpers.tpl +++ b/stable/logstash/templates/_helpers.tpl @@ -30,3 +30,14 @@ Create chart name and version as used by the chart label. {{- define "logstash.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "logstash.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "logstash.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/stable/logstash/templates/serviceaccount.yaml b/stable/logstash/templates/serviceaccount.yaml new file mode 100644 index 000000000000..18a28e4929b1 --- /dev/null +++ b/stable/logstash/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "logstash.serviceAccountName" . }} + labels: + app: {{ template "logstash.name" . }} + chart: {{ template "logstash.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- end -}} diff --git a/stable/logstash/templates/statefulset.yaml b/stable/logstash/templates/statefulset.yaml index 120fd8abf0d0..e654ba0dbc6c 100644 --- a/stable/logstash/templates/statefulset.yaml +++ b/stable/logstash/templates/statefulset.yaml @@ -66,6 +66,10 @@ spec: {{ toYaml .Values.livenessProbe | indent 12 }} readinessProbe: {{ toYaml .Values.readinessProbe | indent 12 }} + {{- if .Values.args }} + args: +{{ .Values.args | toYaml | indent 12 }} + {{- end }} env: ## Logstash monitoring API host and port env vars - name: HTTP_HOST @@ -137,6 +141,7 @@ spec: tolerations: {{ toYaml . | indent 8 }} {{- end }} + serviceAccountName: {{ template "logstash.serviceAccountName" . }} terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} volumes: - name: patterns diff --git a/stable/logstash/values.yaml b/stable/logstash/values.yaml index 85b9d0ec17a0..fb2902b1774d 100644 --- a/stable/logstash/values.yaml +++ b/stable/logstash/values.yaml @@ -321,3 +321,14 @@ outputs: # topic_id => "destination" # } } + +serviceAccount: + # Specifies whether a ServiceAccount should be created + create: true + # The name of the ServiceAccount to use. + # If not set and create is true, a name is generated using the fullname template + name: + +## Additional arguments to pass to the Logstash entrypoint +# args: + # - fizz