User Tools

Site Tools


сервис_postgresql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
сервис_postgresql [2025/10/28 08:35]
val [Клиент psql]
сервис_postgresql [2026/06/11 11:11] (current)
val [Kubernetes]
Line 19: Line 19:
 ==== Kubernetes ==== ==== Kubernetes ====
  
-  * Как не надо делать:​ [[https://​www.digitalocean.com/​community/​tutorials/​how-to-deploy-postgres-to-kubernetes-cluster]]+  * Как не надо делать (уже исправили,​ но, комментарии остались:[[https://​www.digitalocean.com/​community/​tutorials/​how-to-deploy-postgres-to-kubernetes-cluster]]
  
 === Helm === === Helm ===
Line 28: Line 28:
   * Dynamic Volume Provisioning [[Система Kubernetes#​longhorn]]   * Dynamic Volume Provisioning [[Система Kubernetes#​longhorn]]
  
 +  * !!! Поменять repository и allowInsecureImages по аналогии Keycloak в [[Сервис Keycloak#​Kubernetes]]
 <​code>​ <​code>​
 kube1:​~/​my-postgres#​ helm show values oci://​registry-1.docker.io/​bitnamicharts/​postgresql --version 16.6.2 | tee values.yaml.orig kube1:​~/​my-postgres#​ helm show values oci://​registry-1.docker.io/​bitnamicharts/​postgresql --version 16.6.2 | tee values.yaml.orig
Line 62: Line 63:
  
 kube1:~# kubectl -n cnpg-system get all kube1:~# kubectl -n cnpg-system get all
 +
 +kube1:~# mkdir my-pgcluster;​ cd $_
  
 kube1:​~/​my-pgcluster#​ echo -n keycloak | base64 kube1:​~/​my-pgcluster#​ echo -n keycloak | base64
Line 95: Line 98:
 </​code><​code>​ </​code><​code>​
 kube1:​~/​my-pgcluster#​ kubectl create ns my-pgcluster-ns kube1:​~/​my-pgcluster#​ kubectl create ns my-pgcluster-ns
 +</​code>​ 
 +  * [[Система Kubernetes#​Kustomize]] 
 +<​code>​
 kube1:​~/​my-pgcluster#​ kubectl -n my-pgcluster-ns apply -f keycloak-db-secret.yaml,​my-pgcluster.yaml kube1:​~/​my-pgcluster#​ kubectl -n my-pgcluster-ns apply -f keycloak-db-secret.yaml,​my-pgcluster.yaml
- +</​code>​ 
-kube1# ​watch kubectl -n my-pgcluster-ns get all +== Проверка состояния кластера cnpg == 
- +<​code>​ 
-kube1# ###kubectl -n my-pgcluster-ns exec -it pod/​my-pgcluster-1 -- psql+kube1:​~/​my-pgcluster# kubectl -n my-pgcluster-ns get cluster 
 +NAME AGE INSTANCES READY STATUS PRIMARY 
 +... 
 +</​code>​ 
 +== Подключение к кластеру cnpg == 
 +<​code>​ 
 +kube1# kubectl -n my-pgcluster-ns exec -it pod/​my-pgcluster-1 -- psql
  
 kube1# ###psql postgres://​keycloak:​strongpassword@my-pgcluster-rw.my-pgcluster-ns:​5432/​keycloak kube1# ###psql postgres://​keycloak:​strongpassword@my-pgcluster-rw.my-pgcluster-ns:​5432/​keycloak
Line 113: Line 124:
  
 kube1:~# kubectl cnpg status my-pgcluster -n my-pgcluster-ns kube1:~# kubectl cnpg status my-pgcluster -n my-pgcluster-ns
 +
 +kube1:~# kubectl cnpg promote -n my-pgcluster-ns my-pgcluster my-pgcluster-1
  
 kube1:~# kubectl cnpg logs cluster my-pgcluster -n my-pgcluster-ns kube1:~# kubectl cnpg logs cluster my-pgcluster -n my-pgcluster-ns
 +</​code>​
 +== Миграция с вышедшего из строя узла ==
 +<​code>​
 +kube2:~# kubectl -n my-pgcluster-ns get pods
 +...
 +my-pgcluster-3 ​  ​0/​1 ​    ​Pending ​  ​0 ​         80m
 +
 +kube2# kubectl -n my-pgcluster-ns delete pvc my-pgcluster-3
 +
 +kube2# kubectl -n my-pgcluster-ns delete pods/​my-pgcluster-3
 </​code>​ </​code>​
 ===== Клиент psql ===== ===== Клиент psql =====
Line 189: Line 212:
 server# systemctl restart postgresql server# systemctl restart postgresql
  
-client$ psql postgres://​postgres:​strongpassword@IP_OR_DNS_NAME:​5432/​postgres #-c "​\dt"​+client$ psql postgres://​postgres:​strongpassword@IP_OR_DNS_NAME:​5432/​postgres 
 + 
 +root@my-debian:​~psql postgres://​keycloak:​strongpassword@my-pgcluster-rw.my-pgcluster-ns:​5432/​keycloak ​-c "​\dt"​ 
 + 
 +kube1:~# host my-pgcluster-rw.my-pgcluster-ns.svc.cluster.local 169.254.25.10 
 + 
 +kube1:~# telnet 10.233.N.M 5432
 </​code>​ </​code>​
  
сервис_postgresql.1761629729.txt.gz · Last modified: 2025/10/28 08:35 by val