Skip to content

Commit

Permalink
add option to configure connMaxLifetime and connMaxIdleTime.
Browse files Browse the repository at this point in the history
Signed-off-by: Vadim Bauer <[email protected]>
  • Loading branch information
Vad1mo committed Jun 5, 2024
1 parent f547605 commit 6f2691b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ The following table lists the configurable parameters of the Harbor chart and th
| `database.external.sslmode` | Connection method of external database (require, verify-full, verify-ca, disable) | `disable` |
| `database.maxIdleConns` | The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained. | `50` |
| `database.maxOpenConns` | The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections. | `100` |
| `database.connMaxIdleTime` | Terminate any session that has been idle (that is, waiting for a client query), but not within an open transaction, for longer than the specified amount of time. See PG documentation [GUC-IDLE-SESSION-TIMEOUT](https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-IDLE-SESSION-TIMEOUT) | `0s` |
| `database.connMaxLifetime` | The total maximum lifetime of connections. Connections which have exceeded this value will be destroyed instead of returned from the pool. This is useful in clustered configurations to force load balancing between a running server and a server just brought online. | `5m` |
| `database.podAnnotations` | Annotations to add to the database pod | `{}` |
| **Redis** | | |
| `redis.type` | If external redis is used, set it to `external` | `internal` |
Expand Down Expand Up @@ -375,6 +377,10 @@ The following table lists the configurable parameters of the Harbor chart and th
| `exporter.cacheDuration` | the cache duration for information that exporter collected from Harbor | `30` |
| `exporter.cacheCleanInterval` | cache clean interval for information that exporter collected from Harbor | `14400` |
| `exporter.priorityClassName` | The priority class to run the pod as | |
| `exporter.override.database.maxIdleConns` | Override the global setting of the maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained. | `` |
| `exporter.override.database.maxOpenConns` | Override the global setting of the maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections. | `` |
| `exporter.override.database.connMaxIdleTime` | Override the global setting of idle session termination (that is, waiting for a client query), but not within an open transaction, for longer than the specified amount of time. See PG documentation [GUC-IDLE-SESSION-TIMEOUT](https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-IDLE-SESSION-TIMEOUT) | `` |
| `exporter.override.database.connMaxLifetime` | Override the global setting of The total maximum lifetime of connections. Connections which have exceeded this value will be destroyed instead of returned from the pool. This is useful in clustered configurations to force load balancing between a running server and a server just brought online. | `` |
| **Metrics** | | |
| `metrics.enabled` | if enable harbor metrics | `false` |
| `metrics.core.path` | the url path for core metrics | `/metrics` |
Expand Down
4 changes: 3 additions & 1 deletion templates/core/core-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ data:
POSTGRESQL_SSLMODE: "{{ template "harbor.database.sslmode" . }}"
POSTGRESQL_MAX_IDLE_CONNS: "{{ .Values.database.maxIdleConns }}"
POSTGRESQL_MAX_OPEN_CONNS: "{{ .Values.database.maxOpenConns }}"
POSTGRESQL_CONN_MAX_IDLE_TIME: "{{ .Values.database.connMaxIdleTime }}"
POSTGRESQL_CONN_MAX_LIFETIME: "{{ .Values.database.connMaxLifetime }}"
EXT_ENDPOINT: "{{ .Values.externalURL }}"
CORE_URL: "{{ template "harbor.coreURL" . }}"
JOBSERVICE_URL: "{{ template "harbor.jobserviceURL" . }}"
Expand Down Expand Up @@ -87,4 +89,4 @@ data:

{{- if .Values.core.quotaUpdateProvider }}
QUOTA_UPDATE_PROVIDER: "{{ .Values.core.quotaUpdateProvider }}"
{{- end }}
{{- end }}
8 changes: 5 additions & 3 deletions templates/exporter/exporter-cm-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ data:
HARBOR_DATABASE_USERNAME: "{{ template "harbor.database.username" . }}"
HARBOR_DATABASE_DBNAME: "{{ template "harbor.database.coreDatabase" . }}"
HARBOR_DATABASE_SSLMODE: "{{ template "harbor.database.sslmode" . }}"
HARBOR_DATABASE_MAX_IDLE_CONNS: "{{ .Values.database.maxIdleConns }}"
HARBOR_DATABASE_MAX_OPEN_CONNS: "{{ .Values.database.maxOpenConns }}"
{{- end}}
HARBOR_DATABASE_MAX_IDLE_CONNS: "{{ default .Values.database.maxIdleConns .Values.exporter.override.database.maxIdleConns }}"
HARBOR_DATABASE_MAX_OPEN_CONNS: "{{ default .Values.database.maxOpenConns .Values.exporter.override.database.maxOpenConns }}"
HARBOR_DATABASE_CONN_MAX_IDLE_TIME: "{{ default .Values.database.connMaxIdleTime .Values.exporter.override.database.connMaxIdleTime }}"
HARBOR_DATABASE_CONN_MAX_LIFETIME: "{{ default .Values.database.connMaxLifetime .Values.exporter.override.database.connMaxLifetime }}"
{{- end}}
20 changes: 17 additions & 3 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -908,11 +908,18 @@ database:
sslmode: "disable"
# The maximum number of connections in the idle connection pool per pod (core+exporter).
# If it <=0, no idle connections are retained.
maxIdleConns: 100
maxIdleConns: 50
# The maximum number of open connections to the database per pod (core+exporter).
# If it <= 0, then there is no limit on the number of open connections.
# Note: the default number of connections is 1024 for harbor's postgres.
maxOpenConns: 900
# Note: the default number of connections is 1024 for postgres of harbor.
maxOpenConns: 100
# The maximum amount of time a connection may be reused in seconds
#(core+exporter).Default is (5 minutes on exporter and 1h on core as per pgx defaults)
#connMaxLifetime: 1h
# The maximum amount of time a connection can be idle before being closed in seconds (core+exporter).
# Default is (core as per pgx default 30 minutes and exporter 0)
#connMaxIdleTime: 1m

## Additional deployment annotations
podAnnotations: {}
## Additional deployment labels
Expand Down Expand Up @@ -1007,3 +1014,10 @@ exporter:
# whenUnsatisfiable: DoNotSchedule
cacheDuration: 23
cacheCleanInterval: 14400
override:
# Option to override the .database connection settings for the exporter.
database:
# maxIdleConns:
# maxOpenConns:
# connMaxIdleTime:
# connMaxLifetime:

0 comments on commit 6f2691b

Please sign in to comment.