Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -17756,6 +17756,8 @@ spec:
format: int64
type: integer
type: array
tlsOnly:
type: boolean
userInterface:
description: The specification of a user interface that connects to
PostgreSQL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17427,6 +17427,8 @@ spec:
pattern: ^repo[1-4]
type: string
type: object
tlsOnly:
type: boolean
unmanaged:
description: |-
Suspends the rollout and reconciliation of changes made to the
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/pgv2.percona.com_perconapgclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17833,6 +17833,8 @@ spec:
pattern: ^repo[1-4]
type: string
type: object
tlsOnly:
type: boolean
unmanaged:
description: |-
Suspends the rollout and reconciliation of changes made to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17667,6 +17667,8 @@ spec:
minimum: 1
type: integer
type: array
tlsOnly:
type: boolean
userInterface:
description: The specification of a user interface that connects to
PostgreSQL.
Expand Down
4 changes: 4 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18126,6 +18126,8 @@ spec:
pattern: ^repo[1-4]
type: string
type: object
tlsOnly:
type: boolean
unmanaged:
description: |-
Suspends the rollout and reconciliation of changes made to the
Expand Down Expand Up @@ -43350,6 +43352,8 @@ spec:
minimum: 1
type: integer
type: array
tlsOnly:
type: boolean
userInterface:
description: The specification of a user interface that connects to
PostgreSQL.
Expand Down
1 change: 1 addition & 0 deletions deploy/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
# name: cluster1-cert
# customReplicationTLSSecret:
# name: replication1-cert
# tlsOnly: false

# standby:
# enabled: true
Expand Down
4 changes: 4 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18126,6 +18126,8 @@ spec:
pattern: ^repo[1-4]
type: string
type: object
tlsOnly:
type: boolean
unmanaged:
description: |-
Suspends the rollout and reconciliation of changes made to the
Expand Down Expand Up @@ -43350,6 +43352,8 @@ spec:
minimum: 1
type: integer
type: array
tlsOnly:
type: boolean
userInterface:
description: The specification of a user interface that connects to
PostgreSQL.
Expand Down
4 changes: 4 additions & 0 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18126,6 +18126,8 @@ spec:
pattern: ^repo[1-4]
type: string
type: object
tlsOnly:
type: boolean
unmanaged:
description: |-
Suspends the rollout and reconciliation of changes made to the
Expand Down Expand Up @@ -43350,6 +43352,8 @@ spec:
minimum: 1
type: integer
type: array
tlsOnly:
type: boolean
userInterface:
description: The specification of a user interface that connects to
PostgreSQL.
Expand Down
10 changes: 10 additions & 0 deletions internal/controller/postgrescluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@ func (r *Reconciler) Reconcile(
pgmonitor.PostgreSQLHBAs(cluster, &pgHBAs)
pgbouncer.PostgreSQL(cluster, &pgHBAs)

// K8SPG-554
if cluster.Spec.TLSOnly {
for i := range pgHBAs.Mandatory {
pgHBAs.Mandatory[i].TLSOnly()
}
for i := range pgHBAs.Default {
pgHBAs.Default[i].TLSOnly()
}
}

pgParameters := postgres.NewParameters()
// K8SPG-375
if cluster.Spec.Extensions.PGStatMonitor {
Expand Down
7 changes: 7 additions & 0 deletions internal/postgres/hba.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ func (hba *HostBasedAuthentication) TLS() *HostBasedAuthentication {
return hba
}

func (hba *HostBasedAuthentication) TLSOnly() *HostBasedAuthentication {
if hba.origin == "host" || hba.origin == "hostnossl" {
hba.origin = "hostssl"
}
return hba
}

// TCP makes hba match connection attempts made using TCP/IP, with or without SSL.
func (hba *HostBasedAuthentication) TCP() *HostBasedAuthentication {
hba.origin = "host"
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ type PerconaPGClusterSpec struct {
// +optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`

TLSOnly bool `json:"tlsOnly,omitempty"`

// The port on which PostgreSQL should listen.
// +optional
// +kubebuilder:default=5432
Expand Down Expand Up @@ -354,6 +356,8 @@ func (cr *PerconaPGCluster) ToCrunchy(ctx context.Context, postgresCluster *crun
postgresCluster.Spec.Extensions.PGAudit = *cr.Spec.Extensions.BuiltIn.PGAudit
postgresCluster.Spec.Extensions.PGVector = *cr.Spec.Extensions.BuiltIn.PGVector

postgresCluster.Spec.TLSOnly = cr.Spec.TLSOnly

return postgresCluster, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type PostgresClusterSpec struct {
// +optional
CustomTLSSecret *corev1.SecretProjection `json:"customTLSSecret,omitempty"`

TLSOnly bool `json:"tlsOnly,omitempty"`

// The secret containing the replication client certificates and keys for
// secure connections to the PostgreSQL server. It will need to contain the
// client TLS certificate, TLS key and the Certificate Authority certificate
Expand Down
Loading