简体   繁体   English

服务(LoadBalancer)端口在AWS上不起作用

[英]Service (LoadBalancer) port not working on aws

I have a LoadBalancer service on a k8s deployment on aws (made via kops ). 我在aws上的k8s部署中有一个LoadBalancer服务(通过kops )。

Service definition is as follows: 服务定义如下:

apiVersion: v1
kind: Service
metadata:
  name: ui
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: <certificate_id>
spec:
  ports:
  - name: http
    port: 80
    targetPort: ui-port
    protocol: TCP
  - name: https
    port: 443
    targetPort: ui-port
    protocol: TCP
  selector:
    els-pod: ui
  type: LoadBalancer

Here is the respective deployment: 这是各自的部署:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: ui-deployment
spec:
  replicas: 1
  template:
    metadata:
      labels:
        els-pod: ui
    spec:
      containers:
      - image: <my_ecr_registry>/<my_image>:latest
        name: ui
        ports:
        - name: ui-port
          containerPort: 80
      restartPolicy: Always

I know that <my_image> exposes port 80 . 我知道<my_image>暴露了端口80

I have also assigned an alias to the ELB that gets deployed, say. 我还为部署的ELB分配了别名。 my-k8s.mydomain.org

Here is the issue: 这是问题所在:

  • https://my-k8s.mydomain.org works just fine https://my-k8s.mydomain.org运行正常
  • http://my-k8s.mydomain.org returns an empty page (when accessing behind a squid proxy, I get the zero-sized reply error message) http://my-k8s.mydomain.org返回一个空页面(当在一个squid代理后面访问时,我得到zero-sized reply错误消息)

Why am I unable to access the service via port 80 ? 为什么我无法通过端口80访问该服务?

edit : what I have just found is that the service annotation regarding the certificate, also assigns it on port 80 on the ELB. 编辑 :我刚刚发现的是有关证书的服务注释,也将其分配给 ELB的端口80

Could that be the issue? 这可能是问题吗?

Is there a way around this? 有没有解决的办法?

只需在服务定义中添加以下注释:

service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 AWS ECS 服务和 Elastic LoadBalancer 向多个公共端口公开 - Exposing to public more than 1 port with AWS ECS service and Elastic LoadBalancer 适用于ECS的AWS Classic Loadbalancer动态端口映射 - AWS Classic Loadbalancer dynamic port mapping for ECS 使用AWS CLI将AWS LoadBalancer添加到服务 - Adding AWS LoadBalancer to Service using AWS CLI AWS EKS:服务(LoadBalancer)正在运行但不响应请求 - AWS EKS: Service(LoadBalancer) running but not responding to requests 使用 AWS LoadBalancer 如何设置“服务停机维护”? - With AWS LoadBalancer how to set "Service down for maintenance"? AWS ElasticBeanstalk应用程序loadbalancer服务角色 - AWS ElasticBeanstalk application loadbalancer Service role Docker AWS 上的 Swarm:公开服务端口在 AWS 虚拟机上不起作用 - Docker Swarm on AWS: Expose service port not working on AWS virtual machine 没有负载平衡器的Amazon Web Service(AWS)EC2窗口上的Https - Https on a Amazon Web Service (AWS) EC2 windows without loadbalancer AWS-CDK ECS Fargate LoadBalancer 监听端口 80,目标组映射到容器端口 - AWS-CDK ECS Fargate LoadBalancer listening on port 80 with target group mapping to container port istio - 使用vs服务和gw而不是loadbalancer不工作 - istio - using vs service and gw instead loadbalancer not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM