https://rancher.com/ logo
Title
b

best-wall-17038

09/04/2022, 9:47 PM
Hi, When I use nginx ingress controller in rancher-desktop what should be the hostname ? I am getting an error when I would like to use IP i`s invalid: spec.rules[0].host: Invalid value: "192.168.178.38": must be a DNS name, not an IP address`
kubectl get svc -n nginx                                                                                                                                                                                                                                                                                                                              
NAME                  TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)                      AGE
nginx-nginx-ingress   LoadBalancer   10.43.49.252   192.168.178.38   80:32277/TCP,443:32004/TCP   50d
a

aloof-controller-49647

09/05/2022, 9:02 AM
The host should be set if you want to use something else than
localhost
. Host is not required.
b

best-wall-17038

09/05/2022, 9:06 AM
@aloof-controller-49647 but I could not able to access somehow even if I tried localhost or without host
I can able to access via port-forward but not with
192.168.178.38
.. What I am doing wrong?
a

aloof-controller-49647

09/05/2022, 11:31 AM
Did you disable traefik?
b

best-wall-17038

09/05/2022, 11:31 AM
yeah worked after i refactor my ingress
a

aloof-controller-49647

09/05/2022, 11:32 AM
So it is fixed? If yes, what did you do?
b

best-wall-17038

09/05/2022, 11:32 AM
I changed my ingress resource and add some annotations
a

aloof-controller-49647

09/05/2022, 11:32 AM
Could you specify the changes explicitly?
It might be helpful for others.
b

best-wall-17038

09/05/2022, 11:33 AM
this is how it looks like now
apiVersion: <http://networking.k8s.io/v1|networking.k8s.io/v1>
kind: Ingress
metadata:
  name: {{ include "frontend-service.fullname" . }}
  namespace: comnext
  annotations:
    <http://kubernetes.io/ingress.class|kubernetes.io/ingress.class>: "nginx"
    <http://nginx.ingress.kubernetes.io/service-upstream|nginx.ingress.kubernetes.io/service-upstream>: "true"
    <http://nginx.ingress.kubernetes.io/configuration-snippet|nginx.ingress.kubernetes.io/configuration-snippet>: |
      proxy_set_header l5d-dst-override frontend-service.comnext.svc.cluster.local;
      proxy_hide_header l5d-remote-ip;
      proxy_hide_header l5d-server-id;
spec:
  rules:
    - host: localhost
      http:
        paths:
          - backend:
              service:
                name: frontend-service
                port:
                  number: 80
            path: /
            pathType: ImplementationSpecific
a

aloof-controller-49647

09/05/2022, 11:33 AM
­čĺ¬
o

orange-tent-50778

09/06/2022, 12:40 PM
Note that if you run
kubectl explain --api-version=<http://networking.k8s.io/v1|networking.k8s.io/v1> Ingress.spec.ingressClassName
you will see:
DESCRIPTION:
     IngressClassName is the name of the IngressClass cluster resource. The
     associated IngressClass defines which controller will implement the
     resource. This replaces the deprecated `<http://kubernetes.io/ingress.class|kubernetes.io/ingress.class>`
     annotation.
So at some point, you will need to remove the
<http://kubernetes.io/ingress.class|kubernetes.io/ingress.class>
annotation and change your
spec
section to:
spec:
  ingressClassName: nginx
  rules:
    - host: localhost
      http:
        paths:
          - backend:
              service:
                name: frontend-service
                port:
                  number: 80
            path: /
            pathType: ImplementationSpecific
b

best-wall-17038

09/06/2022, 3:09 PM
@orange-tent-50778 you re right.. By the way, when I remove localhost, i am getting an error that host required.. Should I speficy the host in rancher-desktop to access my app
o

orange-tent-50778

09/06/2022, 4:07 PM
I don't know if this is the best approach but this is that I have setup for our project (the project is called The Combine which will help explain some of the names):
apiVersion: <http://networking.k8s.io/v1|networking.k8s.io/v1>
kind: Ingress
metadata:
  annotations:
    <http://cert-manager.io/duration|cert-manager.io/duration>: 2160h
    <http://cert-manager.io/issuer|cert-manager.io/issuer>: self-signed
    <http://cert-manager.io/renew-before|cert-manager.io/renew-before>: 720h
    <http://nginx.ingress.kubernetes.io/proxy-body-size|nginx.ingress.kubernetes.io/proxy-body-size>: 250m
  creationTimestamp: "2022-09-05T14:23:41Z"
  generation: 1
  name: thecombine
  namespace: thecombine
  resourceVersion: "4294"
  uid: 7dbe724d-a005-4bce-9d89-a104507b93fc
spec:
  ingressClassName: nginx
  rules:
  - host: thecombine.local
    http:
      paths:
      - backend:
          service:
            name: frontend
            port:
              number: 80
        path: /
        pathType: Prefix
  tls:
  - hosts:
    - thecombine.local
    secretName: thecombine-local-tls
status:
  {}
I am using helm so I removed the parts added by it. I am also using cert-manager.io to create a self-signed certificate. Secondly, I have updated my
/etc/hosts
to contain:
127.0.0.1	localhost thecombine.local
Last of all, I setup the port forwarding in Rancher Desktop to forward 37700 to the
ingress-nginx
https port. Now I can access my front end by navigating to
<https://thecombine.local:37700>
. Since it has a self-signed certificate, I need to assure the browser that I know what I am doing and accept the risk.
b

best-wall-17038

09/06/2022, 5:03 PM
How do you access backend services if you have any frotnend service ?
Somehow I could not able to do this
@orange-tent-50778 how frontend service access another backend services in rancher-desktop?