title: Exposing UDP and TCP ports for sftp server using Ingress in GKE
body: <p>I am trying to set up a multi-cluster deployment in which there are multiple clusters and one ingress is load balancing the requests between them.</p>
  
  <p>HTTP services work well with the set-up the problem here is the <code>sftp</code> server.</p>
  
  <p>Referring to this <a href="https://stackoverflow.com/questions/49439899/kubernetes-routing-non-http-request-via-ingress-to-container">answer</a> and this <a href="https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/" rel="nofollow noreferrer">documentation</a> I am trying to access port 22 of the <code>sftp</code> service.</p>
  
  <p>Deployment of sftp is being exposed on port 22. Below is the manifest:</p>
  
  <pre><code>kind: Deployment
  apiVersion: extensions/v1beta1
  metadata:
    name: sftp
    labels:
      environment: production
      app: sftp
  spec:
    replicas: 1
    minReadySeconds: 10
    template:
      metadata:
        labels:
          environment: production
          app: sftp
        annotations:
          container.apparmor.security.beta.kubernetes.io/sftp: runtime/default
      spec:
        containers:
          - name: sftp
            image: atmoz/sftp:alpine
            imagePullPolicy: Always
            args: ["user:1001:100:upload"]
            ports:
              - containerPort: 22
            securityContext:
              capabilities:
                add: ["SYS_ADMIN"]
            resources: {}
  
  </code></pre>
  
  <p><br></p>
  
  <p>Here is the simple manifest for the sftp-service using NodePort service:</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    labels:
      environment: production
    name: sftp-service
  spec:
    type: NodePort
    ports:
    - name: sftp-port
      targetPort: 9000
      port: 9000
      nodePort: 30063
      protocol: TCP
    selector:
      app: sftp
  </code></pre>
  
  <p>ConfigMap create to referring to the above mentioned documentation and answer looks like below:</p>
  
  <pre><code>apiVersion: v1
  kind: ConfigMap
  metadata:
    name: sftp-service
  data:
    9000: "default/sftp-service:22"
  </code></pre>
  
  <p>And finally the ingress manifest is something like below:</p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: ingress-foo
    annotations:
      kubernetes.io/ingress.global-static-ip-name: static-ip
      kubernetes.io/ingress.class: gce-multi-cluster
  spec:
    backend:
      serviceName: http-service-zone-printer
      servicePort: 80
    rules:
    - http:
        paths:
        - path: /sftp
          backend:
            serviceName: sftp-service
            servicePort: 22
    template:
      spec:
        containers:
          - name: proxy-port
            args:
              - "--tcp-services-configmap=default/sftp-service"
  </code></pre>
  
  <p>I feel, I have not understood the way to expose the TCP/UDP port for sftp server on kubernetes using ingress. What am I doing wrong here?</p>
  
  <p>Is there any other way to simple setup an <code>sftp</code> using ingress and NodePort service in a multicluster deployment?</p>
  
  <p><a href="https://cloud.google.com/kubernetes-engine/docs/how-to/multi-cluster-ingress" rel="nofollow noreferrer">Here</a> is the official document I am referring to do the set-up.</p>