Skip to content

Commit d822773

Browse files
[Feature #884] Helm chart for Kubernetes deployments PR#902 (#971)
* Include the Helm Chart and Kubernetes YAMLs - Includes the Helm chart required for the NeoDash deployment for the Kubernetes clusters - Includes the example YAML files for the Kubernetes manifests - Appropriate document changes to include the new Kubernetes deployments. Signed-off-by: Lolla, Venkata <[email protected]> * Fix the chart notes Signed-off-by: Lolla, Venkata <[email protected]> * Patch a typo in the build-and-run.adoc file Signed-off-by: Lolla, Venkata <[email protected]> * Resolves SonarCloud warning Signed-off-by: Lolla, Venkata <[email protected]> * Review + small fixes, LGTM --------- Signed-off-by: Lolla, Venkata <[email protected]> Co-authored-by: Lolla, Venkata <[email protected]>
1 parent 416b8f8 commit d822773

File tree

15 files changed

+741
-1
lines changed

15 files changed

+741
-1
lines changed

docs/modules/ROOT/pages/developer-guide/build-and-run.adoc

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ docker run -it –rm -p 5005:5005 neodash
7676

7777
== Run on Kubernetes
7878

79-
An example of a pod definition YAML file to create a NeoDash pod in a cluster:
79+
=== To deploy using YAML files
80+
81+
YAML examples are available in the https://github.com/neo4j-labs/neodash[NeoDash repository]. Here is an example of a pod definition YAML file to create a NeoDash pod in a cluster:
8082

8183
....
8284
apiVersion: v1
@@ -108,3 +110,118 @@ spec:
108110
selector:
109111
project: neodash
110112
....
113+
114+
=== To deploy using a Helm Charts
115+
116+
A Kubernetes Helm chart is available in the https://github.com/neo4j-labs/neodash[the NeoDash repository] and here is the full example of the Helm chart values.yaml file,
117+
118+
....
119+
# Name override or full name override
120+
nameOverride: ''
121+
fullnameOverride: neodash-test
122+
123+
# Number of pods
124+
replicaCount: 1
125+
126+
# Image Details
127+
image:
128+
repository: neo4jlabs/neodash
129+
pullPolicy: IfNotPresent
130+
tag: 'latest'
131+
imagePullSecrets: [] # Image pull secret if any
132+
133+
# Pod annotations, labels and security context
134+
podAnnotations: {}
135+
podLabels: {}
136+
podSecurityContext: {}
137+
138+
# Mode configuration using environment variables
139+
# Set reader mode environment variables when enable_reader_mode is true
140+
enable_reader_mode: true
141+
env:
142+
- name: "ssoEnabled"
143+
value: "false"
144+
- name: "standalone"
145+
value: "true"
146+
- name: "standaloneProtocol"
147+
value: "neo4j+s"
148+
- name: "standaloneHost"
149+
value: "localhost"
150+
- name: "standalonePort"
151+
value: "7687"
152+
- name: "standaloneDatabase"
153+
value: neo4j
154+
- name: "standaloneDashboardName"
155+
value: "test"
156+
- name: "standaloneDashboardDatabase"
157+
value: neo4j
158+
- name: "standaloneAllowLoad"
159+
value: "false"
160+
- name: "standaloneLoadFromOtherDatabases"
161+
value: "false"
162+
- name: "standaloneMultiDatabase"
163+
value: "false"
164+
165+
# Environment variable from secret
166+
envFromSecrets: []
167+
# standaloneUsername:
168+
# secretName: "neo4j-connection-secrets"
169+
# key: "username"
170+
# standalonePassword:
171+
# secretName: "neo4j-connection-secrets"
172+
# key: "password"
173+
174+
# Service details
175+
service:
176+
type: LoadBalancer # Can also be ClusterIP or NodePort
177+
port: 5005 # For the service to listen in for Traffic
178+
targetPort: 5005 # Target port is the container port
179+
annotations: {} # Service annotations for the LoadBalance
180+
181+
# Ingress
182+
ingress:
183+
enabled: false # Enable Kubernetes Ingress
184+
className: 'alb' # Class Name
185+
annotations: {} # Cloud LoadBalancer annotations
186+
hosts: []
187+
# - host: neodash.example.com
188+
# paths:
189+
# - path: '/'
190+
# pathType: Prefix
191+
tls: []
192+
193+
# Pod resources request, limits and health check
194+
resources:
195+
requests:
196+
memory: "64Mi"
197+
cpu: "250m"
198+
limits:
199+
memory: "128Mi"
200+
cpu: "500m"
201+
livenessProbe:
202+
httpGet:
203+
path: /*
204+
port: 5005
205+
readinessProbe:
206+
httpGet:
207+
path: /*
208+
port: 5005
209+
210+
# Pod Autoscaler
211+
autoscaling:
212+
enabled: false
213+
# minReplicas: 1
214+
# maxReplicas: 100
215+
# targetCPUUtilizationPercentage: 80
216+
217+
# Pod Volumes
218+
volumes: []
219+
volumeMounts: []
220+
221+
# Service Account
222+
serviceAccount:
223+
create: true
224+
automount: true
225+
# annotations: {}
226+
# name: ''
227+
....

k8s-deploy/neodash/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

k8s-deploy/neodash/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: neodash
3+
description: A NeoDash Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 1.0.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "2.4.9"

k8s-deploy/neodash/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# NeoDash
2+
3+
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.16.0](https://img.shields.io/badge/AppVersion-1.16.0-informational?style=flat-square)
4+
5+
A NeoDash Helm chart for Kubernetes
6+
7+
## Resources
8+
9+
Following are the Kubernetes resources utilized for the NeoDash.
10+
11+
- Deployment
12+
- Service
13+
- Ingress
14+
- Service Account
15+
- Horizontal Pod Autoscalar (HPA)
16+
17+
## Values Configuration
18+
19+
| Key | Type | Default | Description |
20+
|-----|------|---------|-------------|
21+
| autoscaling.enabled | bool | `false` | Enable/disable Autoscaling |
22+
| enable_reader_mode | bool | `true` | Enable/disable Reader mode |
23+
| envFromSecrets | list | `[]` | Environment variables from secrets |
24+
| fullnameOverride | string | `"neodash-test"` | Name override applies to all resources |
25+
| image.pullPolicy | string | `"IfNotPresent"` | Image pull policy |
26+
| image.repository | string | `"neo4jlabs/neodash"` | Image repository and Image name |
27+
| image.tag | string | `"latest"` | Image version |
28+
| imagePullSecrets | list | `[]` | Image pull secrets if any |
29+
| podAnnotations | object | `{}` | Pod annotations |
30+
| podLabels | object | `{}` | Additional labels |
31+
| podSecurityContext | object | `{}` | Security Context if any |
32+
| ingress.annotations | object | `{}` | Ingress Annotations for load balancers |
33+
| ingress.className | string | `"alb"` | Ingress Class |
34+
| ingress.enabled | bool | `false` | Enable/disable Ingress |
35+
| ingress.hosts | list | `[]` | Host Details |
36+
| ingress.tls | list | `[]` | TLS details |
37+
| livenessProbe.httpGet.path | string | `"/*"` | LivenessProbe path |
38+
| livenessProbe.httpGet.port | int | `5005` | LivenessProbe port |
39+
| readinessProbe.httpGet.path | string | `"/*"` | Readiness path |
40+
| readinessProbe.httpGet.port | int | `5005` | Readiness port |
41+
| replicaCount | int | `1` | Replica count |
42+
| resources.limits.cpu | string | `"500m"` | CPU limit |
43+
| resources.limits.memory | string | `"128Mi"` | Memory limit |
44+
| resources.requests.cpu | string | `"250m"` | CPU request |
45+
| resources.requests.memory | string | `"64Mi"` | Memory request |
46+
| service.annotations | object | `{}` | Service annotations |
47+
| service.port | int | `5005` | Service port |
48+
| service.targetPort | int | `5005` | Service target port |
49+
| service.type | string | `"LoadBalancer"` | Type of service, other options are `ClusterIP` or `NodePort` |
50+
| serviceAccount.automount | bool | `true` | Enable/disable service account auto mount to pod |
51+
| serviceAccount.create | bool | `true` | Enable/disable service account |
52+
| volumeMounts | list | `[]` | Volume mounts on pod |
53+
| volumes | list | `[]` | Volumes for pod |
54+
| env | list |<br><pre lang="YAML">- name: "ssoEnabled" &#13; value: "false" &#13;- name: "standalone" &#13; value: "true" &#13;- name: "standaloneProtocol" &#13; value: "neo4j+s" &#13;- name: "standaloneHost" &#13; value: "localhost" &#13;- name: "standalonePort" &#13; value: "7687" &#13;- name: "standaloneDatabase" &#13; value: "neo4j" &#13;- name: "standaloneDashboardName" &#13; value: "test" &#13;- name: "standaloneDashboardDatabase" &#13; value: "neo4j" &#13;- name: "standaloneAllowLoad" &#13; value: "false" &#13;- name: "standaloneLoadFromOtherDatabases" &#13; value: "false" &#13;- name: "standaloneMultiDatabase" &#13; value: "false" &#13;</pre> | Env variables for reader mode |
55+
56+
## Usage
57+
58+
- To install this helm chart run the following command,
59+
60+
```bash
61+
helm install <release-name> ./neodash -n <namespace-name>
62+
```
63+
64+
- To upgrade the release run the following command,
65+
66+
```bash
67+
helm upgrade <release-name> ./neodash -n <namespace-name>
68+
```
69+
70+
- To uninstall the release run the following command,
71+
72+
```bash
73+
helm uninstall <release-name> -n <namespace-name>
74+
```
75+
76+
> **Note:** To use custom values files, pass `-f <path-to-values-file>.yaml` for the above command.
77+
> **Note:** To use custom values, pass `--set param=value` for the above command.
78+
For example, to install neodash and set the service type to NodePort, run: `helm install <release-name> ./neodash -n <namespace-name> --set service.type=NodePort`
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
The NeoDash application has been successfully deployed, here is the application URL:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
Run the following command to retrieve the IP address:
10+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "neodash.fullname" . }})
11+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
12+
echo http://$NODE_IP:$NODE_PORT
13+
{{- else if contains "LoadBalancer" .Values.service.type }}
14+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
15+
You can watch the status of the LoadBalancer by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "neodash.fullname" . }}'
16+
17+
Once available, run the following command to retrieve the IP address:
18+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "neodash.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
19+
echo http://$SERVICE_IP:{{ .Values.service.port }}
20+
{{- else if contains "ClusterIP" .Values.service.type }}
21+
Run the following command to retrieve the IP address:
22+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "neodash.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
23+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
24+
echo "Visit http://127.0.0.1:8080 to use your application"
25+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
26+
{{- end }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "neodash.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "neodash.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "neodash.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "neodash.labels" -}}
37+
helm.sh/chart: {{ include "neodash.chart" . }}
38+
{{ include "neodash.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "neodash.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "neodash.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "neodash.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "neodash.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

0 commit comments

Comments
 (0)