gpt4 book ai didi

postgresql - 如何访问部署在Kubernetes集群上的postgresql

转载 作者:行者123 更新时间:2023-12-03 08:22:58 25 4
gpt4 key购买 nike

我已经在 kubernetes pod 上部署了 postgresql pod,并且想知道如何访问 postgresql gui。我无法使用入口路径访问它,因为我知道入口仅用于 https 目的,而 postgres 遵循 TCP 协议(protocol)。我如何通过 GUI 访问任何线索?

部署.yaml

---
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
name: "postgresql-development"
namespace: "development"
spec:
selector:
matchLabels:
app: "postgresql-development"
replicas: 1
strategy:
type: "RollingUpdate"
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
minReadySeconds: 5
template:
metadata:
labels:
app: "postgresql-development"
tier: "mysql"
spec:
containers:
-
name: "postgresql-development"
image: "postgresql:12.6"
imagePullPolicy: "Always"
env:
-
name: "POSTGRES_USER"
value: "postgres"
ports:
-
containerPort: 5432
name: "postgres"

volumeMounts:
-
name: "postgresql-persistent-storage"
mountPath: "/var/lib/postgresql"

volumes:
-
name: "postgresql-persistent-storage"
persistentVolumeClaim:
claimName: "postgresql-pvc-development"



imagePullSecrets:
-
name: "postgresql"

服务.yaml

---
apiVersion: "v1"
kind: "Service"
metadata:
name: "postgresql-development"
namespace: "development"
labels:
app: "postgresql-development"
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
spec:
ports:
-
port: 59799
targetPort: 5432
protocol: TCP
selector:
app: "postgresql-development"
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
tier: mysql

入口.yaml

---
apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
metadata:
name: "postgresql-development-ingress"
namespace: "development"
annotations:
nginx.ingress.kubernetes.io/rewrite-target: "/$1"
spec:
rules:
-
host: "localhost"
http:
paths:
-
backend:
serviceName: "postgresql-development"
servicePort: 59799
path: "postgresql-development/(.*)"

最佳答案

Ingress API 仅适用于第 7 层 (HTTP)。在您的情况下,您想要访问第 4 层 (TCP)。

为了实现您的目标,您可以:

关于postgresql - 如何访问部署在Kubernetes集群上的postgresql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67319362/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com