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

Add postgresql database support #200

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 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
11 changes: 8 additions & 3 deletions charts/dragonfly/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: dragonfly
description: Dragonfly is an intelligent P2P based image and file distribution system
icon: https://raw.githubusercontent.com/dragonflyoss/Dragonfly2/main/docs/images/logo/dragonfly.svg
type: application
version: 1.1.9
version: 1.1.10
appVersion: 2.1.16
keywords:
- dragonfly
Expand All @@ -26,8 +26,9 @@ sources:

annotations:
artifacthub.io/changes: |
- Add syncPeers configuration to manager.
- Update dragonfly image tag to v2.1.16.
- Add postgresql database config.
- Fix dfdaemon seedPeer configmap.
- Fix containerd injectConfig error

artifacthub.io/links: |
- name: Chart Source
Expand Down Expand Up @@ -59,3 +60,7 @@ dependencies:
version: 0.66.1
repository: https://jaegertracing.github.io/helm-charts
condition: jaeger.enable
- condition: postgresql.enable
name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 13.1.5
15 changes: 15 additions & 0 deletions charts/dragonfly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ helm delete dragonfly --namespace dragonfly-system
| externalMysql.password | string | `"dragonfly"` | External mysql password. |
| externalMysql.port | int | `3306` | External mysql port. |
| externalMysql.username | string | `"dragonfly"` | External mysql username. |
| externalPostgresql.database | string | `"manager"` | External postgresql database name. |
| externalPostgresql.host | string | `nil` | External postgresql hostname. |
| externalPostgresql.migrate | bool | `true` | Running GORM migration. |
| externalPostgresql.password | string | `"dragonfly"` | External postgresql password. |
| externalPostgresql.port | int | `5432` | External postgresql port. |
| externalPostgresql.username | string | `"dragonfly"` | External postgresql username. |
| externalRedis.addrs | list | `["redis.example.com:6379"]` | External redis server addresses. |
| externalRedis.backendDB | int | `2` | External redis backend db. |
| externalRedis.brokerDB | int | `1` | External redis broker db. |
Expand Down Expand Up @@ -369,6 +375,14 @@ helm delete dragonfly --namespace dragonfly-system
| mysql.enable | bool | `true` | Enable mysql with docker container. |
| mysql.migrate | bool | `true` | Running GORM migration. |
| mysql.primary.service.port | int | `3306` | Mysql port. |
| postgresql.auth.database | string | `"manager"` | postgresql database name. |
| postgresql.auth.host | string | `""` | postgresql hostname. |
| postgresql.auth.password | string | `"dragonfly"` | postgresql password. |
| postgresql.auth.postgresPassword | string | `"dragonfly"` | postgresql root password. |
| postgresql.auth.username | string | `"dragonfly"` | postgresql username. |
| postgresql.enable | bool | `true` | Enable postgresql with docker container. |
| postgresql.migrate | bool | `true` | Running GORM migration. |
| postgresql.primary.service.port | int | `5432` | postgresql port. |
| nameOverride | string | `""` | Override dragonfly name. |
| redis.auth.enabled | bool | `true` | Enable password authentication. |
| redis.auth.password | string | `"dragonfly"` | Redis password. |
Expand Down Expand Up @@ -641,5 +655,6 @@ helm delete dragonfly --namespace dragonfly-system
| Repository | Name | Version |
|------------|------|---------|
| https://charts.bitnami.com/bitnami | mysql | 9.4.6 |
| https://charts.bitnami.com/bitnami | postgresql | 13.1.5 |
| https://charts.bitnami.com/bitnami | redis | 17.4.3 |
| https://jaegertracing.github.io/helm-charts | jaeger | 0.66.1 |
4 changes: 2 additions & 2 deletions charts/dragonfly/templates/dfdaemon/dfdaemon-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ data:
addr: {{ .Values.externalManager.host }}:{{ .Values.externalManager.grpcPort }}
{{- end }}
refreshInterval: {{ .Values.dfdaemon.config.scheduler.manager.refreshInterval }}
seedPeer:
{{ toYaml .Values.dfdaemon.config.scheduler.manager.seedPeer | indent 10 }}
netAddrs:
{{- if and (not .Values.dfdaemon.config.scheduler.manager.enable) (.Values.dfdaemon.config.scheduler.netAddrs) }}
{{ toYaml .Values.dfdaemon.config.scheduler.netAddrs | indent 8 }}
{{- end }}
scheduleTimeout: {{ .Values.dfdaemon.config.scheduler.scheduleTimeout }}
disableAutoBackSource: {{ .Values.dfdaemon.config.scheduler.disableAutoBackSource }}
seedPeer:
{{ toYaml .Values.dfdaemon.config.scheduler.manager.seedPeer | indent 8 }}
host:
{{ toYaml .Values.dfdaemon.config.host | indent 6 }}
download:
Expand Down
5 changes: 3 additions & 2 deletions charts/dragonfly/templates/dfdaemon/dfdaemon-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,12 @@ spec:
else
echo config_path is enabled, add mirror in $config_path
# TODO check whether config_path is enabled, if not, add it
tmp=$(cat $etcContainerd/{{ default "config.toml" .Values.containerRuntime.containerd.configFileName }} | tr '"' ' ' | grep config_path | awk '{print $3}')
tmp=$(cat $etcContainerd/{{ default "config.toml" .Values.containerRuntime.containerd.configFileName }} | tr '"' ' ' | grep config_path | grep -v nri | awk '{print $3}')
if [[ -z "$tmp" ]]; then
echo inject config_path into $etcContainerd/{{ default "config.toml" .Values.containerRuntime.containerd.configFileName }}
if grep -q '\[plugins."io.containerd.grpc.v1.cri".registry\]' $etcContainerd/{{ default "config.toml" .Values.containerRuntime.containerd.configFileName }}; then
sed -i 's|\[plugins."io.containerd.grpc.v1.cri".registry\]|\[plugins."io.containerd.grpc.v1.cri".registry\]\nconfig_path = "{{ .Values.containerRuntime.containerd.configPathDir }}/certs.d"|g' $etcContainerd/{{ default "config.toml" .Values.containerRuntime.containerd.configFileName }}
line_number=$(grep -n '\[plugins\."io\.containerd\.grpc\.v1\.cri"\.registry\]' $etcContainerd/{{ default "config.toml" .Values.containerRuntime.containerd.configFileName }} | cut -d ':' -f 1)
sed -i "$((line_number+1))s|config_path = \"\"|config_path = \"{{ .Values.containerRuntime.containerd.configPathDir }}/certs.d\"|" $etcContainerd/{{ default "config.toml" .Values.containerRuntime.containerd.configFileName }}
else
cat << EOF >> $etcContainerd/{{ default "config.toml" .Values.containerRuntime.containerd.configFileName }}
[plugins."io.containerd.grpc.v1.cri".registry]
Expand Down
23 changes: 23 additions & 0 deletions charts/dragonfly/templates/manager/manager-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ data:
auth:
{{ toYaml .Values.manager.config.auth | indent 6 }}
database:
{{- if and .Values.mysql.enable (empty .Values.externalMysql.host)}}
type: mysql
mysql:
{{- if and .Values.mysql.enable (empty .Values.externalMysql.host)}}
user: {{ .Values.mysql.auth.username }}
Expand All @@ -48,6 +50,27 @@ data:
dbname: {{ .Values.externalMysql.database }}
migrate: {{ .Values.externalMysql.migrate }}
{{- end }}
{{- end }}
{{- if and .Values.postgresql.enable (empty .Values.externalPostgresql.host)}}
type: postgres
postgres:
{{- if and .Values.postgresql.enable (empty .Values.externalPostgresql.host)}}
user: {{ .Values.postgresql.auth.username }}
password: {{ .Values.postgresql.auth.password }}
host: {{ .Release.Name }}-{{ default "postgresql" .Values.postgresql.fullname }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
port: {{ .Values.postgresql.primary.service.port }}
dbname: {{ .Values.postgresql.auth.database }}
migrate: {{ .Values.postgresql.migrate }}
{{- else }}
user: {{ .Values.externalPostgresql.username }}
password: {{ .Values.externalPostgresql.password }}
host: {{ .Values.externalPostgresql.host }}
port: {{ .Values.externalPostgresql.port }}
dbname: {{ .Values.externalPostgresql.database }}
migrate: {{ .Values.externalPostgresql.migrate }}
{{- end }}
timezone: UTC
{{- end }}
redis:
{{- if .Values.redis.enable }}
addrs:
Expand Down
37 changes: 37 additions & 0 deletions charts/dragonfly/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,43 @@ externalMysql:
# -- External mysql port.
port: 3306

postgresql:
# -- Enable postgresql with docker container.
enable: false
# -- Cluster domain.
clusterDomain: "cluster.local"
# -- Running GORM migration.
migrate: true
auth:
enablePostgresUser: true
postgresPassword: "dragonfly"
# -- Create dragonfly user.
username: "dragonfly"
password: "dragonfly"
# -- Create dragonfly manager db.
database: "manager"
primary:
service:
# -- postgresql port.
port: 5432
persistence:
enabled: true
# storageClass: ""

externalPostgresql:
# -- Running GORM migration.
migrate: false
# -- External postgresql hostname.
host:
# -- External postgresql username.
username: dragonfly
# -- External postgresql password.
password: dragonfly
# -- External postgresql database name.
database: manager
# -- External postgresql port.
port: 5432

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank lines.

redis:
# -- Enable redis cluster with docker container.
enable: true
Expand Down
Loading