没有IP地址的入口 [英] Ingress without ip address
问题描述
我创建了一个入口以公开我的内部服务.
I create a ingress to expose my internal service.
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: app-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: example.com
http:
paths:
- path: /app
backend:
serviceName: my-app
servicePort: 80
但是当我尝试获取此入口时,表明它没有IP地址.
But when I try to get this ingress, it show it has not ip address.
NAME HOSTS ADDRESS PORTS AGE
app-ingress example.com 80 10h
服务显示在下面.
apiVersion: v1
kind: Service
metadata:
name: my-app
spec:
selector:
app: my-app
ports:
- name: my-app
nodePort: 32000
port: 3000
targetPort: 3000
type: NodePort
推荐答案
注意:我猜是因为您问的其他问题,您正在尝试使用kubeadm
在手动创建的集群上创建入口.
Note: I'm guessing because of the other question you asked that you are trying to create an ingress on a manually created cluster with kubeadm
.
如文档中所述,以便进入要正常工作,您需要先安装入口控制器.入口对象本身只是已安装的入口控制器的配置片.
As described in the docs, in order for ingress to work, you need to install ingress controller first. An ingress object itself is merely a configuration slice for the installed ingress controller.
基于Nginx的控制器是最受欢迎的选择之一.与服务类似,为了获得单个启用故障转移的VIP,您需要使用 MetalLB .否则,您可以在节点端口上部署ingress-nginx:在此处中查看详细信息
Nginx based controller is one of the most popular choice. Similarly to services, in order to get a single failover-enabled VIP for your ingress, you need to use MetalLB. Otherwise you can deploy ingress-nginx over a node port: see details here
最后,入口对象中的servicePort
应该为3000,与服务的port
相同.
Finally, servicePort
in your ingress object should be 3000, same as port
of your service.
这篇关于没有IP地址的入口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!