Compare commits

..

No commits in common. "feat/postgres-all-parameters" and "main" have entirely different histories.

10 changed files with 91 additions and 92 deletions

View file

@ -112,9 +112,15 @@ type DatabaseRoles struct {
}
type PostgreSQL struct {
// PostgreSQL server parameters. All values must be strings (enclose numbers in quotes). See PostgreSQL documentation for available parameters. WARNING: Some parameters are managed by CloudNativePG and should NOT be overridden (archive_mode, archive_command, restore_command, primary_conninfo, etc.). Incorrect values may break backup/replication or require pod restart.
// +kubebuilder:default:={"max_connections":"100"}
Parameters map[string]string `json:"parameters,omitempty"`
// PostgreSQL server parameters.
// +kubebuilder:default:={}
Parameters PostgreSQLParameters `json:"parameters,omitempty"`
}
type PostgreSQLParameters struct {
// Maximum number of concurrent connections to the database server.
// +kubebuilder:default:=100
MaxConnections int `json:"max_connections,omitempty"`
}
type Quorum struct {

View file

@ -85,7 +85,7 @@ func (in *ConfigSpec) DeepCopyInto(out *ConfigSpec) {
*out = *in
in.Resources.DeepCopyInto(&out.Resources)
out.Size = in.Size.DeepCopy()
in.Postgresql.DeepCopyInto(&out.Postgresql)
out.Postgresql = in.Postgresql
out.Quorum = in.Quorum
if in.Users != nil {
in, out := &in.Users, &out.Users
@ -164,13 +164,7 @@ func (in *DatabaseRoles) DeepCopy() *DatabaseRoles {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PostgreSQL) DeepCopyInto(out *PostgreSQL) {
*out = *in
if in.Parameters != nil {
in, out := &in.Parameters, &out.Parameters
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
out.Parameters = in.Parameters
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PostgreSQL.
@ -183,6 +177,21 @@ func (in *PostgreSQL) DeepCopy() *PostgreSQL {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PostgreSQLParameters) DeepCopyInto(out *PostgreSQLParameters) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PostgreSQLParameters.
func (in *PostgreSQLParameters) DeepCopy() *PostgreSQLParameters {
if in == nil {
return nil
}
out := new(PostgreSQLParameters)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Quorum) DeepCopyInto(out *Quorum) {
*out = *in

View file

@ -16,7 +16,7 @@ spec:
storageClass: ""
postgresql:
parameters:
max_connections: "100"
max_connections: 100
quorum:
minSyncReplicas: 0
maxSyncReplicas: 0

View file

@ -81,10 +81,11 @@ See:
### Application-specific parameters
| Name | Description | Type | Value |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ----- |
| `postgresql` | PostgreSQL server configuration. | `object` | `{}` |
| `postgresql.parameters` | PostgreSQL server parameters. All values must be strings (enclose numbers in quotes). See PostgreSQL documentation for available parameters. WARNING: Some parameters are managed by CloudNativePG and should NOT be overridden (archive_mode, archive_command, restore_command, primary_conninfo, etc.). Incorrect values may break backup/replication or require pod restart. | `map[string]string` | `{}` |
| Name | Description | Type | Value |
| --------------------------------------- | ---------------------------------------------------------------- | -------- | ----- |
| `postgresql` | PostgreSQL server configuration. | `object` | `{}` |
| `postgresql.parameters` | PostgreSQL server parameters. | `object` | `{}` |
| `postgresql.parameters.max_connections` | Maximum number of concurrent connections to the database server. | `int` | `100` |
### Quorum-based synchronous replication

View file

@ -60,16 +60,9 @@ spec:
{{- end }}
postgresql:
parameters:
{{- $defaults := dict "max_wal_senders" "30" }}
{{- $params := merge (dict) .Values.postgresql.parameters $defaults }}
{{- /* Security: Block parameters that could allow shell command execution */ -}}
{{- $dangerousParams := list "archive_command" "restore_command" "ssl_passphrase_command" "log_destination" "event_source" }}
{{- range $key, $value := $params }}
{{- $normalizedKey := lower $key }}
{{- if has $normalizedKey $dangerousParams }}
{{- fail (printf "SECURITY: Parameter '%s' is blocked for security reasons. This parameter could allow arbitrary shell command execution and is managed by CloudNativePG operator." $key) }}
{{- end }}
{{ $key }}: {{ $value | quote }}
max_wal_senders: "30"
{{- with .Values.postgresql.parameters.max_connections }}
max_connections: "{{ . }}"
{{- end }}
minSyncReplicas: {{ .Values.quorum.minSyncReplicas }}

View file

@ -97,13 +97,15 @@
"default": {},
"properties": {
"parameters": {
"description": "PostgreSQL server parameters. All values must be strings (enclose numbers in quotes). See PostgreSQL documentation for available parameters. WARNING: Some parameters are managed by CloudNativePG and should NOT be overridden (archive_mode, archive_command, restore_command, primary_conninfo, etc.). Incorrect values may break backup/replication or require pod restart.",
"description": "PostgreSQL server parameters.",
"type": "object",
"default": {
"max_connections": "100"
},
"additionalProperties": {
"type": "string"
"default": {},
"properties": {
"max_connections": {
"description": "Maximum number of concurrent connections to the database server.",
"type": "integer",
"default": 100
}
}
}
}

View file

@ -48,32 +48,16 @@ version: v18
## @section Application-specific parameters
##
## @typedef {struct} PostgreSQLParameters - PostgreSQL server parameters.
## @field {int} [max_connections] - Maximum number of concurrent connections to the database server.
## @typedef {struct} PostgreSQL - PostgreSQL server configuration.
## @field {map[string]string} [parameters] - PostgreSQL server parameters. All values must be strings (enclose numbers in quotes). See PostgreSQL documentation for available parameters. WARNING: Some parameters are managed by CloudNativePG and should NOT be overridden (archive_mode, archive_command, restore_command, primary_conninfo, etc.). Incorrect values may break backup/replication or require pod restart.
## @field {PostgreSQLParameters} [parameters] - PostgreSQL server parameters.
## @param {PostgreSQL} postgresql - PostgreSQL server configuration.
postgresql:
parameters:
max_connections: "100"
## Additional parameters examples:
## shared_buffers: "1GB"
## effective_cache_size: "4GB"
## bgwriter_delay: "200ms"
## commit_delay: "100"
## commit_siblings: "5"
## work_mem: "256MB"
##
## SECURITY: The following parameters are BLOCKED for security reasons
## (could allow arbitrary shell command execution):
## archive_command, restore_command, ssl_passphrase_command,
## log_destination, event_source
##
## IMPORTANT: Do NOT override CloudNativePG-managed parameters:
## archive_mode, primary_conninfo, wal_level, max_replication_slots
##
## NOTE: Some parameters require pod restart (not just reload):
## shared_buffers, max_connections, max_prepared_transactions,
## wal_buffers, max_wal_senders
max_connections: 100
##
## @section Quorum-based synchronous replication

View file

@ -0,0 +1,42 @@
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: vm-not-running-alert
spec:
groups:
- name: kubevirt-alerts
rules:
- alert: VMNotRunningFor10Minutes
expr: |
max_over_time(
kubevirt_vm_info{
status!="running",
exported_namespace=~".+",
name=~".+"
}[10m]
) == 1
labels:
severity: critical
namespace: "{{ $labels.exported_namespace }}"
annotations:
summary: "VM '{{ $labels.name }}' in namespace '{{ $labels.exported_namespace }}' is not Running for more than 10 minutes"
description: >
The VM '{{ $labels.name }}' in namespace '{{ $labels.exported_namespace }}' has been in a non-Running state
for more than 10 minutes. Please investigate the issue.
- alert: VMINotRunningFor10Minutes
expr: |
max_over_time(
kubevirt_vmi_info{
phase!="running",
exported_namespace=~".+",
name=~".+"
}[10m]
) == 1
labels:
severity: critical
namespace: "{{ $labels.exported_namespace }}"
annotations:
summary: "VMI '{{ $labels.name }}' in namespace '{{ $labels.exported_namespace }}' is not Running for more than 10 minutes"
description: >
The VM '{{ $labels.name }}' in namespace '{{ $labels.exported_namespace }}' has been in a non-Running state
for more than 10 minutes. Please investigate the issue.

View file

@ -1,38 +0,0 @@
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: vm-not-running-alert
spec:
groups:
- name: kubevirt-alerts
rules:
- alert: VMNotRunningFor10Minutes
expr: |
max_over_time(
kubevirt_vm_info{
status!="running",
exported_namespace=~".+",
name=~".+"
}[10m]
) == 1
labels:
severity: critical
namespace: '{{ "{{" }} $labels.exported_namespace {{ "}}" }}'
annotations:
summary: 'VM {{ "{{" }} $labels.name {{ "}}" }} in namespace {{ "{{" }} $labels.exported_namespace {{ "}}" }} is not Running for more than 10 minutes'
description: 'The VM {{ "{{" }} $labels.name {{ "}}" }} in namespace {{ "{{" }} $labels.exported_namespace {{ "}}" }} has been in a non-Running state for more than 10 minutes. Please investigate the issue.'
- alert: VMINotRunningFor10Minutes
expr: |
max_over_time(
kubevirt_vmi_info{
phase!="running",
exported_namespace=~".+",
name=~".+"
}[10m]
) == 1
labels:
severity: critical
namespace: '{{ "{{" }} $labels.exported_namespace {{ "}}" }}'
annotations:
summary: 'VMI {{ "{{" }} $labels.name {{ "}}" }} in namespace {{ "{{" }} $labels.exported_namespace {{ "}}" }} is not Running for more than 10 minutes'
description: 'The VMI {{ "{{" }} $labels.name {{ "}}" }} in namespace {{ "{{" }} $labels.exported_namespace {{ "}}" }} has been in a non-Running state for more than 10 minutes. Please investigate the issue.'

File diff suppressed because one or more lines are too long