简体   繁体   中英

Service (LoadBalancer) port not working on aws

I have a LoadBalancer service on a k8s deployment on aws (made via 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 .

I have also assigned an alias to the ELB that gets deployed, say. my-k8s.mydomain.org

Here is the issue:

  • https://my-k8s.mydomain.org works just fine
  • http://my-k8s.mydomain.org returns an empty page (when accessing behind a squid proxy, I get the zero-sized reply error message)

Why am I unable to access the service via port 80 ?

edit : what I have just found is that the service annotation regarding the certificate, also assigns it on port 80 on the ELB.

Could that be the issue?

Is there a way around this?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM