'kubernetes service load balancer auto change protocol

I create a service which type is loadbalancer, kubernetes create an ELB and listen protocol is tcp 80--->tcp 80, then I modified the ELB by changing the protocol to http 80--->http 80, but after a few days, I find that the protocol went back to tcp 80--->tcp 80 again, how could this happen? Any answers would be appreciated



Solution 1:[1]

By default kubernetes will add, TCP protocol in loadbalancer. If we modify manually, It will get changed automatically by kubernetes. If you wish to keep HTTP protocol in kubernets. Please add below annotations in your service yaml.

apiVersion: v1
kind: Service
metadata:
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http

Solution 2:[2]

If you connect your kubernetes cluster to your AWS account and create a service with type: Loadbalancer Kubernetes will create and configure an ELB pointing to your service for you.

Since this ELB instance is managed by Kubernetes every change to it from outside Kubernetes will be resetted after some time.

Solution 3:[3]

I modified the ELB

If you touch kubernetes resources from outside, kubernetes will find out and restore/reconcile the cluster to the desired state.

Here is more info about k8s ELB.

Solution 4:[4]

Create an annotation on your 'service' which explicitly declare:

 annotations:
  service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
  service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: 'true'
  service.beta.kubernetes.io/aws-load-balancer-type: alb

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Santhosh Kumar A
Solution 2 Lukas Eichler
Solution 3 Vikram Hosakote
Solution 4 Asher Manangan