Skip to content

Commit

Permalink
[incubator/graylog] Add support for node autoscaling and installing p…
Browse files Browse the repository at this point in the history
…lugins (helm#1)

* add autoscaling to graylog nodes

* check for value before setting metrics for hpa

* trying out plugin install

* update init container script

* volume mount plugin folder

* add volume

* try using graylog image for init container

* messed up init container command

* bad command

* mount to another directory to keep all default plugins

* missing && in cmd for install plugins

* copy all files instead of folder

* install plugins to master as well

* always run plugin install so volume mount isn't empty
  • Loading branch information
bjaworski3 authored Jul 16, 2018
1 parent effe2a6 commit 18ba942
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 0 deletions.
32 changes: 32 additions & 0 deletions incubator/graylog/templates/graylog-node-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.nodes.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "graylog.fullname" . }}-node
labels:
app: {{ template "graylog.name" . }}-node
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: graylog-node
spec:
scaleTargetRef:
apiVersion: apps/v1beta1
kind: Deployment
name: {{ template "graylog.fullname" . }}-node
minReplicas: {{ .Values.nodes.autoscaling.minReplicas }}
maxReplicas: {{ .Values.nodes.autoscaling.maxReplicas }}
metrics:
{{ if .Values.nodes.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.nodes.autoscaling.targetCPUUtilizationPercentage }}
{{ end }}
{{ if .Values.nodes.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.nodes.autoscaling.targetMemoryUtilizationPercentage }}
{{ end }}
{{- end }}
31 changes: 31 additions & 0 deletions incubator/graylog/templates/graylog-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ spec:
app: {{ template "graylog.name" . }}-node
role: graylog-node
spec:
initContainers:
- name: install-plugins
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
command: ["sh",
"-c",
"cp /tmp/scripts/install_plugins.sh /usr/share/graylog/plugin/install_plugins.sh &&
chmod 0775 /usr/share/graylog/plugin/install_plugins.sh &&
/usr/share/graylog/plugin/install_plugins.sh &&
cp /usr/share/graylog/plugin/* /usr/share/graylog/plugin_install
"
]
volumeMounts:
- mountPath: /usr/share/graylog/plugin_install
name: graylog-plugins
subPath: plugin
- name: install-plugins
mountPath: /tmp/scripts/
resources:
{{ toYaml .Values.plugins.resources | indent 12 }}
containers:
- name: graylog
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand Down Expand Up @@ -83,3 +102,15 @@ spec:
secretKeyRef:
name: {{ template "graylog.fullname" . }}
key: root_password
volumeMounts:
- mountPath: /usr/share/graylog/plugin
name: graylog-plugins
subPath: plugin
volumes:
- name: install-plugins
configMap:
name: {{ template "graylog.fullname" . }}-install-plugins
items:
- key: install_plugins.sh
path: install_plugins.sh
- name: graylog-plugins
31 changes: 31 additions & 0 deletions incubator/graylog/templates/graylog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ spec:
app: {{ template "graylog.name" . }}
role: graylog-master
spec:
initContainers:
- name: install-plugins
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
command: ["sh",
"-c",
"cp /tmp/scripts/install_plugins.sh /usr/share/graylog/plugin/install_plugins.sh &&
chmod 0775 /usr/share/graylog/plugin/install_plugins.sh &&
/usr/share/graylog/plugin/install_plugins.sh &&
cp /usr/share/graylog/plugin/* /usr/share/graylog/plugin_install
"
]
volumeMounts:
- mountPath: /usr/share/graylog/plugin_install
name: graylog-plugins
subPath: plugin
- name: install-plugins
mountPath: /tmp/scripts/
resources:
{{ toYaml .Values.plugins.resources | indent 12 }}
containers:
- name: graylog
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand Down Expand Up @@ -77,4 +96,16 @@ spec:
secretKeyRef:
name: {{ template "graylog.fullname" . }}
key: root_password
volumeMounts:
- mountPath: /usr/share/graylog/plugin
name: graylog-plugins
subPath: plugin
volumes:
- name: install-plugins
configMap:
name: {{ template "graylog.fullname" . }}-install-plugins
items:
- key: install_plugins.sh
path: install_plugins.sh
- name: graylog-plugins

18 changes: 18 additions & 0 deletions incubator/graylog/templates/install-plugins.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "graylog.fullname" . }}-install-plugins
labels:
app: {{ template "graylog.name" . }}-node
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: graylog-node
data:
install_plugins.sh: |-
cd /usr/share/graylog/plugin
{{- if .Values.plugins.install }}
{{- range $index, $val := .Values.plugins.install }}
wget {{ $val }} --no-check-certificate
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions incubator/graylog/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ master:

nodes:
replicas: 3

autoscaling:
enabled: false
# minReplicas: 3
# maxReplicas: 8
# targetCPUUtilizationPercentage: 50
# targetMemoryUtilizationPercentage: 50

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
Expand Down Expand Up @@ -75,6 +83,12 @@ nodes:
annotations:
# external-dns.alpha.kubernetes.io/hostname: graylog-inputs.example.com

plugins:
install: []
resources: {}
# We allow the plugins init container to have a separate resources declaration because
# the initContainer does not take as much resources.

elasticsearch:
# Host Name for elasticsearch
hosts: elasticsearch
Expand Down

0 comments on commit 18ba942

Please sign in to comment.