简体   繁体   English

microk8s 中的入口没有分配地址

[英]ingress in microk8s doesnt assigne an ADDRESS

my problem is why ingress doesnt assigne an Address for the services?我的问题是为什么入口没有为服务分配地址?

first of all i create 3 deployments:首先,我创建了 3 个部署:

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:其次,我公开了这 3 个部署:

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:然后我用kubectl apply -f ingress.yaml应用我的 ingress.yaml , ingress.yaml 内容是:

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但是当我路由这条路径时,结果仍然是404-nginx

the kubectl get ingress returns: kubectl get ingress返回:

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 NOTE1:我在 ubuntu 上使用 microk8s,我的集群版本是: 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注意2:我已经通过这个命令启用了入口扩展: microk8s enable ingress

If you're using this cluster bare-metal, you'll have to use something like metallb.如果你使用这个集群裸机,你将不得不使用类似 metallb 的东西。 Kubernetes does not implement network load balancers and therefore will not be able to assign an ip address to your ingress. Kubernetes 没有实现网络负载均衡器,因此无法将 ip 地址分配给您的入口。

Since you're using microk8s, you can use microk8s enable metallb由于您使用的是 microk8s,因此您可以使用microk8s enable metallb

If you're using aws, gcp, aks, you'll find it in their documentation.如果您使用的是 aws、gcp、aks,您可以在他们的文档中找到它。

For bare-metal see the following: https://metallb.org/对于裸机,请参阅以下内容: https://metallb.org/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM