Ket*_*ena 5 tcp nginx kubernetes kubernetes-ingress nginx-ingress
所以我使用 Kubernetes 在谷歌云上设置了我的应用程序。我有一个 Pod,我想将它暴露在需要 TCP 请求的集群之外。
我开始知道这可以通过ingress-nginx 实现,并对此进行了研究。正如此处的文档中所述,可以通过设置如下的 configMap 来完成:
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-configmap-example
data:
9000: "default/my-service-name:7051
Run Code Online (Sandbox Code Playgroud)
,但它的完整用法没有清楚地描述,我也无法在文档中正确找到完整的示例。
我已经安装了安装指南中提到的 ingress-nginx,但我不确定接下来要公开我的 Pod 的步骤是什么。
额外信息
7051 因此,为了实现这一目标,您可以这样做:
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-configmap-example
data:
9000: "default/my-service-name:7051
Run Code Online (Sandbox Code Playgroud)
然后通过将此标志添加到容器参数来编辑 nginx-ingress-controller 部署,如下所示:
...
containers:
- name: nginx-ingress-controller
image: "quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.26.1"
imagePullPolicy: "IfNotPresent"
args:
- /nginx-ingress-controller
- --default-backend-service=nginx-ingress/nginx-ingress-default-backend
- --election-id=ingress-controller-leader
- --ingress-class=nginx
- --configmap=nginx-ingress/nginx-ingress-controller
- --tcp-services-configmap=default/tcp-configmap-example
...
Run Code Online (Sandbox Code Playgroud)通过将端口添加到 LoadBalancer 来编辑 LoadBalancer 服务
...
ports:
- name: http
port: 80
protocol: TCP
targetPort: http
- name: https
port: 443
protocol: TCP
targetPort: https
- name: some-service-port
port: 7051
protocol: TCP
Run Code Online (Sandbox Code Playgroud)希望能帮助到你!
| 归档时间: |
|
| 查看次数: |
1588 次 |
| 最近记录: |