Skip to content
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
59 changes: 30 additions & 29 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
name: Build Pgskipper Components
run-name: "Dev image for ${{ github.event.repository.name }}: ${{ github.run_number }} - ${{ github.actor }}"
on:
release:
types: [created]
push:
branches:
- "main"
paths-ignore:
- "docs/**"
- "CODE-OF-CONDUCT.md"
- "CONTRIBUTING.md"
- "LICENSE"
- "README.md"
- "SECURITY.md"
pull_request:
branches:
- "**"
paths-ignore:
- "docs/**"
- "CODE-OF-CONDUCT.md"
- "CONTRIBUTING.md"
- "LICENSE"
- "README.md"
- "SECURITY.md"
workflow_dispatch:
inputs:
publish_docker:
description: "Publish images to ghcr.io/netcracker"
type: boolean
default: false
required: false
push
# release:
# types: [created]
# push:
# branches:
# - "main"
# paths-ignore:
# - "docs/**"
# - "CODE-OF-CONDUCT.md"
# - "CONTRIBUTING.md"
# - "LICENSE"
# - "README.md"
# - "SECURITY.md"
# pull_request:
# branches:
# - "**"
# paths-ignore:
# - "docs/**"
# - "CODE-OF-CONDUCT.md"
# - "CONTRIBUTING.md"
# - "LICENSE"
# - "README.md"
# - "SECURITY.md"
# workflow_dispatch:
# inputs:
# publish_docker:
# description: "Publish images to ghcr.io/netcracker"
# type: boolean
# default: false
# required: false

permissions:
contents: read
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ permissions:
actions: read

on:
pull_request:
types: [opened, synchronize, reopened]
branches: [main]
push
# pull_request:
# types: [opened, synchronize, reopened]
# branches: [main]

jobs:
Wait-for-images:
Expand Down Expand Up @@ -49,3 +50,4 @@ jobs:
fi
echo "All tests completed successfully or not required"


2 changes: 1 addition & 1 deletion docs/public/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ For more information on how to do the Major Upgrade of PostgreSQL, please, follo
```yaml
pgbouncer:
listen_port: '6432'
listen_addr: '0.0.0.0'
listen_addr: '*'
auth_type: 'md5'
auth_file: '/etc/pgbouncer/userlist.txt'
auth_user: 'pgbouncer'
Expand Down
10 changes: 5 additions & 5 deletions operator/build/configs/patroni.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ kubernetes:
app: ${PATRONI_CLUSTER_NAME}
role_label: pgtype
scope_label: app
pod_ip: ${LISTEN_ADDR}
# pod_ip is omitted so Patroni auto-discovers it from pod.status.pod_ip
postgresql:
authentication:
replication:
Expand All @@ -67,15 +67,15 @@ postgresql:
on_role_change: /setup_endpoint_callback.py
on_start: /setup_endpoint_callback.py
on_stop: /setup_endpoint_callback.py
connect_address: ${LISTEN_ADDR}:5432
connect_address: ${POD_DNS_NAME}:5432
data_dir: /var/lib/pgsql/data/postgresql_${NODE_NAME}
listen: '0.0.0.0, ::0:5432'
listen: '*:5432'
parameters:
unix_socket_directories: /var/run/postgresql, /tmp
pgpass: /tmp/pgpass0
restapi:
connect_address: ${LISTEN_ADDR}:8008
listen: ${LISTEN_ADDR}:8008
connect_address: ${POD_DNS_NAME}:8008
listen: '*:8008'
tags:
clonefrom: false
nofailover: ${DR_MODE}
Expand Down
1 change: 1 addition & 0 deletions operator/charts/patroni-core/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,4 @@ INTERNAL_TLS_ENABLED: false
GLOBAL_SECURITY_CONTEXT: true

CLOUD_PUBLIC_HOST: "k8s.default"

2 changes: 1 addition & 1 deletion operator/charts/patroni-services/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ connectionPooler:
'*': "host=pg-patroni-direct port=5432"
pgbouncer:
listen_port: '6432'
listen_addr: '0.0.0.0'
listen_addr: '*'
auth_type: 'md5'
auth_file: '/etc/pgbouncer/userlist.txt'
auth_user: 'pgbouncer'
Expand Down
27 changes: 26 additions & 1 deletion operator/pkg/deployment/patroni.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,31 @@ func NewPatroniStatefulset(cr *patroniv1.PatroniCore, deploymentIdx int, cluster
},
},
},
{
Name: "POD_NAME",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
APIVersion: "v1",
FieldPath: "metadata.name",
},
},
},
{
Name: "HEADLESS_SERVICE",
Value: fmt.Sprintf("patroni-%s-headless", clusterName),
},
{
Name: "POD_DNS_NAME",
Value: "$(POD_NAME).$(HEADLESS_SERVICE).$(POD_NAMESPACE).svc",
},
{
Name: "PG_RESOURCES_LIMIT_MEM",
ValueFrom: &corev1.EnvVarSource{
ResourceFieldRef: &corev1.ResourceFieldSelector{
Resource: "limits.memory",
},
},
},
{
Name: "PATRONI_CLUSTER_NAME",
Value: clusterName,
Expand Down Expand Up @@ -262,7 +287,7 @@ func NewPatroniStatefulset(cr *patroniv1.PatroniCore, deploymentIdx int, cluster
DNSPolicy: corev1.DNSClusterFirst,
},
},
ServiceName: "backrest-headless",
ServiceName: fmt.Sprintf("patroni-%s-headless", clusterName),
PodManagementPolicy: appsv1.OrderedReadyPodManagement,
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{Type: appsv1.RollingUpdateStatefulSetStrategyType},
RevisionHistoryLimit: ptr.To[int32](10),
Expand Down
24 changes: 24 additions & 0 deletions operator/pkg/deployment/pgbackrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,30 @@ func GetBackrestHeadless() *corev1.Service {
}
}

func GetPatroniHeadless(clusterName string) *corev1.Service {
labels := map[string]string{"app": clusterName}
ports := []corev1.ServicePort{
{Name: "postgresql", Port: 5432},
{Name: "patroni-api", Port: 8008},
}
return &corev1.Service{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Service",
},
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("patroni-%s-headless", clusterName),
Namespace: util.GetNameSpace(),
},

Spec: corev1.ServiceSpec{
Selector: labels,
Ports: ports,
ClusterIP: "None",
},
}
}

func getPgBackRestSettings(pgBackrestSpec *v1.PgBackRest, isStandby bool) string {
var listSettings []string
listSettings = append(listSettings, "[global]")
Expand Down
8 changes: 8 additions & 0 deletions operator/pkg/reconciler/patroni.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,14 @@ func (r *PatroniReconciler) processPatroniServices(cr *v1.PatroniCore, patroniSp
}
}
}

// Create patroni headless service for DNS-based pod discovery
patroniHeadless := deployment.GetPatroniHeadless(r.cluster.ClusterName)
if err := r.helper.ResourceManager.CreateOrUpdateService(patroniHeadless); err != nil {
logger.Error(fmt.Sprintf("Cannot create service %s", patroniHeadless.Name), zap.Error(err))
return err
}

return nil
}

Expand Down
Loading