installing nginx-ingress on Kubernetes to run on localhost MacOs - Docker for Mac(Edge)

1/18/2018

Update:

I got the NodePort to work: kubectl get services

NAME                                       TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
kubernetes                                 ClusterIP   10.96.0.1       <none>        443/TCP                      7d
my-release-nginx-ingress-controller        NodePort    10.105.64.135   <none>        80:32706/TCP,443:32253/TCP   10m
my-release-nginx-ingress-default-backend   ClusterIP   10.98.230.24    <none>        80/TCP                       10m

Do I port-forward then?

Installing Ingress using Helm on Docker for Mac(Edge with Kubernetes)

https://github.com/kubernetes/charts/tree/master/stable/nginx-ingress

Will this work on localhost - and if so, how to access a service?

Steps:

  1. helm install stable/nginx-ingress

Output:

NAME:   washing-jackal
LAST DEPLOYED: Thu Jan 18 12:57:40 2018
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/ConfigMap
NAME                                     DATA  AGE
washing-jackal-nginx-ingress-controller  1     1s

==> v1/Service
NAME                                          TYPE          CLUSTER-IP     EXTERNAL-IP  PORT(S)                     AGE
washing-jackal-nginx-ingress-controller       LoadBalancer  10.105.122.1   <pending>    80:31494/TCP,443:32136/TCP  1s
washing-jackal-nginx-ingress-default-backend  ClusterIP     10.103.189.14  <none>       80/TCP                      1s

==> v1beta1/Deployment
NAME                                          DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
washing-jackal-nginx-ingress-controller       1        1        1           0          0s
washing-jackal-nginx-ingress-default-backend  1        1        1           0          0s

==> v1/Pod(related)
NAME                                                           READY  STATUS             RESTARTS  AGE
washing-jackal-nginx-ingress-controller-5b4d86c948-xxlrt       0/1    ContainerCreating  0         0s
washing-jackal-nginx-ingress-default-backend-57947f94c6-h4sz6  0/1    ContainerCreating  0         0s


NOTES:
The nginx-ingress controller has been installed.
It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status by running 'kubectl --namespace default get services -o wide -w washing-jackal-nginx-ingress-controller'

An example Ingress that makes use of the controller:

  apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    annotations:
      kubernetes.io/ingress.class: nginx
    name: example
    namespace: foo
  spec:
    rules:
      - host: www.example.com
        http:
          paths:
            - backend:
                serviceName: exampleService
                servicePort: 80
              path: /
    # This section is only required if TLS is to be enabled for the Ingress
    tls:
        - hosts:
            - www.example.com
          secretName: example-tls

If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided:

  apiVersion: v1
  kind: Secret
  metadata:
    name: example-tls
    namespace: foo
  data:
    tls.crt: <base64 encoded cert>
    tls.key: <base64 encoded key>
  type: kubernetes.io/tls
-- Chris G.
kubernetes
kubernetes-helm

2 Answers

4/24/2018

To see the app running, you need to go to localhost:port to see your service if you're on minikube. Or use your computer name instead of localhost if you're on a different computer in your network. If you're using VM's, use the node's VM IP in the browser instead of localhost.

-- anweb
Source: StackOverflow

1/18/2018

As far as I can tell from the output you posted, everything should be running smoothly in your local kubernetes cluster.

However, your ingress controller is exposed using a LoadBalancer Service as you can tell from the following portion of the output you posted:

==> v1/Service
NAME                                          TYPE          CLUSTER-IP     EXTERNAL-IP  PORT(S)                     AGE
washing-jackal-nginx-ingress-controller       LoadBalancer  10.105.122.1   <pending>    80:31494/TCP,443:32136/TCP  1s 

Services of type LoadBalancer require support from the underlying infrastructure, and will not work in your local environment.

However, a LoadBalancer service is also a NodePort Service. In fact you can see in the above snippet of output that your ingress controller is listening to the following ports:

80:31494/TCP,443:32136/TCP

This means you should be able to reach your ingress controller on port 31494 and 32136 on your node's ip address.

You could make your ingress controller listen to more standard ports, such as 80 and 443, but you'll probably have to edit manually the resources created by the helm chart to do so.

-- whites11
Source: StackOverflow