ingress-controller tcp转发

此yaml测试可用

ingress 不支持tcp转发,可以使用ingress-controller来做tcp转发
例如:
apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-tcp-ingress-configmap
data:
  7077: "default/sparkdingtest-master:7077"
  6066: "default/sparkdingtest-master:6066"
---
---
apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx-ingress-controller
  labels:
    k8s-app: nginx-ingress-lb
spec:
  replicas: 1
  selector:
    k8s-app: nginx-tcp-ingress-lb
  template:
    metadata:
      labels:
        k8s-app: nginx-tcp-ingress-lb
        name: nginx-tcp-ingress-lb
    spec:
      terminationGracePeriodSeconds: 60
      hostNetwork: true
      serviceAccountName: ingress
      containers:
      - image: registry.cn-hangzhou.aliyuncs.com/souban/nginx-ingress-controller:0.9.0-beta.10
        name: nginx-tcp-ingress-lb
        env:
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
        ports:
        - containerPort: 80
          hostPort: 80
        - containerPort: 6066
          hostPort: 6066
        - containerPort: 7077 
          hostPort: 7077
        args:
        - /nginx-ingress-controller
        - --default-backend-service=$(POD_NAMESPACE)/default-http-backend
        - --tcp-services-configmap=$(POD_NAMESPACE)/nginx-tcp-ingress-configmap

你可能感兴趣的:(Kubernetes)