[英]AWS LoadBalancer doesn't connect to K8s POD
I've got a single-node Kubernetes "cluster" built with kubeadm
in AWS. 我已经在AWS中使用kubeadm
构建了一个单节点Kubernetes“集群”。
I have deployed a simple Nginx deployment with this config: 我已经使用此配置部署了一个简单的Nginx部署:
kind: Deployment
apiVersion: apps/v1
metadata:
name: nginx0-deployment
labels:
app: nginx0-deployment
spec:
replicas: 1
selector:
matchLabels:
app: nginx0
template:
metadata:
labels:
app: nginx0
spec:
containers:
- name: nginx
image: k8s.gcr.io/nginx:latest
ports:
- containerPort: 80
name: backend-http
I have also created an AWS ELB LoadBalancer: 我还创建了一个AWS ELB LoadBalancer:
kind: Service
apiVersion: v1
metadata:
name: nginx0-service
balancing-enabled: "true"
spec:
selector:
app: nginx0-deployment
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer
This created the ELB and opened the relevant ports in the K8s instance security group. 这创建了ELB,并打开了K8s实例安全组中的相关端口。
{ec2-instance} ~ $ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/nginx0-deployment-548f99f47c-ns75w 1/1 Running 0 3m45s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 25h
service/nginx0-service LoadBalancer 10.106.179.191 acfc4150....elb.amazonaws.com 80:30675/TCP 63s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx0-deployment 1/1 1 1 3m45s
NAME DESIRED CURRENT READY AGE
replicaset.apps/nginx0-deployment-548f99f47c 1 1 1 3m45s
However something is still missing between the ELB and the POD because browsing to http://acfc4150....elb.amazonaws.com/
doesn't work - Chrome says ERR_EMPTY_RESPONSE. 但是,由于浏览到http://acfc4150....elb.amazonaws.com/
不起作用,ELB和POD之间仍然缺少某些内容http://acfc4150....elb.amazonaws.com/
表示ERR_EMPTY_RESPONSE。
I guess it's something to do with the ELB port mapping 80:30675/TCP - I have checked the incoming traffic on the instance and I see packets for port 30675 but nothing goes back. 我想这与ELB端口映射 80:30675 / TCP有关 -我已经检查了实例上的传入流量,并且看到端口30675的数据包,但没有任何返回。 As if the mapping between this port and the POD's port 80 wasn't set up? 好像未建立此端口与POD的端口80之间的映射?
Any idea what should I add to my manifests to make it work? 任何想法我应该添加到清单中以使其起作用吗?
Thanks! 谢谢!
You have the wrong labels; 您的标签有误; your Deployment has app: nginx0-deployment
but your Pods have app: nginx0
and Service
s don't target Deployments, they target Pods 您部署 app: nginx0-deployment
,但你的豆荚 app: nginx0
和Service
■不要针对部署,他们的目标吊舱
Update your Service
to have: 更新您的Service
以具有:
spec:
selector:
app: nginx0
instead 代替
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.