title: Kubernetes Redis Cluster issue
body: <p>I'm trying to create redis cluster using kubernetes on centos. I have my kubernetes master running on one host and kubernetes slaves on 2 different hosts.</p>
  <blockquote>
  <p>etcdctl get /kube-centos/network/config</p>
  </blockquote>
  <pre><code>{ &quot;Network&quot;: &quot;172.30.0.0/16&quot;, &quot;SubnetLen&quot;: 24, &quot;Backend&quot;: { &quot;Type&quot;: &quot;vxlan&quot; } }
  </code></pre>
  <p>Here is my replication controller</p>
  <pre><code>apiVersion: v1
  kind: ReplicationController
  metadata:
    name: redis-master
    labels:
    app: redis
    role: master
    tier: backend
  spec:
    replicas: 6
    template:
      metadata:
        labels:
          app: redis
          role: master
          tier: backend
      spec:
        containers:
        - name: master
          image: redis
          command: 
            - &quot;redis-server&quot;
          args:
            - &quot;/redis-master/redis.conf&quot;
          ports:
          - containerPort: 6379
          volumeMounts:
          - mountPath: /redis-master
            name: config
          - mountPath: /redis-master-data 
            name: data
          volumes:
          - name: data
            emptyDir: {}
          - name: config
            configMap:
              name: redis-config
              items:
              - key: redis-config
                path: redis.conf    
  </code></pre>
  <blockquote>
  <p>kubectl create -f rc.yaml</p>
  </blockquote>
  <pre><code>NAME                           READY     STATUS    RESTARTS   AGE       IP            NODE
  redis-master-149tt             1/1       Running   0          8s        172.30.96.4   centos-minion-1
  redis-master-14j0k             1/1       Running   0          8s        172.30.79.3   centos-minion-2
  redis-master-3wgdt             1/1       Running   0          8s        172.30.96.3   centos-minion-1
  redis-master-84jtv             1/1       Running   0          8s        172.30.96.2   centos-minion-1
  redis-master-fw3rs             1/1       Running   0          8s        172.30.79.4   centos-minion-2
  redis-master-llg9n             1/1       Running   0          8s        172.30.79.2   centos-minion-2
  </code></pre>
  <p>Redis-config file used</p>
  <pre><code>appendonly yes
  cluster-enabled yes
  cluster-config-file /redis-master/nodes.conf
  cluster-node-timeout 5000
  dir /redis-master
  port 6379
  </code></pre>
  <p>I used the following command to create the kubernetes service.</p>
  <blockquote>
  <p>kubectl expose rc redis-master --name=redis-service --port=6379 --target-port=6379 --type=NodePort</p>
  </blockquote>
  <pre><code>Name:           redis-service
  Namespace:      default
  Labels:         app=redis
                  role=master
                  tier=backend
  Selector:       app=redis,role=master,tier=backend
  Type:           NodePort
  IP:             10.254.229.114
  Port:           &lt;unset&gt; 6379/TCP
  NodePort:       &lt;unset&gt; 30894/TCP
  Endpoints:      172.30.79.2:6379,172.30.79.3:6379,172.30.79.4:6379 + 3     more...
  Session Affinity:   None
  No events.
  </code></pre>
  <p>Now I have all the pods and service up and running. I'm using redis-trib pod to create redis cluster.</p>
  <blockquote>
  <p>kubectl exec -it redis-trib bash</p>
  <p>./redis-trib.rb create --replicas 1 172.30.79.2:6379 172.30.79.3:6379 172.30.79.4:6379 172.30.96.2:6379 172.30.96.3:6379 172.30.96.4:6379</p>
  </blockquote>
  <p>Redis Cluster created as expected with the below message.</p>
  <pre><code>[OK] All 16384 slots covered.
  </code></pre>
  <p>Now I should be able to access my redis-cluster on kubernetes node IP(192.168.240.116) and nodePort(30894) from any host within my network. Everything works as expected when I execute the below command from one of the kubernetes node.</p>
  <blockquote>
  <p>redis-cli -p 30894 -h 192.168.240.116 -c</p>
  </blockquote>
  <pre><code>192.168.240.116:30894&gt; set foo bar
  -&gt; Redirected to slot [12182] located at 172.30.79.4:6379
  OK
  172.30.79.4:6379&gt; 
  </code></pre>
  <p>When I run the same command from different (non-kubernetes) node within the same network, I see the connected timed out error.</p>
  <blockquote>
  <p>redis-cli -c -p 30894 -h 192.168.240.116</p>
  </blockquote>
  <pre><code>192.168.240.116:30894&gt; set foo bar
  -&gt; Redirected to slot [12182] located at 172.30.79.4:6379
  Could not connect to Redis at 172.30.79.4:6379: Connection timed out
  </code></pre>
  <p>Is it not possible to access the redis-cluster outside the kubernetes cluster network when exposed using <strong>NodePort</strong> service type?</p>
  <p>Also I cannot use <strong>LoadBalancer</strong> service type as I'm not hosting it on cloud.</p>
  <p>I have been stuck with this issue for quite a while. Can someone suggest on what approach I should use to access my redis-cluster outside my network ?</p>
  <p>Thanks</p>