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 support to Postgres (v2) #282

Open
wants to merge 8 commits into
base: main
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
2 changes: 1 addition & 1 deletion .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.7.2
version: v3.15.3

- uses: actions/setup-python@v5
with:
Expand Down
6 changes: 5 additions & 1 deletion 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.2.4
version: 1.2.6
appVersion: 2.1.55
keywords:
- dragonfly
Expand Down Expand Up @@ -57,3 +57,7 @@ dependencies:
version: 19.5.5
repository: https://charts.bitnami.com/bitnami
condition: redis.enable
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 15.3.3
condition: postgresql.enable
18 changes: 18 additions & 0 deletions charts/dragonfly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ 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 | `false` | Running GORM migration. |
| externalPostgresql.password | string | `"dragonfly"` | External postgresql password. |
| externalPostgresql.port | int | `5432` | External postgresql port. |
| externalPostgresql.sslMode | string | `"disable"` | External postgresql ssl mode. |
| 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 @@ -342,6 +349,16 @@ helm delete dragonfly --namespace dragonfly-system
| mysql.primary.service.port | int | `3306` | Mysql port. |
| nameOverride | string | `""` | Override dragonfly name. |
| namespaceOverride | string | `""` | Override dragonfly namespace. |
| postgresql.auth.database | string | `"manager"` | Create dragonfly manager db. |
| postgresql.auth.enablePostgresUser | bool | `true` | |
| postgresql.auth.password | string | `"dragonfly"` | |
| postgresql.auth.postgresPassword | string | `"dragonfly"` | |
| postgresql.auth.username | string | `"dragonfly"` | Create dragonfly user. |
| postgresql.clusterDomain | string | `"cluster.local"` | Cluster domain. |
| postgresql.enable | bool | `false` | Enable postgresql with docker container. |
| postgresql.migrate | bool | `true` | Running GORM migration. |
| postgresql.primary.persistence.enabled | bool | `true` | |
| postgresql.primary.service.port | int | `5432` | postgresql port. |
| redis.auth.enabled | bool | `true` | Enable password authentication. |
| redis.auth.password | string | `"dragonfly"` | Redis password. |
| redis.clusterDomain | string | `"cluster.local"` | Cluster domain. |
Expand Down Expand Up @@ -539,4 +556,5 @@ helm delete dragonfly --namespace dragonfly-system
| Repository | Name | Version |
|------------|------|---------|
| https://charts.bitnami.com/bitnami | mysql | 10.1.1 |
| https://charts.bitnami.com/bitnami | postgresql | 15.3.3 |
| https://charts.bitnami.com/bitnami | redis | 19.5.5 |
26 changes: 25 additions & 1 deletion charts/dragonfly/templates/manager/manager-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ data:
auth:
{{ toYaml .Values.manager.config.auth | indent 6 }}
database:
{{- if or .Values.mysql.enable .Values.externalMysql.host }}
type: mysql
mysql:
{{- if and .Values.mysql.enable (empty .Values.externalMysql.host)}}
{{- if and .Values.mysql.enable (empty .Values.externalMysql.host) }}
user: {{ .Values.mysql.auth.username }}
password: {{ .Values.mysql.auth.password }}
host: {{ .Release.Name }}-{{ default "mysql" .Values.mysql.fullname }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
Expand All @@ -48,6 +50,28 @@ data:
dbname: {{ .Values.externalMysql.database }}
migrate: {{ .Values.externalMysql.migrate }}
{{- end }}
{{- end }}
{{- if or .Values.postgresql.enable .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 }}
sslMode: {{ .Values.externalPostgresql.sslMode }}
{{- end }}
timezone: UTC
{{- end }}
redis:
{{- if .Values.redis.enable }}
addrs:
Expand Down
8 changes: 7 additions & 1 deletion charts/dragonfly/templates/manager/manager-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ spec:
hostAliases:
{{ toYaml .Values.manager.hostAliases | indent 8 }}
{{- end }}
{{- if or .Values.redis.enable .Values.mysql.enable }}
{{- if or .Values.redis.enable .Values.mysql.enable .Values.postgresql.enable}}
initContainers:
{{- if .Values.redis.enable }}
- name: wait-for-redis
Expand All @@ -83,6 +83,12 @@ spec:
resources:
{{ toYaml .Values.manager.initContainer.resources | indent 12 }}
{{- end }}
{{- if .Values.postgresql.enable }}
- name: wait-for-postgresql
image: {{ template "manager.initContainer.image" . }}
imagePullPolicy: {{ .Values.manager.initContainer.image.pullPolicy }}
command: ['sh', '-c', 'until nslookup {{ .Release.Name }}-{{ default "postgresql" .Values.postgresql.fullname }}.{{ $.Release.Namespace }}.svc.{{ $.Values.clusterDomain }} && nc -vz {{ .Release.Name }}-{{ default "postgresql" .Values.postgresql.fullname }}.{{ $.Release.Namespace }}.svc.{{ $.Values.clusterDomain }} {{ .Values.postgresql.primary.service.port }}; do echo waiting for postgresql; sleep 2; done;']
{{- end }}
{{- end }}
containers:
- name: manager
Expand Down
39 changes: 39 additions & 0 deletions charts/dragonfly/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,45 @@ 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 ssl mode.
sslMode: disable
# -- External postgresql port.
port: 5432

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