如何解决使用 nginx 入口控制器公开 TCP 流量
目前我正在使用 Docker 桌面和 Kubernetes 功能在 Windows 上进行测试。
我想通过入口控制器通过 TCP 流式传输 RTMP
数据。
我遵循了 Nginx 控制器安装指南 https://kubernetes.github.io/ingress-nginx/deploy/ 并尝试像 https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/ 一样配置 TCP
请注意- --tcp-services-configmap=rtmp/tcp-services
如果我通过端口 1936 推送数据,则无法建立连接。如果我尝试使用 1935,它会起作用。我想让 Ingress 控制器将流量路由到我的服务并摆脱 LoadBalancer
,因为让一个接一个的平衡器真的没有意义。
使用以下配置,我希望将数据发送到 1936 会起作用。
我错过了什么吗?
apiVersion: v1
kind: Service
Metadata:
name: restreamer1-service
namespace: rtmp
spec:
type: LoadBalancer
selector:
app: restreamer1-service
ports:
- protocol: TCP
port: 1935
targetPort: 1935
name: rtml-com
- protocol: TCP
port: 8080
targetPort: 8080
name: http-com
---
apiVersion: v1
kind: ConfigMap
Metadata:
name: tcp-services
namespace: rtmp
data:
1936: "rtmp/restreamer1-service:1935"
---
# Source: ingress-Nginx/templates/controller-deployment.yaml
apiVersion: apps/v1
kind: Deployment
Metadata:
labels:
helm.sh/chart: ingress-Nginx-3.23.0
app.kubernetes.io/name: ingress-Nginx
app.kubernetes.io/instance: ingress-Nginx
app.kubernetes.io/version: 0.44.0
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: controller
name: ingress-Nginx-controller
namespace: ingress-Nginx
spec:
selector:
matchLabels:
app.kubernetes.io/name: ingress-Nginx
app.kubernetes.io/instance: ingress-Nginx
app.kubernetes.io/component: controller
revisionHistoryLimit: 10
minReadySeconds: 0
template:
Metadata:
labels:
app.kubernetes.io/name: ingress-Nginx
app.kubernetes.io/instance: ingress-Nginx
app.kubernetes.io/component: controller
spec:
dnsPolicy: ClusterFirst
containers:
- name: controller
image: k8s.gcr.io/ingress-Nginx/controller:v0.44.0@sha256:3dd0fac48073beaca2d67a78c746c7593f9c575168a17139a9955a82c63c4b9a
imagePullPolicy: IfNotPresent
lifecycle:
preStop:
exec:
command:
- /wait-shutdown
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
- --tcp-services-configmap=rtmp/tcp-services
- --validating-webhook=:8443
- --validating-webhook-certificate=/usr/local/certificates/cert
- --validating-webhook-key=/usr/local/certificates/key
securityContext:
capabilities:
drop:
- ALL
add:
- NET_BIND_SERVICE
runAsUser: 101
allowPrivilegeEscalation: true
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldpath: Metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldpath: Metadata.namespace
- name: LD_PRELOAD
value: /usr/local/lib/libmimalloc.so
livenessProbe:
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 1
successthreshold: 1
failureThreshold: 5
readinessProbe:
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 1
successthreshold: 1
failureThreshold: 3
ports:
- name: http
containerPort: 80
protocol: TCP
- name: https
containerPort: 443
protocol: TCP
- name: webhook
containerPort: 8443
protocol: TCP
volumeMounts:
- name: webhook-cert
mountPath: /usr/local/certificates/
readOnly: true
resources:
requests:
cpu: 100m
memory: 90Mi
nodeselector:
kubernetes.io/os: linux
serviceAccountName: ingress-Nginx
terminationGracePeriodSeconds: 300
volumes:
- name: webhook-cert
secret:
secretName: ingress-Nginx-admission
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。