我正在尝试将Kong Ingress Controller部署到我在virtualbox中使用kubeadm部署的K8s集群中。
它由一个主节点和两个工作节点组成。
根据文档,我正在使用无DBless部署:
kubectl apply -f https://raw.githubusercontent.com/Kong/kubernetes-ingress-controller/master/deploy/single/all-in-one-dbless.yaml
结果是这样的:
namespace/kong created
customresourcedefinition.apiextensions.k8s.io/kongclusterplugins.configuration.konghq.com created
customresourcedefinition.apiextensions.k8s.io/kongconsumers.configuration.konghq.com created
customresourcedefinition.apiextensions.k8s.io/kongingresses.configuration.konghq.com created
customresourcedefinition.apiextensions.k8s.io/kongplugins.configuration.konghq.com created
customresourcedefinition.apiextensions.k8s.io/tcpingresses.configuration.konghq.com created
customresourcedefinition.apiextensions.k8s.io/udpingresses.configuration.konghq.com created
serviceaccount/kong-serviceaccount created
role.rbac.authorization.k8s.io/kong-leader-election created
clusterrole.rbac.authorization.k8s.io/kong-ingress created
rolebinding.rbac.authorization.k8s.io/kong-leader-election created
clusterrolebinding.rbac.authorization.k8s.io/kong-ingress created
service/kong-proxy created
service/kong-validation-webhook created
deployment.apps/ingress-kong created
到目前为止,一切顺利。以下是它创建的组件:
NAME READY STATUS RESTARTS AGE
pod/ingress-kong-7498964bb6-ddbfw 2/2 Running 2 (7m37s ago) 7m41s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kong-proxy LoadBalancer 10.110.24.254 <pending> 80:31345/TCP,443:31076/TCP 7m41s
service/kong-validation-webhook ClusterIP 10.108.43.162 <none> 443/TCP 7m41s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/ingress-kong 1/1 1 1 7m41s
NAME DESIRED CURRENT READY AGE
replicaset.apps/ingress-kong-7498964bb6 1 1 1 7m41s
我正在使用port-forward公开负载均衡器:
kubectl port-forward svc/kong-proxy -n kong 80:80
然后我curl http://localhost结果如预期:
curl : {"message":"no Route matched with those values"}
最后,我部署了一组入口规则来测试它:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginx
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
strategy: {}
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx:alpine
name: nginx
ports:
- containerPort: 80
resources: {}
status: {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: httpd
name: httpd
spec:
replicas: 1
selector:
matchLabels:
app: httpd
strategy: {}
template:
metadata:
labels:
app: httpd
spec:
containers:
- image: httpd:alpine
name: httpd
ports:
- containerPort: 80
resources: {}
status: {}
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: nginx
name: nginx-service
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: ClusterIP
status:
loadBalancer: {}
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: httpd
name: httpd-service
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: httpd
type: ClusterIP
status:
loadBalancer: {}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
konghq.com/strip-path: "true"
name: nginx-ingress
spec:
ingressClassName: kong
rules:
- http:
paths:
- backend:
service:
name: nginx-service
port:
number: 80
path: /nginx
pathType: Prefix
status:
loadBalancer: {}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
konghq.com/strip-path: "true"
name: httpd-ingress
spec:
ingressClassName: kong
rules:
- http:
paths:
- backend:
service:
name: httpd-service
port:
number: 80
path: /httpd
pathType: Prefix
当我尝试curl在我的ingress规则中定义的任何路径时,例如,curl http://localhost/httpd它会抛出以下错误:
curl : An invalid response was received from the upstream server
来自kong代理的日志显示了以下错误:
[error] 1097#0: *6474 connect() failed (113: Host is unreachable) while connecting to upstream, client: 127.0.0.1, server: kong, request: "GET /httpd HTTP/1.1", upstream: "http://10.88.0.58:80/", host: "localhost"
当我列出端点时,IP显示:
httpd-service 10.88.0.58:80 14m
nginx-service 10.88.0.59:80 14m
这两个服务(httpd-service和nginx-service)都是正确的,当我将它们的服务转发到我的本地机器时,我可以访问它们。
我在DigitalOcean上将同样的部署部署到另一个集群中,除了配置负载平衡器之外,结果几乎相同。
有人能帮我吗?
谢谢!
1条答案
按热度按时间wrrgggsh1#
原因是内部负载均衡IP安装了kong-proxy。
您的** curl :{“message”:“no Route matched with those values”}端口转发后是因为URL在内部命中。
当您创建远程托管的ingresshttpd服务时。使用内部负载均衡器,我们无法访问外部托管域。
因此,请尝试将kong ingress安装为暴露于外部网络的外部负载均衡IP**。以便您可以访问托管服务。
获取kong的安装yaml,其中包含外部负载均衡器。