0

Kubernetes is based on ubuntu.When I run the application, the address part of ingress is empty.

service.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    app: docker-testmrv
  name: docker-testmrv-service
  namespace: jenkins
spec:
  selector:
    app: docker-testmrv
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8093
   type: LoadBalancer

ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  labels:
    app: docker-testmrv
  name: docker-testmrv-ingress
  namespace: jenkins
spec:
  rules:
    - host: dockertest.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: docker-testmrv-service
                port:
                  number: 80
      ingressClassName: nginx

As you can see in the picture below, the hosts part is empty.I also tried the following in the annotation section, but it didn't work. I've looked and tried other sources as well.

    nginx.ingress.kubernetes.io/rewrite-target: /$1 
or
    ingressclass.kubernetes.io/is-default-class: "true"
or
    kubernetes.io/ingressClassName: nginx

kubectl get ing -n jenkins

enter image description here

enter image description here

island
  • 43
  • 1
  • 11

1 Answers1

0

First we need to ensure nginx enabled and nginx-ingress-controller pod in running status.

Follow below steps to verify :

  • Enable the NGINX Ingress controller, run the following command:

    minikube addons enable ingress

  • Verify that the NGINX Ingress controller is running

    kubectl get pods -n kube-system

As per your YAML, For ingress rule, change the port servicePort from 8093 to 80 the default http port.

Now apply those files and create your pods, service and ingress rule. Wait a few moments, it will take a few moments to get ADDRESS for your ingress rule.

Refer this SO Link

Updated Answer :

Do Nodes have an external ip by default?

If you're using public nodes, each node will have a different public IP and can change every time a node is recreated.

So, Make sure you use the service type as Load balancer to get an external IP on your ingress . NodePort opens any one of the available ports. You can also use NodePort but it might not give you an external IP though instead give a port that will be opened on all the nodes.

Refer this Link to get the difference between cluster IP Node Port and Load balancer different from each other.

Create the service type as Load balancer and add the last line ingressClassName: nginx definition to your ingress yaml. This will work. Refer to this SO

Hemanth Kumar
  • 2,728
  • 1
  • 4
  • 19
  • I tried what you wrote but it didn't work.Do Nodes have external ip by default? I tried to work on Node. @Hemanth Kumar – island Nov 02 '22 at 05:32
  • @island : I have updated the answer . Feel free to check and let me know if you are facing any errors. – Hemanth Kumar Nov 02 '22 at 08:19
  • I have updated the question.I created the service type as Load balancer.I fixed it according to what you said above.I added the last line ingressClassName: nginx defination and it's not work!I really tried a lot. @Hemanth Kumar – island Nov 03 '22 at 10:48
  • apiVersion: v1 kind: Service metadata: labels: app: docker-testmrv name: docker-testmrv-service namespace: jenkins spec: selector: app: docker-testmrv ports: - protocol: TCP port: 80 targetPort: 8093 type: LoadBalancer. ==> use this service Yaml and let me know the errors you are getting, so that i can help you out with an appropriate solution. – Hemanth Kumar Nov 03 '22 at 11:58
  • I have updated the service.yaml. kubectl get svc docker-testmrv-service -n jenkins => external-ıp =>none and kubectl get ingress -n jenkins => adress empty. I tried what you wrote but it still didn't work.@Hemanth Kumar – island Nov 03 '22 at 12:49
  • @island : Im replicating your issue and will update the solution asap while you have look into this [doc](https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer#visiting_your_application) and try the changes. – Hemanth Kumar Nov 04 '22 at 09:40
  • I am not using cloud service.I have master and worker nodes on Ubuntu.@Hemanth Kumar – island Nov 04 '22 at 10:47
  • There may be an error in the ingress installation. I will reinstall it.thank you for your help.@Hemanth Kumar – island Nov 05 '22 at 09:45
  • @island : Have you reinstalled ? is that ingress working ? If your issue is solved , can you please provide the resolution steps you have followed and provide it as an answer for the greater visibility of the community. – Hemanth Kumar Nov 09 '22 at 08:20