Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 303
Chris G. Avatar asked Jan 18 '18 12:01

Chris G.


People also ask

How do I use nginx ingress controller with Kubernetes?

Nginx ingress controller by Nginx Inc We will be using the Nginx controller from the kubernetes community. Ingress controller needs a specific namespace, service account, cluster role bindings, configmaps etc. You can create all the kubernetes objects mentioned using the yaml file from official ingress repo.

How do I set up Nginx ingress on Mac?

Start by creating the “mandatory” resources for Nginx Ingress in your cluster. Then, enable the ingress add-on for Minikube. Or, if you’re using Docker for Mac to run Kubernetes instead of Minikube. Check that it’s all set up correctly. This has set up the Nginx Ingress Controller.

How do I set up Nginx ingress on a minikube cluster?

Assuming you have Kubernetes and Minikube (or Docker for Mac) installed , follow these steps to set up the Nginx Ingress Controller on your local Minikube cluster. Start by creating the “mandatory” resources for Nginx Ingress in your cluster. Then, enable the ingress add-on for Minikube.

How many Nginx ingress controllers are there?

There are two nginx ingress controllers. We will be using the Nginx controller from the kubernetes community. Ingress controller needs a specific namespace, service account, cluster role bindings, configmaps etc.


1 Answers

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.

like image 126
whites11 Avatar answered Sep 28 '22 11:09

whites11