title: Why does my bare-metal kubernetes nginx Ingress-controller return a 308?
body: <p>I am trying to create add the nginx ingress controller to my kubernetes cluster. My current cluster has 3 nodes and they all have open firewall rules in between them. (Note: This is a bare metal cluster for educational purposes) </p>
  
  <p>I have created a deployment with the following config</p>
  
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: nodejs-test
    labels:
      app: nodejs
  spec:
    replicas: 5
    selector:
      matchLabels:
        app: nodejs
    template:
      metadata:
        labels:
          app: nodejs
      spec:
        containers:
        - name: nodejs-container
          image: gcr.io/infrastructure/test-nodejs-server
          ports:
          - containerPort: 3000
  ---
  apiVersion: v1
  kind: Service
  metadata:
    name: test-deployment-service
  spec:
    selector:
      app: nodejs
    ports:
    - protocol: TCP
      port: 80
      targetPort: 3000
  </code></pre>
  
  <p>After running kubectl create -f file.yaml</p>
  
  <p>I see all pods and services running. Within the cluster I can curl that service ip and get a response from the pods.</p>
  
  <p>Now I go to create a ingress.</p>
  
  <p>I first followed the install steps found at <a href="https://github.com/kubernetes/ingress-nginx/tree/master/deploy" rel="noreferrer">https://github.com/kubernetes/ingress-nginx/tree/master/deploy</a></p>
  
  <p>I can see my ingress controller running. </p>
  
  <pre><code>    NAMESPACE       NAME                                         READY     STATUS    RESTARTS   AGE
  default         my-test-6445d9bb7b-blm7t                     1/1       Running   0          3h
  default         nodejs-test-5657f7bb74-7hwqk                 1/1       Running   0          23h
  default         nodejs-test-5657f7bb74-bh44x                 1/1       Running   0          23h
  default         nodejs-test-5657f7bb74-dw4g4                 1/1       Running   0          23h
  default         nodejs-test-5657f7bb74-k7bf4                 1/1       Running   0          23h
  default         nodejs-test-5657f7bb74-xdthl                 1/1       Running   0          23h
  ingress-nginx   default-http-backend-55c6c69b88-4d5bf        1/1       Running   0          26m
  ingress-nginx   nginx-ingress-controller-5c6698dfbf-gs9zd    1/1       Running   0          25m
  kube-system     etcd-yoda.me.com                      1/1       Running   1          1d
  kube-system     kube-apiserver-yoda.me.com            1/1       Running   1          1d
  kube-system     kube-controller-manager-yoda.me.com   1/1       Running   1          1d
  kube-system     kube-dns-6f4fd4bdf-62bxg                     3/3       Running   3          1d
  kube-system     kube-flannel-ds-jbmwg                        1/1       Running   1          1d
  kube-system     kube-flannel-ds-r8nfb                        1/1       Running   2          1d
  kube-system     kube-flannel-ds-rczbx                        1/1       Running   0          1d
  kube-system     kube-proxy-brm2g                             1/1       Running   0          1d
  kube-system     kube-proxy-qjgcv                             1/1       Running   1          1d
  kube-system     kube-proxy-sz6rw                             1/1       Running   1          1d
  kube-system     kube-scheduler-yoda.me.com            1/1       Running   1          1d
  kube-system     kubernetes-dashboard-5bd6f767c7-stscl        1/1       Running   1          23h
  kube-system     tiller-deploy-59d854595c-tngg6               1/1       Running   0          23h
  </code></pre>
  
  <p>I then create my ingress with the following file</p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: test-ingress
    annotations:
      ingress.kubernetes.io/rewrite-target: /
      kubernetes.io/ingress.class: "nginx"
  spec:
    rules:
    - http:
        paths:
        - path: /whoop
          backend:
            serviceName: test-deployment-service
            servicePort: 80
  </code></pre>
  
  <p>Then I run kubectl get services --all-namespaces to find my ingress controller port.</p>
  
  <pre><code>NAMESPACE       NAME                      TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
  default         kubernetes                ClusterIP   10.96.0.1        &lt;none&gt;        443/TCP                      1d
  default         my-test                   ClusterIP   10.110.102.5     &lt;none&gt;        80/TCP                       4h
  default         test-deployment-service   ClusterIP   10.104.239.37    &lt;none&gt;        80/TCP                       23h
  ingress-nginx   default-http-backend      ClusterIP   10.105.218.87    &lt;none&gt;        80/TCP                       29m
  ingress-nginx   ingress-nginx             NodePort    10.110.39.104    &lt;none&gt;        80:30652/TCP,443:31624/TCP   27m
  kube-system     kube-dns                  ClusterIP   10.96.0.10       &lt;none&gt;        53/UDP,53/TCP                1d
  kube-system     kubernetes-dashboard      ClusterIP   10.100.219.110   &lt;none&gt;        443/TCP                      23h
  kube-system     tiller-deploy             ClusterIP   10.101.179.202   &lt;none&gt;        44134/TCP                    23h
  </code></pre>
  
  <p>Now I go to curl my server:</p>
  
  <pre><code>curl -v myserver:30652/whoop/
  </code></pre>
  
  <p>The resulting response is: </p>
  
  <pre><code>*   Trying myip...
  * TCP_NODELAY set
  * Connected to myserver (myip) port 30652 (#0)
  &gt; GET /whoop/ HTTP/1.1
  &gt; Host: myserver:30652
  &gt; User-Agent: curl/7.54.0
  &gt; Accept: */*
  &gt; 
  &lt; HTTP/1.1 308 Permanent Redirect
  &lt; Server: nginx/1.13.9
  &lt; Date: Fri, 02 Mar 2018 14:38:21 GMT
  &lt; Content-Type: text/html
  &lt; Content-Length: 187
  &lt; Connection: keep-alive
  &lt; Location: https://myserver:30652/whoop/
  &lt; Strict-Transport-Security: max-age=15724800; includeSubDomains;
  &lt; 
  &lt;html&gt;
  &lt;head&gt;&lt;title&gt;308 Permanent Redirect&lt;/title&gt;&lt;/head&gt;
  &lt;body bgcolor="white"&gt;
  &lt;center&gt;&lt;h1&gt;308 Permanent Redirect&lt;/h1&gt;&lt;/center&gt;
  &lt;hr&gt;&lt;center&gt;nginx/1.13.9&lt;/center&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  * Connection #0 to host myserver left intact
  </code></pre>
  
  <p>I would expect to be getting the response from my pods. However I always get the 308. </p>
  
  <p>If I curl a random path</p>
  
  <p>curl myserver:30652/random</p>
  
  <p>The response I get is </p>
  
  <pre><code>default backend - 404
  </code></pre>
  
  <p>How can I hook up my ingress and ingress controller for the routing to work correctly?</p>