入口没有地址
Ingress no address
我的机器上有一个小的 k8s 集群,我尝试做一些东西来学习,但我现在正在堆叠。
我有 2 个应用程序,一个 mysql 和另一个 wordpress,它们运行良好。当我为 wordpress 提供 LoadBalancer 类型时,它占用了一个 ip,我可以在我的浏览器中看到。
所以我想创建一个 Ingress 并通过主机名调用,但 Ingress 不使用 Loadbalancer IP..
我做错了什么吗?
这是我的 Ingress 配置
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: wp-ingress
kubernetes.io/ingress.class: nginx
labels:
name: wp-ingress
spec:
rules:
- host: wordpress.pandora.local
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: wp-svc
port:
number: 80
- host: phpmyadmin.pandora.local
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: phpmyadmin-svc
port:
number: 80
和问题
# kg ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
wp-ingress <none> wordpress.pandora.local,phpmyadmin.pandora.local 80 38m
我正在使用 Metallb 作为负载均衡器,我知道它可以工作是因为 wordpress,但是如果你想看
kg svc -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
calico-apiserver calico-api ClusterIP 10.108.149.243 <none> 443/TCP 45h
calico-system calico-kube-controllers-metrics ClusterIP 10.100.211.40 <none> 9094/TCP 45h
calico-system calico-typha ClusterIP 10.107.217.253 <none> 5473/TCP 45h
default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 45h
default mysql-svc ClusterIP 10.103.110.242 <none> 3306/TCP 3h1m
default phpmyadmin-svc ClusterIP 10.105.195.144 <none> 80/TCP 156m
default wp-svc ClusterIP 10.100.96.37 <none> 80/TCP 126m
ingress-nginx ingress-nginx-controller LoadBalancer 10.99.196.206 192.168.188.20 80:30986/TCP,443:32709/TCP 49m
ingress-nginx ingress-nginx-controller-admission ClusterIP 10.99.212.249 <none> 443/TCP 49m
kube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 45h
我该如何解决问题
我解决了。感谢您的帮助:)
问题即将进入 class.
kind: Ingress
metadata:
name: wp-ingress
spec:
rules:
- host: wordpress.pandora.local
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: wp-svc
port:
number: 80
- host: phpmyadmin.pandora.local
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: phpmyadmin-svc
port:
number: 80
ingressClassName: nginx
我添加了最后一行 ingressClassName: nginx 定义并且成功了!
kg ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
wp-ingress nginx wordpress.pandora.local,phpmyadmin.pandora.local 192.168.88.20 80 5h19m
我的机器上有一个小的 k8s 集群,我尝试做一些东西来学习,但我现在正在堆叠。
我有 2 个应用程序,一个 mysql 和另一个 wordpress,它们运行良好。当我为 wordpress 提供 LoadBalancer 类型时,它占用了一个 ip,我可以在我的浏览器中看到。
所以我想创建一个 Ingress 并通过主机名调用,但 Ingress 不使用 Loadbalancer IP.. 我做错了什么吗?
这是我的 Ingress 配置
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: wp-ingress
kubernetes.io/ingress.class: nginx
labels:
name: wp-ingress
spec:
rules:
- host: wordpress.pandora.local
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: wp-svc
port:
number: 80
- host: phpmyadmin.pandora.local
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: phpmyadmin-svc
port:
number: 80
和问题
# kg ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
wp-ingress <none> wordpress.pandora.local,phpmyadmin.pandora.local 80 38m
我正在使用 Metallb 作为负载均衡器,我知道它可以工作是因为 wordpress,但是如果你想看
kg svc -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
calico-apiserver calico-api ClusterIP 10.108.149.243 <none> 443/TCP 45h
calico-system calico-kube-controllers-metrics ClusterIP 10.100.211.40 <none> 9094/TCP 45h
calico-system calico-typha ClusterIP 10.107.217.253 <none> 5473/TCP 45h
default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 45h
default mysql-svc ClusterIP 10.103.110.242 <none> 3306/TCP 3h1m
default phpmyadmin-svc ClusterIP 10.105.195.144 <none> 80/TCP 156m
default wp-svc ClusterIP 10.100.96.37 <none> 80/TCP 126m
ingress-nginx ingress-nginx-controller LoadBalancer 10.99.196.206 192.168.188.20 80:30986/TCP,443:32709/TCP 49m
ingress-nginx ingress-nginx-controller-admission ClusterIP 10.99.212.249 <none> 443/TCP 49m
kube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 45h
我该如何解决问题
我解决了。感谢您的帮助:) 问题即将进入 class.
kind: Ingress
metadata:
name: wp-ingress
spec:
rules:
- host: wordpress.pandora.local
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: wp-svc
port:
number: 80
- host: phpmyadmin.pandora.local
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: phpmyadmin-svc
port:
number: 80
ingressClassName: nginx
我添加了最后一行 ingressClassName: nginx 定义并且成功了!
kg ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
wp-ingress nginx wordpress.pandora.local,phpmyadmin.pandora.local 192.168.88.20 80 5h19m