Skip to content

Commit

Permalink
Helm chart for nebula (#1473)
Browse files Browse the repository at this point in the history
This pr is to provide a helm chart for nebula. With this chart, we can install nebula in few steps.
  • Loading branch information
knightXun authored Mar 9, 2020
1 parent 546f85e commit 439ea8c
Show file tree
Hide file tree
Showing 11 changed files with 738 additions and 0 deletions.
22 changes: 22 additions & 0 deletions kubernetes/helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
.vscode/
18 changes: 18 additions & 0 deletions kubernetes/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
name: nebula
description: A distributed, fast open-source graph database
featuring horizontal scalability and high availability
https://nebula-graph.io
type: application
version: 0.1
appVersion: 1.0.0-rc2
keywords:
- graph-database
- distributed
- database
- graphdb
home: https://nebula-graph.io
maintainers:
- name: flyingcat
email: badgangkiller@gmail.com
engine: gotpl
1 change: 1 addition & 0 deletions kubernetes/helm/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

67 changes: 67 additions & 0 deletions kubernetes/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "nebula.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "nebula.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "nebula.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "nebula.labels" -}}
helm.sh/chart: {{ include "nebula.chart" . }}
{{ include "nebula.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "nebula.selectorLabels" -}}
app.kubernetes.io/name: {{ include "nebula.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "nebula.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "nebula.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{- define "metad.endpoints" -}}
{{- join "," .Values.MetadHosts -}}
{{- end -}}
165 changes: 165 additions & 0 deletions kubernetes/helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: nebula-graphd
namespace: {{ .Values.namespace }}
data:
nebula-graphd.conf: |
########## basics ##########
# Whether to run as a daemon process
--daemonize=false
# The file to host the process id
--pid_file=pids/nebula-graphd.pid
########## logging ##########
# The directory to host logging files, which must already exists
--log_dir=logs
# Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively
--minloglevel=2
# Verbose log level, 1, 2, 3, 4, the higher of the level, the more verbose of the logging
--v=0
# Maximum seconds to buffer the log messages
--logbufsecs=0
# Whether to redirect stdout and stderr to separate output files
--redirect_stdout=true
# Destination filename of stdout and stderr, which will also reside in log_dir.
--stdout_log_file=stdout.log
--stderr_log_file=stderr.log
# Copy log messages at or above this level to stderr in addition to logfiles. The numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively.
--stderrthreshold=2
########## networking ##########
# Meta Server Address
--meta_server_addrs={{ template "metad.endpoints" . }}
# Local ip
--local_ip=0.0.0.0
# Network device to listen on
--listen_netdev=any
# Port to listen on
--port={{ .Values.port.graphd.thriftPort }}
# To turn on SO_REUSEPORT or not
--reuse_port=false
# Backlog of the listen socket, adjust this together with net.core.somaxconn
--listen_backlog=1024
# Seconds before the idle connections are closed, 0 for never closed
--client_idle_timeout_secs=0
# Seconds before the idle sessions are expired, 0 for no expiration
--session_idle_timeout_secs=60000
# The number of threads to accept incoming connections
--num_accept_threads=1
# The number of networking IO threads, 0 for # of CPU cores
--num_netio_threads=0
# The number of threads to execute user queries, 0 for # of CPU cores
--num_worker_threads=0
# HTTP service ip
--ws_ip=0.0.0.0
# HTTP service port
--ws_http_port={{ .Values.port.graphd.httpPort }}
# HTTP2 service port
--ws_h2_port={{ .Values.port.graphd.http2Port }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nebula-metad
namespace: {{ .Values.namespace }}
data:
nebula-metad.conf: |
########## basics ##########
# Whether to run as a daemon process
--daemonize=false
# The file to host the process id
--pid_file=pids/nebula-metad.pid
########## logging ##########
# The directory to host logging files, which must already exists
--log_dir=logs
# Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively
--minloglevel=2
# Verbose log level, 1, 2, 3, 4, the higher of the level, the more verbose of the logging
--v=0
# Maximum seconds to buffer the log messages
--logbufsecs=0
########## networking ##########
# Meta Server Address
--meta_server_addrs={{ template "metad.endpoints" . }}
# Local ip
--local_ip=0.0.·0.0
# Meta daemon listening port
--port={{ .Values.port.metad.thriftPort }}
# HTTP service ip
--ws_ip=0.0.0.0
# HTTP service port
--ws_http_port={{ .Values.port.metad.httpPort }}
# HTTP2 service port
--ws_h2_port={{ .Values.port.metad.http2Port }}
########## storage ##########
# Root data path, here should be only single path for metad
--data_path=data/meta
########## Misc #########
# The default number of parts when a space is created
--default_parts_num=100
# The default replica factor when a space is created
--default_replica_factor=1
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nebula-storaged
namespace: {{ .Values.namespace }}
data:
nebula-storaged.conf: |
########## basics ##########
# Whether to run as a daemon process
--daemonize=false
# The file to host the process id
--pid_file=pids/nebula-storaged.pid
########## logging ##########
# The directory to host logging files, which must already exists
--log_dir=logs
# Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively
--minloglevel=2
# Verbose log level, 1, 2, 3, 4, the higher of the level, the more verbose of the logging
--v=0
# Maximum seconds to buffer the log messages
--logbufsecs=0
########## networking ##########
# Meta server address
--meta_server_addrs={{ template "metad.endpoints" . }}
# Local ip
--local_ip=0.0.0.0
# Storage daemon listening port
--port={{ .Values.port.storaged.thriftPort }}
# HTTP service ip
--ws_ip=0.0.0.0
# HTTP service port
--ws_http_port={{ .Values.port.storaged.httpPort }}
# HTTP2 service port
--ws_h2_port={{ .Values.port.storaged.http2Port }}
########## storage ##########
# Root data path, multiple paths should be splitted by comma.
# One path per instance, if --engine_type is `rocksdb'
--data_path=data/storage
# The default reserved bytes for one batch operation
--rocksdb_batch_size=4096
# The default block cache size used in BlockBasedTable.
# The unit is MB.
--rocksdb_block_cache=4
# The type of storage engine, `rocksdb', `memory', etc.
--engine_type=rocksdb
############## rocksdb Options ##############
--rocksdb_disable_wal=true
# rocksdb DBOptions in json, each name and value of option is a string, given as "option_name":"option_value" separated by comma
--rocksdb_db_options={}
# rocksdb ColumnFamilyOptions in json, each name and value of option is string, given as "option_name":"option_value" separated by comma
--rocksdb_column_family_options={"write_buffer_size":"67108864","max_write_buffer_number":"4","max_bytes_for_level_base":"268435456"}
# rocksdb BlockBasedTableOptions in json, each name and value of option is string, given as "option_name":"option_value" separated by comma
--rocksdb_block_based_table_options={"block_size":"8192"}
79 changes: 79 additions & 0 deletions kubernetes/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nebula-graphd
name: nebula-graphd
namespace: {{ .Values.namespace }}
spec:
selector:
matchLabels:
app: nebula-graphd
replicas: {{ .Values.replication.graphd.replicas }}
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
labels:
app: nebula-graphd
spec:
restartPolicy: Always
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
containers:
- name: nebula-graphd
image: "{{ .Values.image.graphd.repository }}:{{ .Values.image.graphd.tag }}"
imagePullPolicy: {{ .Values.image.graphd.pullPolicy }}
env:
- name: USER
value: root
resources:
requests:
cpu: {{ .Values.resources.graphd.requests.cpu | quote }}
memory: {{ .Values.resources.graphd.requests.memory | quote }}
limits:
cpu: {{ .Values.resources.graphd.limits.cpu | quote }}
memory: {{ .Values.resources.graphd.limits.memory | quote }}
ports:
- name: thrift
containerPort: {{ .Values.port.graphd.thriftPort }}
- name: http
containerPort: {{ .Values.port.graphd.httpPort }}
- name: http2
containerPort: {{ .Values.port.graphd.http2Port }}
command: ["/usr/local/nebula/bin/nebula-graphd", "--flagfile=/usr/local/nebula/etc/nebula-graphd.conf", "--v=0", "--minloglevel=2", "--daemonize=false"]
{{- if .Values.livenessProbe.graphd.Enable }}
livenessProbe:
httpGet:
path: /status
port: {{ .Values.port.graphd.httpPort }}
initialDelaySeconds: 30
timeoutSeconds: 5
{{- end }}
resources:
#TODO: Change these to appropriate values for the hardware that you're running.
requests:
cpu: "{{ .Values.resources.graphd.requests.cpu }}"
memory: "{{ .Values.resources.graphd.requests.memory }}"
limits:
cpu: "{{ .Values.resources.graphd.limits.cpu }}"
memory: "{{ .Values.resources.graphd.limits.memory }}"
volumeMounts:
- name: config
mountPath: /usr/local/nebula/etc/
- name: timezone
mountPath: /etc/localtime
volumes:
- name: timezone
hostPath:
path: /etc/localtime
- name: config
configMap:
name: nebula-graphd


9 changes: 9 additions & 0 deletions kubernetes/helm/templates/ingress-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: graphd-services
namespace: {{ .Values.namespace }}
data:
3699: "{{ .Values.namespace}}/nebula-graphd:{{ .Values.port.graphd.thriftPort }}"
13000: "{{ .Values.namespace}}/nebula-graphd:{{ .Values.port.graphd.httpPort }}"
13002: "{{ .Values.namespace}}/nebula-graphd:{{ .Values.port.graphd.http2Port }}"
12 changes: 12 additions & 0 deletions kubernetes/helm/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: nebula-budget
labels:
app: nebula-budget
spec:
selector:
matchLabels:
app: nebula-storaged
app: nebula-metad
maxUnavailable: 1
Loading

0 comments on commit 439ea8c

Please sign in to comment.