1.9 KiB
1.9 KiB
date, topic, areas, tags
| date | topic | areas | tags | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 2026-04-16 | kine pgx multi-host 직결 (HAProxy 의존 제거) |
|
|
K3s kine 의 datastore-endpoint 를 HAProxy 192.168.9.1:5432 에서 Patroni 3노드 pgx multi-host 로 전환. API 다운타임 <1초.
변경 사항
K3s config (/etc/rancher/k3s/config.yaml, kr1 + kr2)
before:
datastore-endpoint: "postgres://kine:kine@192.168.9.1:5432/kine"
after:
datastore-endpoint: "postgres://kine:kine@10.100.2.5:5432,10.100.3.185:5432,10.100.1.83:5432/kine?target_session_attrs=read-write&sslmode=disable"
실행 순서
- kr2 (init server): config backup → sed 치환 →
systemctl restart k3s→ kubectl get nodes 확인 (5초 내 Ready) - kr1 (secondary server): 동일 → 10초 내 Ready
- 4노드 전체 Ready 확인 (hp1, hp2, kr1, kr2), API 응답 시간 ~200ms
Patroni switchover 테스트
patronictl switchover --leader postgres-1 --candidate postgres-3 --force (TL12→13):
- switchover 커맨드 반환: 4.8초
- kubectl get nodes 첫 응답: t+2ms (즉시) —
incus-hp1 Ready - API 정상 응답 시간: 231ms
- API 다운타임: <1초
kine 의 pgx target_session_attrs=read-write 가 자동으로 새 primary (postgres-3, 10.100.1.83) 에 재연결.
비교: HAProxy 경유 시 health check inter 3s fall 3 = 최대 9초 감지 지연. pgx multi-host 방식은 connection-level 에서 즉시 재시도.
롤백
sudo cp /tmp/config.yaml-backup-20260416 /etc/rancher/k3s/config.yaml
sudo systemctl restart k3s
HAProxy :5432 상태
kine + pgpool(NocoDB/n8n/Outline) 전환 완료로 HAProxy postgres 프론트엔드 (ft_postgres + bk_postgres_primary) 는 더 이상 트래픽 없음. 1주 관측 후 제거.
참조
infra/postgresql-ha.md— 「K3s kine 연결」 갱신- kine pgx 지원 확인:
k3s-io/kinego.modgithub.com/jackc/pgx/v5