<p>Hello when I use node port to expose my redis service it works fine. I am able to access it.
But if I try switch to Ingress Nginx controller it refuse to connect.. Other apps work fine with ingress.</p>
<p>Here is my service:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: redis-svc
spec:
#  type: NodePort
  ports:
    - name: http
      port: 6379
      targetPort: 6379
      protocol: TCP
#      nodePort: 30007
  selector:
    app: redis
</code></pre>
<p>And here is ingress:</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: redis-ing
  annotations:
     kubernetes.io/ingress.class: &quot;nginx&quot;
     ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
     nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
     nginx.ingress.kubernetes.io/force-ssl-redirect: &quot;true&quot;
     cert-manager.io/cluster-issuer: &quot;letsencrypt-prod&quot;
    #  nginx.ingress.kubernetes.io/enable-cors: &quot;true&quot;
    #  nginx.ingress.kubernetes.io/cors-allow-methods: &quot;PUT, GET, POST, OPTIONS&quot;
    #  nginx.ingress.kubernetes.io/cors-allow-origin: &quot;https://test.hefest.io&quot;
    #  nginx.ingress.kubernetes.io/cors-allow-credentials: &quot;true&quot;
spec:
  tls:
  - secretName: letsencrypt-prod
    hosts:
      - redis-dev.domain.com
  rules:
  - host: redis-dev.domain.com
    http:
      paths:
      - path: /
        backend:
          serviceName: redis-svc
          servicePort: 6379
</code></pre>
<p>Any idea what can be an issue?</p>
<p>I am using this ingress controller: <a href="https://github.com/nginxinc/kubernetes-ingress" rel="noreferrer">https://github.com/nginxinc/kubernetes-ingress</a></p>

<p>Redis works on 6379 which is non HTTP port(80,443). So you need to enable <a href="https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/" rel="noreferrer">TCP/UDP support</a> in nginx ingress controller. The minikube docs <a href="https://minikube.sigs.k8s.io/docs/tutorials/nginx_tcp_udp_ingress/" rel="noreferrer">here</a> shows how to do it for redis.</p>
<p><strong>Update the TCP and/or UDP services configmaps</strong></p>
<p>Borrowing from the tutorial on configuring TCP and UDP services with the ingress nginx controller we will need to edit the configmap which is installed by default when enabling the minikube ingress addon.</p>
<p>There are 2 configmaps, 1 for TCP services and 1 for UDP services. By default they look like this:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: tcp-services
  namespace: ingress-nginx
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: udp-services
  namespace: ingress-nginx
</code></pre>
<p>Since these configmaps are centralized and may contain configurations, it is best if we only patch them rather than completely overwrite them.</p>
<p>Let’s use this redis deployment as an example:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-deployment
  namespace: default
  labels:
    app: redis
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
      - image: redis
        imagePullPolicy: Always
        name: redis
        ports:
        - containerPort: 6379
          protocol: TCP
</code></pre>
<p>Create a file <code>redis-deployment.yaml</code> and paste the contents above. Then install the redis deployment with the following command:</p>
<pre><code>kubectl apply -f redis-deployment.yaml
</code></pre>
<p>Next we need to create a service that can route traffic to our pods:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: redis-service
  namespace: default
spec:
  selector:
    app: redis
  type: ClusterIP
  ports:
    - name: tcp-port
      port: 6379
      targetPort: 6379
      protocol: TCP
</code></pre>
<p>Create a file <code>redis-service.yaml</code> and paste the contents above. Then install the redis service with the following command:</p>
<pre><code>kubectl apply -f redis-service.yaml
</code></pre>
<p>To add a TCP service to the nginx ingress controller you can run the following command:</p>
<pre><code>kubectl patch configmap tcp-services -n kube-system --patch '{&quot;data&quot;:{&quot;6379&quot;:&quot;default/redis-service:6379&quot;}}'
</code></pre>
<p>Where:</p>
<p><code>6379</code> : the port your service should listen to from outside the minikube virtual machine</p>
<p><code>default</code> : the namespace that your service is installed in</p>
<p><code>redis-service</code> : the name of the service</p>
<p>We can verify that our resource was patched with the following command:</p>
<pre><code>kubectl get configmap tcp-services -n kube-system -o yaml
</code></pre>
<p>We should see something like this:</p>
<pre><code>apiVersion: v1
data:
  &quot;6379&quot;: default/redis-service:6379
kind: ConfigMap
metadata:
  creationTimestamp: &quot;2019-10-01T16:19:57Z&quot;
  labels:
    addonmanager.kubernetes.io/mode: EnsureExists
  name: tcp-services
  namespace: kube-system
  resourceVersion: &quot;2857&quot;
  selfLink: /api/v1/namespaces/kube-system/configmaps/tcp-services
  uid: 4f7fac22-e467-11e9-b543-080027057910
</code></pre>
<p>The only value you need to validate is that there is a value under the data property that looks like this:</p>
<pre><code>&quot;6379&quot;: default/redis-service:6379
</code></pre>
<p><strong>Patch the ingress-nginx-controller</strong></p>
<p>There is one final step that must be done in order to obtain connectivity from the outside cluster. We need to patch our nginx controller so that it is listening on port 6379 and can route traffic to your service. To do this we need to create a patch file.</p>
<pre><code>spec:
  template:
    spec:
      containers:
      - name: ingress-nginx-controller
        ports:
         - containerPort: 6379
           hostPort: 6379
</code></pre>
<p>Create a file called <code>ingress-nginx-controller-patch.yaml</code> and paste the contents above.</p>
<p>Next apply the changes with the following command:</p>
<pre><code>kubectl patch deployment ingress-nginx-controller --patch &quot;$(cat ingress-nginx-controller-patch.yaml)&quot; -n kube-system
</code></pre>
