[英]How to expose postgres tcp port using Docker Desktop for Windows Kubernetes and ingress-nginx
I'm using "Docker Desktop for Windows" with kube.netes.我在 kube.netes 中使用“Windows 版 Docker 桌面”。 So far, its great.
到目前为止,它很棒。
I'd like to manage my postgress db (TCP:5432).我想管理我的 postgress 数据库 (TCP:5432)。 I'm using the kube.netes "ingress-nginx" ingress controller, which saws it can be configured to expose TCP using a configmap .
我正在使用 kube.netes“ingress-nginx”入口 controller,它可以配置为使用 configmap 公开 TCP 。
Here is what I have so far:这是我到目前为止所拥有的:
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx
data:
5432: "ingress-nginx/postgres:5432"
---
# SEE: https://kubernetes.io/docs/concepts/services-networking/ingress/
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-myproject.com
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: clusterissuer-selfsigned
# See: https://github.com/kubernetes/ingress-nginx/blob/master/docs/examples/rewrite/README.md
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
spec:
tls:
- hosts:
- www.myproject.com
secretName: tls-myproject
rules:
# Avoid Quasar build paths: /css, /fonts, /icons, /js
- http:
paths:
# See https://github.com/kubernetes/ingress-nginx/blob/master/docs/examples/rewrite/README.md
- path: /data(/|$)(.*)
pathType: Prefix
backend:
service:
name: backend
port:
number: 80
...
Now I need to:现在我需要:
I found the ingress-nginx-controller in the kube.netes dashboard and hand edited like below, but it's behavior didn't change.我在 kube.netes 仪表板中找到了 ingress-nginx-controller 并进行了如下手动编辑,但它的行为没有改变。
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
template:
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
spec:
volumes:
- name: webhook-cert
secret:
secretName: ingress-nginx-admission
defaultMode: 420
containers:
- name: controller
image: >-
k8s.gcr.io/ingress-nginx/controller:v0.41.0@sha256:e6019e536cfb921afb99408d5292fa88b017c49dd29d05fc8dbc456aa770d590
args:
- /nginx-ingress-controller
- '--publish-service=$(POD_NAMESPACE)/ingress-nginx-controller'
- '--election-id=ingress-controller-leader'
- '--ingress-class=nginx'
- '--configmap=$(POD_NAMESPACE)/ingress-nginx-controller'
- '--validating-webhook=:8443'
- '--validating-webhook-certificate=/usr/local/certificates/cert'
- '--validating-webhook-key=/usr/local/certificates/key'
- '--tcp-services-configmap=ingress-nginx/tcp-services'
What am I missing?我错过了什么? How can I configure this w/o having to hand edit it?
我如何配置它而不必手动编辑它? Thank you!
谢谢!
I think there are 2 issues.我认为有两个问题。
You need to install nginx separately from your postgress installation.您需要与 postgress 安装分开安装 nginx。 This means that you will have some nginx pods/deployments, and a service that exist in the ingress-nginx namespace.
这意味着您将拥有一些 nginx 个 pod/部署,以及一个存在于 ingress-nginx 命名空间中的服务。 To do this, follow the guide here .
为此,请按照此处的指南进行操作。 It is recommended that you follow a yaml file from the cloud section for a docker desktop deployment.
建议您按照云部分的 yaml 文件进行 docker 桌面部署。 This is someone who has gone through the process.
这是一个经历过这个过程的人。
Once nginx is installed on your cluster, you need to go from you postgress deployment/pod -> service -> ingress.在集群上安装 nginx 后,您需要从 postgress deployment/pod -> service -> ingress 中获取 go。 These will be in a different namespace than your ingress-nginx one (default is fine).
这些将与您的 ingress-nginx 位于不同的命名空间中(默认即可)。 To configure it, you can follow the guide located here .
要配置它,您可以按照此处的指南进行操作。 If you want to test things along the way, you can use kube.netes
port-forward
ing command to forward your postgress pod to your local machine.如果你想一路测试东西,你可以使用 kube.netes
port-forward
命令将你的 postgress pod 转发到你的本地机器。 You can also test your service with the same method.您也可以使用相同的方法测试您的服务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.