Skip to content

Commit

Permalink
Issue #00 fix: helm chart nodebb deployment (#1849)
Browse files Browse the repository at this point in the history
nodebb variables
  • Loading branch information
harshavardhanc authored Aug 31, 2020
1 parent 57f577b commit d2ef514
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 0 deletions.
1 change: 1 addition & 0 deletions ansible/roles/stack-sunbird/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ service_env:
- ../../../../ansible/roles/stack-sunbird/templates/taxonomy-service_logback.xml
report: ../../../../ansible/roles/stack-sunbird/templates/sunbird_report-service.env
telemetry-dp-logstash: ../../../../ansible/roles/stack-sunbird/templates/telemetry-logstash-datapipeline.conf
nodebb: ../../../../ansible/roles/stack-sunbird/templates/sunbird_nodebb.env
analytics: ../../../../ansible/roles/stack-sunbird/templates/analytics_api_service.conf

sunbird_portal_player_cdn_enabled: false
Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/stack-sunbird/templates/sunbird_nodebb.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sunbird_nodebb_url=https://{{ domain_name }}/discussions
redis_nodebb_host="{{ groups['redis-nodebb'][0]}}"
18 changes: 18 additions & 0 deletions kubernetes/helm_charts/core/nginx-public-ingress/values.j2
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,24 @@ proxyconfig: |
proxy_set_header X-Request-ID $sb_request_id;
proxy_pass $target;
}

location /discussions/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;

# Socket.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
set $target http://nodebb-service.{{ namespace }}.svc.cluster.local:4567;
#rewrite ^/discussions/(.*) /$1 break;
proxy_pass $target;
}

location ~* ^/assets/public/(.*) {
# Enabling cache for Response code 200
expires 1M;
Expand Down
22 changes: 22 additions & 0 deletions kubernetes/helm_charts/core/nodebb/.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/
5 changes: 5 additions & 0 deletions kubernetes/helm_charts/core/nodebb/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: nodebb
version: 0.1.0
45 changes: 45 additions & 0 deletions kubernetes/helm_charts/core/nodebb/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "print.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 "print.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 "print.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "print.labels" -}}
app.kubernetes.io/name: {{ include "print.name" . }}
helm.sh/chart: {{ include "print.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file will get replaced at runtime
81 changes: 81 additions & 0 deletions kubernetes/helm_charts/core/nodebb/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Chart.Name }}
namespace: {{ .Values.namespace }}
annotations:
reloader.stakater.com/auto: "true"
spec:
replicas: {{ .Values.replicaCount }}
strategy:
rollingUpdate:
maxSurge: {{ .Values.strategy.maxsurge }}
maxUnavailable: {{ .Values.strategy.maxunavailable }}
selector:
matchLabels:
app: {{ .Chart.Name }}
template:
metadata:
labels:
app: {{ .Chart.Name }}
spec:
volumes:
- name: nodebb-config-json
configMap:
name: nodebb-config-json
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.dockerhub }}/{{ .Values.repository }}:{{ .Values.image_tag }}"
imagePullPolicy: Always
volumeMounts:
- name: nodebb-config-json
mountPath: /usr/src/app/config.json
subPath: config.json
resources:
{{ toYaml .Values.resources | indent 10 }}
ports:
- containerPort: {{ .Values.network.port }}
{{- if .Values.healthcheck }}
livenessProbe:
{{ toYaml .Values.livenessProbe | indent 10 }}
readinessProbe:
{{ toYaml .Values.readinessProbe | indent 10 }}
{{- end }}

---
apiVersion: v1
kind: ConfigMap
metadata:
name: nodebb-config-json
data:
config.json: |-
{
"url": "{{ .Values.nodebb_url }}",
"secret": "100101",
"database": "redis",
"port": "4567",
"redis": {
"host": "{{ .Values.redis_nodebb_host }}",
"port": 6379,
"username": "",
"password": "",
"database": "0"
}
}
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Chart.Name }}-service
namespace: {{ .Values.namespace }}
labels:
app: {{ .Chart.Name }}
spec:
ports:
- name: http-{{ .Chart.Name }}
protocol: TCP
port: {{ .Values.network.port }}
selector:
app: {{ .Chart.Name }}
27 changes: 27 additions & 0 deletions kubernetes/helm_charts/core/nodebb/values.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#jinja2:lstrip_blocks: True

### Default variable file for nodebb-service ###

namespace: {{ namespace }}
imagepullsecrets: {{ imagepullsecrets }}
dockerhub: nodebb

replicaCount: {{nodebb_replicacount|default(1)}}
repository: 'docker'
image_tag: v1.13.4-5
resources:
requests:
cpu: {{nodebb_cpu_req|default('50m')}}
memory: {{nodebb_mem_req|default('50Mi')}}
limits:
cpu: {{nodebb_cpu_limit|default('1')}}
memory: {{nodebb_mem_limit|default('1024Mi')}}
network:
port: 4567
strategy:
type: RollingUpdate
maxsurge: {{ nodebb_maxsurge|default('25%') }}
maxunavailable: {{ nodebb_maxunavailable|default('25%') }}

nodebb_url: {{ sunbird_nodebb_url }}
redis_nodebb_host: {{ redis_nodebb_host }}

0 comments on commit d2ef514

Please sign in to comment.