当前位置: 首页 > 知识库问答 >
问题:

Bitnami Postgresql with Kubernetes Istio

苏凯
2023-03-14

我开始在库伯内特斯上构建一个Postgresql哈集群,使用的是sesrew网格istio。在命名空间中启用istion注入之前,我尝试了不带istio的方法。它运行良好。启用istio注入后,statefulset中的第二个pod无法通过无头服务连接到集群中的第一个pod。

postgreslq-test-postgresql-ha-pgpool-779d7f588-qmbmf   1/1     Running   9          69m
postgreslq-test-postgresql-ha-postgresql-0             3/3     Running   0          10m
postgreslq-test-postgresql-ha-postgresql-1             2/3     Running   6          9m50s

我删除了在掌舵安装下创建的网络策略。

kubectl logs postgreslq-test-postgresql-ha-postgresql-1 postgresql

postgresql-repmgr 13:00:54.29 DEBUG ==> Host 'postgreslq-test-postgresql-ha-postgresql-0.postgreslq-test-postgresql-ha-postgresql-headless.gitlab-test.svc.cluster.local:5432' is not accessible
psql: error: could not connect to server: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.

为了自己测试它,我使用postgresql客户端创建了一个pod

root@testpod:/# psql -h postgreslq-test-postgresql-ha-postgresql-0.postgreslq-test-postgresql-ha-postgresql-headless.gitlab-test.svc.cluster.local -U posgres
psql: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.

Istio代理日志:

"response_flags": "UF,URX",
    "start_time": "2020-10-19T14:21:44.631Z",
    "method": "-",
    "request_id": "-",
    "upstream_host": "10.93.202.188:5432",
    "x_forwarded_for": "-",
    "requested_server_name": "-",
    "bytes_received": "0",
    "istio_policy_status": "-",
    "bytes_sent": "0",
    "upstream_cluster": "outbound|5432||postgresql-ha-postgresql-headless.gitlab-prod.svc.cluster.local",
    "downstream_remote_address": "10.93.203.197:42222",
    "authority": "-",
    "path": "-",
    "protocol": "-",
    "upstream_service_time": "-",
    "upstream_local_address": "-",
    "duration": "3",
    "upstream_transport_failure_reason": "-",
    "route_name": "-",
    "downstream_local_address": "10.93.202.188:5432",
    "user_agent": "-",
    "response_code": "0"


Kubernetes版本:k8s.gcr.io/hyperkube:v1.18.4

Istio 版本: 1.6.3

头盔图表:bitnami/postgresql-ha图表版本:5.0.0 APP版本:11.9.1

我认为是某种Istio配置导致了这个问题,因为它在没有Istio的情况下工作。

知道有什么问题吗?

共有1个答案

暴向笛
2023-03-14

我找到了问题和解决方案。端口名引起的问题。

apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/instance: pg-istio
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: postgresql-ha
    helm.sh/chart: postgresql-ha-6.5.0
  namespace: postgre-test-istio
spec:
  clusterIP: None
  ports:
  - name: postgresql
    port: 5432
    protocol: TCP
    targetPort: 5432
  selector:
    app.kubernetes.io/component: postgresql
    app.kubernetes.io/instance: pg-istio
    app.kubernetes.io/name: postgresql-ha
  sessionAffinity: None
  type: ClusterIP

更改为 :

apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/instance: pg-istio
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: postgresql-ha
    helm.sh/chart: postgresql-ha-6.5.0
  namespace: postgre-test-istio
spec:
  clusterIP: None
  ports:
  - name: tcp-postgresql
    port: 5432
    protocol: TCP
    targetPort: 5432
  selector:
    app.kubernetes.io/component: postgresql
    app.kubernetes.io/instance: pg-istio
    app.kubernetes.io/name: postgresql-ha
  sessionAffinity: None
  type: ClusterIP


 类似资料:

相关问答

相关文章

相关阅读