Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable to use external postgresql #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

# Match any file or path named .git
.git
Chart.lock

6 changes: 0 additions & 6 deletions Chart.lock

This file was deleted.

4 changes: 2 additions & 2 deletions Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.3.4
version: 0.3.5

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand All @@ -27,4 +27,4 @@ dependencies:
- name: "postgresql-ha"
version: "7.11.0"
repository: https://charts.bitnami.com/bitnami
condition: postgresql-ha.enabled
condition: database.internal
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,17 @@ This will also require specifying a service address for DNS. Choose a valid ipv4
| nameOverride | string | `""` | override the name for netmaker objects |
| podAnnotations | object | `{}` | pod annotations to add |
| podSecurityContext | object | `{}` | pod security contect to add |
| database.internal | bool | `true` | internal or external postgresql |
| postgresql-ha.persistence.size | string | `"3Gi"` | size of postgres DB |
| postgresql-ha.postgresql.database | string | `"netmaker"` | postgress db to generate |
| postgresql-ha.postgresql.password | string | `"netmaker"` | postgres pass to generate |
| postgresql-ha.postgresql.username | string | `"netmaker"` | postgres user to generate |
| postgresql-ha.postgresql.containerPorts.postgresql | int | `5432` | postgres port |
| external-postgresql.host | string | `"external.postgres.url"` | external postgres host |
| external-postgresql.port | int | `5432` | external postgres port |
| external-postgresql.database | string | `"netmaker"` | external postgress db |
| external-postgresql.password | string | `"netmaker"` | external postgres pass |
| external-postgresql.username | string | `"netmaker"` | external postgres user |
| replicas | int | `3` | number of netmaker server replicas to create |
| service.mqPort | int | `443` | public port for MQ service |
| service.restPort | int | `8081` | port for API service |
Expand Down
55 changes: 55 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,58 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Username for postgresql
*/}}
{{- define "netmaker.database.username" -}}
{{- if .Values.database.internal }}
{{- index .Values "postgresql-ha" "postgresql" "username" }}
{{- else }}
{{- index .Values "external-postgresql" "username" }}
{{- end }}
{{- end }}

{{/*
Password for postgresql
*/}}
{{- define "netmaker.database.password" -}}
{{- if .Values.database.internal }}
{{- index .Values "postgresql-ha" "postgresql" "password" }}
{{- else }}
{{- index .Values "external-postgresql" "password" }}
{{- end }}
{{- end }}

{{/*
Host for postgresql
*/}}
{{- define "netmaker.database.host" -}}
{{- if .Values.database.internal }}
{{- .Release.Name }}-postgresql-ha-pgpool.{{ .Release.Namespace }}
{{- else }}
{{- index .Values "external-postgresql" "host" }}
{{- end }}
{{- end }}

{{/*
Port for postgresql
*/}}
{{- define "netmaker.database.port" -}}
{{- if .Values.database.internal }}
{{- index .Values "postgresql-ha" "postgresql" "containerPorts" "postgresql" }}
{{- else }}
{{- index .Values "external-postgresql" "port" }}
{{- end }}
{{- end }}

{{/*
Database for postgresql
*/}}
{{- define "netmaker.database.database" -}}
{{- if .Values.database.internal }}
{{- index .Values "postgresql-ha" "postgresql" "database" }}
{{- else }}
{{- index .Values "external-postgresql" "database" }}
{{- end }}
{{- end }}
36 changes: 36 additions & 0 deletions templates/confgmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "netmaker.fullname" . }}
labels:
{{- include "netmaker.labels" . | nindent 4 }}
data:
SERVER_NAME: broker.{{ required "A valid .Values.baseDomain entry required!" .Values.baseDomain}}
SERVER_API_CONN_STRING: api.{{ required "A valid .Values.baseDomain entry required!" .Values.baseDomain}}:443
SERVER_HTTP_HOST: api.{{ required "A valid .Values.baseDomain entry required!" .Values.baseDomain}}
API_PORT: "8081"
{{- if not .Values.wireguard.kernel }}
WG_QUICK_USERSPACE_IMPLEMENTATION: wireguard-go
{{- end }}
{{- if .Values.dns.enabled }}
DNS_MODE: "on"
COREDNS_ADDR: {{ required "A valid .Values.dns.clusterIP entry required! Choose an IP from your k8s service IP CIDR" .Values.dns.clusterIP }}
{{- else }}
DNS_MODE: "off"
{{- end }}
CLIENT_MODE: "on"
MASTER_KEY: {{ include "netmaker.masterKey" . }}
CORS_ALLOWED_ORIGIN: '*'
SQL_HOST: "{{ include "netmaker.database.host" . }}"
SQL_PORT: "{{ include "netmaker.database.port" . }}"
SQL_DB: "{{ include "netmaker.database.database" . }}"
SQL_USER: "{{ include "netmaker.database.username" . }}"
SQL_PASS: "{{ include "netmaker.database.password" . }}"
DATABASE: postgres
DISPLAY_KEYS: "on"
MQ_HOST: {{ include "netmaker.fullname" . }}-mqtt
MQ_PORT: "{{ .Values.service.mqPort }}"
MQ_SERVER_PORT: "1883"
MQ_ADMIN_PASSWORD: {{ .Values.mq.password }}
PLATFORM: "Kubernetes"
VERBOSITY: "3"
2 changes: 1 addition & 1 deletion templates/mq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ spec:
name: wait-script
- name: shared-data
persistentVolumeClaim:
{{- if not .Values.mq.existingClaim }}
{{- if .Values.mq.existingClaim }}
claimName: {{ .Values.mq.existingClaim }}
{{- else }}
claimName: {{ include "netmaker.fullname" . }}-shared-data-pvc
Expand Down
60 changes: 3 additions & 57 deletions templates/netmaker-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,68 +36,14 @@ spec:
topologyKey: "kubernetes.io/hostname"
containers:
- env:
- name: SERVER_NAME
value: broker.{{ required "A valid .Values.baseDomain entry required!" .Values.baseDomain}}
- name: SERVER_API_CONN_STRING
value: api.{{ required "A valid .Values.baseDomain entry required!" .Values.baseDomain}}:443
- name: SERVER_HTTP_HOST
value: api.{{ required "A valid .Values.baseDomain entry required!" .Values.baseDomain}}
- name: API_PORT
value: "8081"
{{- if not .Values.wireguard.kernel }}
- name: WG_QUICK_USERSPACE_IMPLEMENTATION
value: wireguard-go
{{- end }}
{{- if .Values.dns.enabled }}
- name: DNS_MODE
value: "on"
- name: COREDNS_ADDR
value: {{ required "A valid .Values.dns.clusterIP entry required! Choose an IP from your k8s service IP CIDR" .Values.dns.clusterIP }}
{{- else }}
- name: DNS_MODE
value: "off"
{{- end }}
- name: CLIENT_MODE
value: "on"
- name: MASTER_KEY
value: {{ include "netmaker.masterKey" . }}
- name: CORS_ALLOWED_ORIGIN
value: '*'
- name: NODE_ID
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: SQL_HOST
{{- if index .Values "postgresql-ha" "enabled" }}
value: '{{ .Release.Name }}-postgresql-ha-pgpool.{{ .Release.Namespace }}.svc.cluster.local'
{{- else }}
value: {{ .Values.wireguard.dbHost }}
{{- end }}
- name: SQL_PORT
value: "5432"
- name: SQL_DB
value: {{ index .Values "postgresql-ha" "postgresql" "database" }}
- name: SQL_USER
value: {{ index .Values "postgresql-ha" "postgresql" "username" }}
- name: SQL_PASS
value: {{ index .Values "postgresql-ha" "postgresql" "password" }}
- name: DATABASE
value: postgres
- name: DISPLAY_KEYS
value: "on"
- name: MQ_HOST
value: {{ include "netmaker.fullname" . }}-mqtt
- name: MQ_PORT
value: "{{ .Values.service.mqPort }}"
- name: MQ_SERVER_PORT
value: "1883"
- name: MQ_ADMIN_PASSWORD
value: {{ .Values.mq.password }}
- name: PLATFORM
value: "Kubernetes"
- name: VERBOSITY
value: "3"
envFrom:
- configMapRef:
name: {{ include "netmaker.fullname" . }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
name: {{ include "netmaker.fullname" . }}
Expand Down
24 changes: 23 additions & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# -- number of netmaker server replicas to create
replicas: 3

baseDomain: netmaker.org

image:
# -- The image repo to pull Netmaker image from
repository: gravitl/netmaker
Expand Down Expand Up @@ -44,6 +46,7 @@ mq:
singlenode: false
storageSize: 128Mi
password: 3yyerWGdds43yegGR
# existingClaim:
RWX:
storageClassName: ""

Expand All @@ -70,6 +73,7 @@ service:
ingress:
# -- attempts to configure ingress if true
enabled: true
className: "nginx"
tls:
enabled: false
issuerName: "letsencrypt-prod"
Expand Down Expand Up @@ -114,17 +118,35 @@ wireguard:
# -- max number of networks that Netmaker will support if running with WireGuard enabled
networkLimit: 10

# -- which database will be use
database:
internal: true

# -- internal database
postgresql-ha:
enabled: true
postgresql:
# -- postgres user to generate
username: netmaker
# -- postgres pass to generate
password: netmaker
# -- postgress db to generate
database: netmaker
containerPorts:
postgresql: 5432
# -- postgress number of replicas to deploy
replicaCount: 2
persistence:
# -- size of postgres DB
size: 1Gi

external-postgresql:
# -- postgres host
host: external.postgres.url
# -- postgres hosts port
port: 5432
# -- postgres username
username: netmaker
# -- postgres pass
password: netmaker
# -- postgress db
database: netmaker