diff --git a/elasticsearch/.helmignore b/elasticsearch/.helmignore new file mode 100644 index 0000000..f0c1319 --- /dev/null +++ b/elasticsearch/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/elasticsearch/Chart.yaml b/elasticsearch/Chart.yaml new file mode 100644 index 0000000..25e972c --- /dev/null +++ b/elasticsearch/Chart.yaml @@ -0,0 +1,20 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +description: A Helm chart for Elasticsearch +name: elasticsearch +version: 0.1.0 +maintainers: + - name: OpenStack-Helm Authors \ No newline at end of file diff --git a/elasticsearch/README.md b/elasticsearch/README.md new file mode 100644 index 0000000..61ff575 --- /dev/null +++ b/elasticsearch/README.md @@ -0,0 +1,71 @@ +# Elasticsearch Helm Chart + +This chart installs a working version of Elasticsearch cluster on Kubernetes. + +### Installation + +Values.yaml contains configuration for Elasticsearch cluster. + +#### Note: Minimum of 2 Master Nodes are required for elasticsearch cluster + +``` +helm install elasticsearch + +``` +### To verify the helm deployment was successful: + +``` +helm list +``` + +### To confirm all pods are up and running: + +``` +kubectl get pods + +``` + +### To view list of services + +``` +kubectl get svc +``` + +``` +elasticsearch-discovery 10.99.148.252 9300/TCP 47m +elasticsearch-logging 10.105.222.126 9200:31070/TCP 47m +``` + +### Test elasticsearch functionality: + +#### From any host within cluster.. + +1) Check if Elasticsearch cluster is up +``` +curl http://10.105.222.126:9200 +``` +``` +curl http://10.105.222.126:9200/_cluster/health?pretty +``` + +2) Store data manually using APIs +``` +curl -XPUT 'http://10.105.222.126:9200/blog/user/renmak' -d \ +'{ "name" : "Dilbert Brown" }' +``` +``` +curl -XPUT 'http://10.105.222.126:9200/blog/post/1' -d \ +'{ "user":"renmak", "title":"how to test ES"}' +``` +3) Retrive data manually using APIs +``` +curl -XGET 'http://10.105.222.126:9200/blog/user/renmak?pretty=true' + +curl -XGET 'http://10.105.222.126:9200/blog/post/1?pretty=true' + +curl -XGET 'http://10.105.222.126:9200/blog/post/_search?q=user:renmak&pretty=true' + +curl -XGET 'http://10.105.222.126:9200/_search?q=*renmak&pretty=true' + +``` + diff --git a/elasticsearch/templates/.DS_Store b/elasticsearch/templates/.DS_Store new file mode 100644 index 0000000..4132da6 Binary files /dev/null and b/elasticsearch/templates/.DS_Store differ diff --git a/elasticsearch/templates/NOTES.txt b/elasticsearch/templates/NOTES.txt new file mode 100644 index 0000000..e69de29 diff --git a/elasticsearch/templates/_helpers.tpl b/elasticsearch/templates/_helpers.tpl new file mode 100644 index 0000000..f7877c3 --- /dev/null +++ b/elasticsearch/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 24 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 24 | trimSuffix "-" -}} +{{- end -}} diff --git a/elasticsearch/templates/deployment-es-client.yaml b/elasticsearch/templates/deployment-es-client.yaml new file mode 100644 index 0000000..09a12d3 --- /dev/null +++ b/elasticsearch/templates/deployment-es-client.yaml @@ -0,0 +1,96 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Values.labels.es_client.name }} + labels: + component: {{ .Values.labels.common.component }} + role: {{ .Values.labels.es_client.role }} +spec: + replicas: {{ .Values.replicas.es_client }} + template: + metadata: + labels: + component: {{ .Values.labels.common.component }} + role: {{ .Values.labels.es_client.role }} + annotations: + # Elasticsearch uses a hybrid mmapfs / niofs directory by default to + # store its indices. The default operating system limits on mmap counts + # is likely to be too low, which may result in out of memory exceptions, + # so we use vm.max_map_count=262144 to increase that value. + pod.beta.kubernetes.io/init-containers: '[ + { + "name": "sysctl", + "image": "busybox", + "imagePullPolicy": "IfNotPresent", + "command": ["sysctl", "-w", "vm.max_map_count=262144"], + "securityContext": { + "privileged": true + } + } + ]' + spec: + containers: + - name: {{ .Values.labels.es_client.name }} + securityContext: + privileged: false + capabilities: + add: + - IPC_LOCK + - SYS_RESOURCE + image: {{ .Values.images.elasticsearch }} + imagePullPolicy: {{ .Values.images.pullPolicy }} + {{- if .Values.resources.enabled }} + resources: + limits: + cpu: {{ .Values.resources.limits.cpu }} + memory: {{ .Values.resources.limits.memory }} + requests: + cpu: {{ .Values.resources.requests.cpu }} + memory: {{ .Values.resources.requests.memory }} + {{- end }} + env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: "CLUSTER_NAME" + value: {{ .Values.cluster_name }} + - name: NODE_MASTER + value: "false" + - name: NODE_DATA + value: "false" + - name: HTTP_ENABLE + value: "true" + - name: "ES_JAVA_OPTS" + value: {{ .Values.es_java_opts.es_client }} + ports: + - containerPort: {{ .Values.network.client.port }} + name: {{ .Values.network.client.name }} + protocol: {{ .Values.network.client.protocol }} + - containerPort: {{ .Values.network.discovery.port}} + name: {{ .Values.network.discovery.name }} + protocol: {{ .Values.network.discovery.protocol }} + volumeMounts: + - name: storage + mountPath: /data + volumes: + - name: storage + emptyDir: {} diff --git a/elasticsearch/templates/deployment-es-data.yaml b/elasticsearch/templates/deployment-es-data.yaml new file mode 100644 index 0000000..bd7045b --- /dev/null +++ b/elasticsearch/templates/deployment-es-data.yaml @@ -0,0 +1,89 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Values.labels.es_data.name }} + labels: + component: {{ .Values.labels.common.component }} + role: {{ .Values.labels.es_data.role }} +spec: + replicas: {{ .Values.replicas.es_data }} + template: + metadata: + labels: + component: {{ .Values.labels.common.component }} + role: {{ .Values.labels.es_data.role }} + annotations: + pod.beta.kubernetes.io/init-containers: '[ + { + "name": "sysctl", + "image": "busybox", + "imagePullPolicy": "IfNotPresent", + "command": ["sysctl", "-w", "vm.max_map_count=262144"], + "securityContext": { + "privileged": true + } + } + ]' + spec: + containers: + - name: {{ .Values.labels.es_data.name }} + securityContext: + privileged: false + capabilities: + add: + - IPC_LOCK + - SYS_RESOURCE + image: {{ .Values.images.elasticsearch }} + imagePullPolicy: {{ .Values.images.pullPolicy }} + {{- if .Values.resources.enabled }} + resources: + limits: + cpu: {{ .Values.resources.limits.cpu }} + memory: {{ .Values.resources.limits.memory }} + requests: + cpu: {{ .Values.resources.requests.cpu }} + memory: {{ .Values.resources.requests.memory }} + {{- end }} + env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: "CLUSTER_NAME" + value: {{ .Values.cluster_name }} + - name: NODE_MASTER + value: "false" + - name: NODE_INGEST + value: "false" + - name: HTTP_ENABLE + value: "false" + - name: "ES_JAVA_OPTS" + value: {{ .Values.es_java_opts.es_data }} + ports: + - containerPort: {{ .Values.network.discovery.port}} + name: {{ .Values.network.discovery.name}} + protocol: {{ .Values.network.discovery.protocol}} + volumeMounts: + - name: storage + mountPath: /data + volumes: + - name: storage + emptyDir: {} diff --git a/elasticsearch/templates/deployment-es-master.yaml b/elasticsearch/templates/deployment-es-master.yaml new file mode 100644 index 0000000..f1fdcd5 --- /dev/null +++ b/elasticsearch/templates/deployment-es-master.yaml @@ -0,0 +1,93 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Values.labels.es_master.name }} + labels: + component: {{ .Values.labels.common.component }} + role: {{ .Values.labels.es_master.role }} +spec: + replicas: {{ .Values.replicas.es_master }} + template: + metadata: + labels: + component: {{ .Values.labels.common.component }} + role: {{ .Values.labels.es_master.role }} + annotations: + pod.beta.kubernetes.io/init-containers: '[ + { + "name": "sysctl", + "image": "busybox", + "imagePullPolicy": "IfNotPresent", + "command": ["sysctl", "-w", "vm.max_map_count=262144"], + "securityContext": { + "privileged": true + } + } + ]' + spec: + containers: + - name: {{ .Values.labels.es_master.name }} + securityContext: + privileged: false + capabilities: + add: + - IPC_LOCK + - SYS_RESOURCE + image: {{ .Values.images.elasticsearch }} + imagePullPolicy: {{ .Values.images.pullPolicy }} + {{- if .Values.resources.enabled }} + resources: + limits: + cpu: {{ .Values.resources.limits.cpu }} + memory: {{ .Values.resources.limits.memory }} + requests: + cpu: {{ .Values.resources.requests.cpu }} + memory: {{ .Values.resources.requests.memory }} + {{- end }} + env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: "CLUSTER_NAME" + value: {{ .Values.cluster_name }} + - name: "NUMBER_OF_MASTERS" + value: "{{ .Values.replicas.es_master }}" + - name: NODE_MASTER + value: "true" + - name: NODE_INGEST + value: "false" + - name: NODE_DATA + value: "false" + - name: HTTP_ENABLE + value: "false" + - name: "ES_JAVA_OPTS" + value: {{ .Values.es_java_opts.es_master }} + ports: + - containerPort: {{ .Values.network.discovery.port }} + name: {{ .Values.network.discovery.name }} + protocol: {{ .Values.network.discovery.protocol }} + volumeMounts: + - name: storage + mountPath: /data + volumes: + - name: storage + emptyDir: {} \ No newline at end of file diff --git a/elasticsearch/templates/service-es-client.yaml b/elasticsearch/templates/service-es-client.yaml new file mode 100644 index 0000000..2dcd8c7 --- /dev/null +++ b/elasticsearch/templates/service-es-client.yaml @@ -0,0 +1,31 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.services.client.name }} + labels: + component: {{ .Values.labels.common.component }} + role: {{ .Values.labels.es_client.role }} +spec: + type: {{ .Values.services.client.type }} + selector: + component: {{ .Values.labels.common.component }} + role: {{ .Values.labels.es_client.role }} + ports: + - name: {{ .Values.network.client.name }} + port: {{ .Values.network.client.port }} + protocol: {{ .Values.network.client.protocol }} + \ No newline at end of file diff --git a/elasticsearch/templates/service-es-discovery.yaml b/elasticsearch/templates/service-es-discovery.yaml new file mode 100644 index 0000000..bcdb65a --- /dev/null +++ b/elasticsearch/templates/service-es-discovery.yaml @@ -0,0 +1,29 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.services.discovery.name }} + labels: + component: {{ .Values.labels.common.component }} + role: {{ .Values.labels.es_master.role }} +spec: + selector: + component: {{ .Values.labels.common.component }} + role: {{ .Values.labels.es_master.role }} + ports: + - name: {{ .Values.network.discovery.name }} + port: {{ .Values.network.discovery.port }} + protocol: {{ .Values.network.discovery.protocol }} diff --git a/elasticsearch/values.yaml b/elasticsearch/values.yaml new file mode 100644 index 0000000..58e064e --- /dev/null +++ b/elasticsearch/values.yaml @@ -0,0 +1,80 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default values for elasticsearch. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicas: + es_master: 3 #Minimum of 2 master is required for ES cluster to work properly. + es_data: 2 + es_client: 2 + +cluster_name: myesdb + +images: + elasticsearch: gcr.io/google_containers/elasticsearch:v2.4.1-2 + pullPolicy: Always + +labels: + common: + component: elasticsearch + es_master: + role: master + name: es-master + es_data: + role: data + name: es-data + es_client: + role: client + name: es-client + +#heap size via JVM flags +es_java_opts: + es_master: "-Xms256m -Xmx256m" + es_data: "-Xms256m -Xmx256m" + es_client: "-Xms256m -Xmx256m" + +services: + client: + name: elasticsearch-logging + type: LoadBalancer + discovery: + name: elasticsearch-discovery + +network: + client: + name: http + port: 9200 + protocol: TCP + discovery: + name: transport + port: 9300 + protocol: TCP + + +resources: + enabled: false + limits: + memory: "256Mi" + cpu: "500m" + requests: + memory: "256Mi" + cpu: "500m" + + + + + +