Skip to content

Commit

Permalink
added support to plugin an external sql database
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Meadows <[email protected]>
  • Loading branch information
Tom Meadows committed Feb 14, 2022
1 parent 980e072 commit cf12106
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 65 deletions.
2 changes: 1 addition & 1 deletion charts/dependency-track/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
- name: postgresql
version: ~10.10
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
condition: database.internal.enabled
- name: common
version: 1.9.x
repository: https://charts.bitnami.com/bitnami
140 changes: 82 additions & 58 deletions charts/dependency-track/templates/backend/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,65 +24,89 @@ spec:
initContainers: {{- toYaml . | nindent 6 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}-apiserver
securityContext: {{- toYaml .Values.apiserver.securityContext | nindent 12 }}
image: {{ include "apiserver.image" . }}
imagePullPolicy: {{ .Values.apiserver.image.pullPolicy }}
{{- with .Values.apiserver.resources }}
resources: {{ . | toYaml | nindent 10 }}
{{- end }}
env:
- name: ALPINE_DATA_DIRECTORY
value: "/data"
{{- if .Values.postgresql.enabled }}
- name: ALPINE_DATABASE_MODE
value: "external"
- name: ALPINE_DATABASE_DRIVER
value: "org.postgresql.Driver"
- name: ALPINE_DATABASE_URL
value: jdbc:postgresql://{{ .Release.Name }}-postgresql/{{ .Values.postgresql.postgresqlDatabase }}
- name: ALPINE_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-postgresql
key: postgresql-password
- name: ALPINE_DATABASE_USERNAME
value: {{ .Values.postgresql.postgresqlUsername }}
{{- end }}
{{- with .Values.apiserver.env }}
{{- toYaml . | nindent 8 }}
{{- end }}
volumeMounts:
- name: data
mountPath: /data
- name: tmp
mountPath: /tmp
ports:
- name: api
containerPort: 8080
protocol: TCP
{{- if .Values.apiserver.livenessProbe.enabled }}
livenessProbe:
httpGet:
port: api
path: {{ .Values.apiserver.livenessProbe.path }}
initialDelaySeconds: {{ .Values.apiserver.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.apiserver.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.apiserver.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.apiserver.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.apiserver.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.apiserver.livenessProbe.enabled }}
readinessProbe:
httpGet:
port: api
path: {{ .Values.apiserver.readinessProbe.path }}
initialDelaySeconds: {{ .Values.apiserver.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.apiserver.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.apiserver.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.apiserver.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.apiserver.readinessProbe.failureThreshold }}
- name: {{ .Chart.Name }}-apiserver
securityContext: {{- toYaml .Values.apiserver.securityContext | nindent 12 }}
image: {{ include "apiserver.image" . }}
imagePullPolicy: {{ .Values.apiserver.image.pullPolicy }}
{{- with .Values.apiserver.resources }}
resources: {{ . | toYaml | nindent 12 }}
{{- end }}
env:
- name: ALPINE_DATA_DIRECTORY
value: "/data"
{{- if eq .Values.database.internal.enabled true }}
- name: ALPINE_DATABASE_MODE
value: "external"
- name: ALPINE_DATABASE_DRIVER
value: "org.postgresql.Driver"
- name: ALPINE_DATABASE_URL
value: jdbc:postgresql://{{ .Release.Name }}-postgresql/{{ .Values.database.internal.postgresql.database }}
- name: ALPINE_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-postgresql
key: postgresql-password
- name: ALPINE_DATABASE_USERNAME
value: {{ .Values.database.internal.postgresql.username }}
{{- else if eq .Values.database.external.enabled true }}
- name: ALPINE_DATABASE_MODE
value: {{ .Values.database.external.databaseMode}}
- name: ALPINE_DATABASE_DRIVER
value: {{ .Values.database.external.databaseDriver}}
- name: ALPINE_DATABASE_URL
value: {{ .Values.database.external.databaseURL}}
- name: ALPINE_DATABASE_USERNAME
value: {{ .Values.database.external.databaseUsername }}
- name: ALPINE_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.databaseUserPassword.secretName }}
key: {{ .Values.database.external.databaseUserPassword.secretKey }}
{{- end }}
{{- with .Values.apiserver.env }}
{{- toYaml . | nindent 8 }}
{{- end }}
volumeMounts:
- name: data
mountPath: /data
- name: tmp
mountPath: /tmp
ports:
- name: api
containerPort: 8080
protocol: TCP
{{- if .Values.apiserver.livenessProbe.enabled }}
livenessProbe:
httpGet:
port: api
path: {{ .Values.apiserver.livenessProbe.path }}
initialDelaySeconds: {{ .Values.apiserver.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.apiserver.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.apiserver.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.apiserver.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.apiserver.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.apiserver.livenessProbe.enabled }}
readinessProbe:
httpGet:
port: api
path: {{ .Values.apiserver.readinessProbe.path }}
initialDelaySeconds: {{ .Values.apiserver.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.apiserver.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.apiserver.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.apiserver.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.apiserver.readinessProbe.failureThreshold }}
{{- end }}
{{- if .Values.apiserver.sidecarContainers }}
{{- range $name, $spec := .Values.apiserver.sidecarContainers }}
- name: {{ $name }}
{{- if kindIs "string" $spec }}
{{- tpl $spec $ | nindent 10 }}
{{- else }}
{{- toYaml $spec | nindent 10 }}
{{- end }}
{{- end }}
{{- end }}
{{- with .Values.apiserver.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
35 changes: 29 additions & 6 deletions charts/dependency-track/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ frontend:
# -- config of the apiserver
apiserver:
enabled: true
# sidecarContainers - add more containers to the api-server (e.g. Google Cloud SQL Proxy)
# Key/Value where Key is the sidecar `- name: <Key>`
# Example:
# sidecarContainers:
# cloud-sql-proxy:
# image: gcr.io/cloudsql-docker/gce-proxy:1.23.0
sidecarContainers: {}
# Max: 1 - DT is not designed for HA
replicaCount: 1
image:
Expand Down Expand Up @@ -170,9 +177,25 @@ ingress:
host: chart-example.local
# ingressClassName: nginx

# -- configuration of postgres
postgresql:
enabled: true
postgresqlUsername: deptrack
postgresqlPassword: deptrack
postgresqlDatabase: deptrack
# "internal" currently only supports postgres
# -- configuration of SQL database setup as a Kubernetes deployment
internal:
enabled: false
postgresql:
username: deptrack
password: deptrack
database: deptrack

# -- configuration of database
database:
external:
enabled: false
# Please see variable definitions here https://docs.dependencytrack.org/getting-started/configuration/
databaseMode: "external"
databaseDriver: "org.postgresql.Driver"
databaseURL: ""
databaseUsername: ""
# Store the database user password in a Kubernetes Secret
databaseUserPassword:
secretName: ""
secretKey: ""

0 comments on commit cf12106

Please sign in to comment.