1

my problem is why ingress doesnt assigne an Address for the services?

first of all i create 3 deployments:

kubectl create deployment cheddar --image=errm/cheese:cheddar
kubectl create deployment stilton --image=errm/cheese:stilton
kubectl create deployment wensleydale --image=errm/cheese:wensleydale

second of all i expose those 3 deployment:

kubectl expose deployment cheddar --port=80                  
kubectl expose deployment stilton --port=80                  
kubectl expose deployment wensleydale --port=80

then i apply my ingress.yaml with kubectl apply -f ingress.yaml, the ingress.yaml content is:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: cheddar
spec:
  ingressClassName: nginx
  rules:
  - host: cheddar.127.0.0.1.nip.io
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: cheddar
            port:
              number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: stilton
spec:
  ingressClassName: nginx
  rules:
  - host: stilton.127.0.0.1.nip.io
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: stilton
            port:
              number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: wensleydale
spec:
  ingressClassName: nginx
  rules:
  - host: wensleydale.127.0.0.1.nip.io
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: wensleydale
            port:
              number: 80
---

but when i route this paths, the result would still be 404-nginx

the kubectl get ingress returns:

NAME          CLASS   HOSTS                          ADDRESS   PORTS   AGE
cheddar       nginx   cheddar.127.0.0.1.nip.io                 80      43s
stilton       nginx   stilton.127.0.0.1.nip.io                 80      43s
wensleydale   nginx   wensleydale.127.0.0.1.nip.io             80      43s

NOTE1: im using microk8s on ubuntu, my clusterversion is: v1.21.7-3+7700880a5c71e2

➜  ~ k get no
NAME   STATUS   ROLES    AGE   VERSION
ali    Ready    <none>   8d    v1.21.7-3+7700880a5c71e2

➜  ~ kubectl version
Client Version: version.Info{Major:"1", Minor:"21+", GitVersion:"v1.21.7-3+7700880a5c71e2", GitCommit:"7700880a5c71e25c44491ef5c7d7fb30527d8337", GitTreeState:"clean", BuildDate:"2021-11-17T22:07:23Z", GoVersion:"go1.16.10", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21+", GitVersion:"v1.21.7-3+7700880a5c71e2", GitCommit:"7700880a5c71e25c44491ef5c7d7fb30527d8337", GitTreeState:"clean", BuildDate:"2021-11-17T22:02:47Z", GoVersion:"go1.16.10", Compiler:"gc", Platform:"linux/amd64"}

NOTE2: i've already enaled the ingress extention by this command: microk8s enable ingress

Ali
  • 922
  • 1
  • 9
  • 24

1 Answers1

1

If you're using this cluster bare-metal, you'll have to use something like metallb. Kubernetes does not implement network load balancers and therefore will not be able to assign an ip address to your ingress.

Since you're using microk8s, you can use microk8s enable metallb

If you're using aws, gcp, aks, you'll find it in their documentation.

For bare-metal see the following : https://metallb.org/

Chris
  • 36
  • 1
  • 6