-2

I got the following code that uses ingress-nginx within infra\k8s-dev\ingress-srv.yaml file.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  rules:
    - host: mysite.local
      http:
        paths:
          - path: /api/users/?(.*)
            pathType: Prefix
            backend:
              service:
                name: auth-srv
                port:
                  number: 3000
          - path: /?(.*)
            pathType: Prefix
            backend:
              service:
                name: client-srv
                port:
                  number: 3000

I searched through the internet and found the following command to install it:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.4.0/deploy/static/provider/cloud/deploy.yaml

But I am not sure where should I run this command? Is there any ingress-nginx package that I also must install from NPM?

I am using Docker-Desktop on Windows 10 machine.

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
GoodMan
  • 542
  • 6
  • 19

1 Answers1

2

Command you have mentioned is right

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.4.0/deploy/static/provider/cloud/deploy.yaml

it self will download and apply the YAML config from URL, it will deploy the Nginx controller. Nginx ingress controller will manage the Ingress you are creating above.

Ingress is rule to divert the traffic and controller manages these rules (ingress).

So just running the apply to K8s cluster context will download and start the PODs of the Nginx controller.

as you mentioned in your ingress annotation

kubernetes.io/ingress.class: nginx

that specific ingress rule will get connected or managed by nginx controller.

inside the ingress you have mentioned mysite.local so make sure in local setup host file you are mapping the domain to IP.

Once controller is up and running opening the URL (mysite.local) into the browser will show the site.

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102