0

I have a Minikube instance installed on an Ubuntu VM (Digital Ocean). I have also configured ingress for one my deployments but when I curl the hostname I am getting an error :

curl myserver.xyz
curl: (7) Failed to connect to myserver.xyz port 80: Connection refused

My deployment :

apiVersion: v1
kind: Service
metadata:
  name: echo2
spec:
  ports:
  - port: 80
    targetPort: 5678
  selector:
    app: echo2
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: echo2
spec:
  selector:
    matchLabels:
      app: echo2
  replicas: 1
  template:
    metadata:
      labels:
        app: echo2
    spec:
      containers:
      - name: echo2
        image: hashicorp/http-echo
        args:
        - "-text=echo2"
        ports:
        - containerPort: 5678

And the ingress resource (deployed in same namespace) :

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: echo-ingress
  annotations: 
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: myserver.xyz
    http:
        paths:
        - pathType: Prefix
          path: "/"
          backend:
            service:
              name: echo1
              port:
                number: 80

My ingress is deployed using :

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

What I have tried so far --> 1. Changing the nginx service to type LoadBalancer :

 kubectl patch svc ingress-nginx-controller -n ingress-nginx -p '{"spec": {"type": "LoadBalancer", "externalIPs":["146.190.XXX.XXX"]}}'
  1. Checking status of ingress

     kubectl get ingress
     NAME              CLASS    HOSTS              ADDRESS        PORTS   AGE
     echo-ingress      <none>   myserver.xyz       192.168.XX.X   80      2d9h
     example-ingress   nginx    hello-world.info   192.168.XX.X   80      61d
    
  2. Checking status of the services

        kubectl get svc --namespace=ingress-nginx
        NAME                                 TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)                      AGE
      ingress-nginx-controller             LoadBalancer   10.108.xxx.XXX   146.190.XXX.XXX   
      80:317XX/TCP,443:320XX/TCP   2d23h
      ingress-nginx-controller-admission   ClusterIP      10.101.xxx.XXX   <none>            443/TCP 2d23h
  1. Checking the ingress definition
kubectl describe ingress echo-ingress
Name:             echo-ingress
Labels:           <none>
Namespace:        default
Address:          192.168.XX.X
Ingress Class:    <none>
Default backend:  <default>
Rules:
  Host             Path  Backends
  ----             ----  --------
  myserver.xyz
                   /   echo1:80 (XX.XXX.X.XXX:5678)
Annotations:       kubernetes.io/ingress.class: nginx
Events:
  Type    Reason  Age                  From                      Message
  ----    ------  ----                 ----                      -------
  Normal  Sync    131m                 nginx-ingress-controller  Scheduled for sync
  Normal  Sync    126m (x2 over 126m)  nginx-ingress-controller  Scheduled for sync
  Normal  Sync    108m                 nginx-ingress-controller  Scheduled for sync

I have already pointed the domain name and DNS A records to the DigitalOcean VM 's External IP Address.

I have also checked /etc/hosts and I added an entry for the domain as follows :

146.190.XXX.XXX    myserver.xyz

What am I missing?

Do I need to install metallb Minikube addon or its not applicable in this context ?

PS: I am following the example tutorial given here

Golide
  • 835
  • 3
  • 13
  • 36
  • 1
    If you use service type of LoadBalancer, you connect to the load balancer IP, not to the VMs IP. If you want to connect directly to the VM, your nginx ingress should be a service type of NodePort. – jordanm May 26 '23 at 15:06

1 Answers1

1

Per @jordanm

If you use service type of LoadBalancer, you connect to the load balancer IP, not to the VMs IP. If you want to connect directly to the VM, your nginx ingress should be a service type of NodePort.

James S
  • 1,181
  • 1
  • 7