我安装了一个带有负载均衡器的kubernetes集群,该集群为我提供了一个外部IP,但是当我尝试访问该IP地址时,我会超时...
仅当我尝试通过入口访问服务时才发生这种情况,当直接用负载均衡器公开服务时,我会直接得到响应。
我还有一个关于制作群集here的问题,也许那里有一些信息可以用来补充这个问题。
我的入口文件
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: dev-ingress
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: httpd
servicePort: 80
我的服务文件
apiVersion: v1
kind: Service
metadata:
creationTimestamp: "2020-02-18T19:37:44Z"
labels:
app: httpd
name: httpd
namespace: development
resourceVersion: "513069"
selfLink: /api/v1/namespaces/development/services/httpd
uid: a0b54ecf-6481-4047-b242-6a6c76df4e70
spec:
clusterIP: 10.99.124.218
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: httpd
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
当我先执行kubectl port-forward <pod-name> 80
然后执行curl localhost:80
时,我从httpd服务获得了响应,其默认值为“有效”!页面。
从负载均衡器中获取外部IP
$ kubectl get ing
NAME HOSTS ADDRESS PORTS AGE
dev-ingress * <my external IP> 80 18h
通过负载均衡器对公开的IP地址进行ping
$ ping <my external IP>
Pinging <my external IP> with 32 bytes of data:
Request timed out.
日志。 (一旦我ping或卷曲外部IP,就没有新的日志了)
$ kubectl logs -f nginx-ingress-controller-5d7fc968df-992zf -n ingress-nginx
-------------------------------------------------------------------------------
NGINX Ingress controller
Release: 0.29.0
Build: git-eedcdcdbf
Repository: https://github.com/kubernetes/ingress-nginx
nginx version: nginx/1.17.8
-------------------------------------------------------------------------------
W0219 14:49:56.568453 7 flags.go:260] SSL certificate chain completion is disabled (--enable-ssl-chain-completion=false)
W0219 14:49:56.568838 7 client_config.go:543] Neither --kubeconfig nor --master was specified. Using the inClusterConfig. This might not work.
I0219 14:49:56.569749 7 main.go:193] Creating API client for https://10.96.0.1:443
I0219 14:49:56.716103 7 main.go:237] Running in Kubernetes cluster version v1.17 (v1.17.2) - git (clean) commit 59603c6e503c87169aea6106f57b9f242f64df89 - platform linux/arm
I0219 14:50:01.502630 7 main.go:102] SSL fake certificate created /etc/ingress-controller/ssl/default-fake-certificate.pem
I0219 14:50:01.676803 7 nginx.go:263] Starting NGINX Ingress controller
I0219 14:50:01.856152 7 event.go:281] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"ingress-nginx", Name:"udp-services", UID:"c8ed6c41-dfd2-41b3-a6bd-4a5cac469346", APIVersion:"v1", ResourceVersion:"442237", FieldPath:""}): type: 'Normal' reason: 'CREATE' ConfigMap ingress-nginx/udp-services
I0219 14:50:01.856531 7 event.go:281] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"ingress-nginx", Name:"nginx-configuration", UID:"0006891d-43cd-46d1-a1b8-4e4b123cd1f6", APIVersion:"v1", ResourceVersion:"442235", FieldPath:""}): type: 'Normal' reason: 'CREATE' ConfigMap ingress-nginx/nginx-configuration
I0219 14:50:01.882095 7 event.go:281] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"ingress-nginx", Name:"tcp-services", UID:"65a44b89-c6c2-4126-bee3-6c72e039df49", APIVersion:"v1", ResourceVersion:"442236", FieldPath:""}): type: 'Normal' reason: 'CREATE' ConfigMap ingress-nginx/tcp-services
I0219 14:50:02.991815 7 event.go:281] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"development", Name:"dev-ingress", UID:"ad997038-c7e3-4e33-bec1-7305daff8cc0", APIVersion:"networking.k8s.io/v1beta1", ResourceVersion:"525710", FieldPath:""}): type: 'Normal' reason: 'CREATE' Ingress development/dev-ingress
I0219 14:50:03.077935 7 nginx.go:307] Starting NGINX process
I0219 14:50:03.078415 7 leaderelection.go:242] attempting to acquire leader lease ingress-nginx/ingress-controller-leader-nginx...
I0219 14:50:03.082313 7 controller.go:137] Configuration changes detected, backend reload required.
I0219 14:50:03.101026 7 status.go:86] new leader elected: nginx-ingress-controller-5d7fc968df-jgz2t
I0219 14:50:03.449249 7 controller.go:153] Backend successfully reloaded.
I0219 14:50:03.450116 7 controller.go:162] Initial sync, sleeping for 1 second.
I0219 14:50:55.465109 7 leaderelection.go:252] successfully acquired lease ingress-nginx/ingress-controller-leader-nginx
I0219 14:50:55.465113 7 status.go:86] new leader elected: nginx-ingress-controller-5d7fc968df-992zf
metalLB控制器日志
{"caller":"main.go:108","configmap":"metallb-system/config","event":"startUpdate","msg":"start of config update","ts":"2020-02-19T15:02:13.512307096Z"}
{"caller":"main.go:121","configmap":"metallb-system/config","event":"endUpdate","msg":"end of config update","ts":"2020-02-19T15:02:13.512598915Z"}
{"caller":"k8s.go:376","configmap":"metallb-system/config","event":"configLoaded","msg":"config (re)loaded","ts":"2020-02-19T15:02:13.512757194Z"}
{"caller":"main.go:49","event":"startUpdate","msg":"start of service update","service":"kube-system/kube-dns","ts":"2020-02-19T15:02:13.51819962Z"}
{"caller":"service.go:33","event":"clearAssignment","msg":"not a LoadBalancer","reason":"notLoadBalancer","service":"kube-system/kube-dns","ts":"2020-02-19T15:02:13.518476596Z"}
{"caller":"main.go:75","event":"noChange","msg":"service converged, no change","service":"kube-system/kube-dns","ts":"2020-02-19T15:02:13.518964089Z"}
{"caller":"main.go:76","event":"endUpdate","msg":"end of service update","service":"kube-system/kube-dns","ts":"2020-02-19T15:02:13.519145076Z"}
{"caller":"main.go:49","event":"startUpdate","msg":"start of service update","service":"default/kubernetes","ts":"2020-02-19T15:02:13.519351115Z"}
{"caller":"service.go:33","event":"clearAssignment","msg":"not a LoadBalancer","reason":"notLoadBalancer","service":"default/kubernetes","ts":"2020-02-19T15:02:13.51972585Z"}
{"caller":"main.go:75","event":"noChange","msg":"service converged, no change","service":"default/kubernetes","ts":"2020-02-19T15:02:13.520109699Z"}
{"caller":"main.go:76","event":"endUpdate","msg":"end of service update","service":"default/kubernetes","ts":"2020-02-19T15:02:13.520263603Z"}
{"caller":"main.go:49","event":"startUpdate","msg":"start of service update","service":"development/httpd","ts":"2020-02-19T15:02:13.520447767Z"}
{"caller":"service.go:33","event":"clearAssignment","msg":"not a LoadBalancer","reason":"notLoadBalancer","service":"development/httpd","ts":"2020-02-19T15:02:13.520622087Z"}
{"caller":"main.go:75","event":"noChange","msg":"service converged, no change","service":"development/httpd","ts":"2020-02-19T15:02:13.520975572Z"}
{"caller":"main.go:76","event":"endUpdate","msg":"end of service update","service":"development/httpd","ts":"2020-02-19T15:02:13.521132393Z"}
{"caller":"main.go:49","event":"startUpdate","msg":"start of service update","service":"ingress-nginx/ingress-nginx","ts":"2020-02-19T15:02:13.521314318Z"}
{"caller":"main.go:75","event":"noChange","msg":"service converged, no change","service":"ingress-nginx/ingress-nginx","ts":"2020-02-19T15:02:13.521901705Z"}
{"caller":"main.go:76","event":"endUpdate","msg":"end of service update","service":"ingress-nginx/ingress-nginx","ts":"2020-02-19T15:02:13.522087797Z"}