Friday, October 4, 2024
HomeGolangHTTP requests to a headless k8s service not getting load balanced with...

HTTP requests to a headless k8s service not getting load balanced with go1.22.7 – Getting Assist


Hello,

I’ve a headless k8s service for which the native DNS resolver offers all of the IPs of the pods sitting behind the service. The requests made to the service are usually not getting load balanced with go1.22.7 and all of the requests go to a single pod. The HTTP consumer is invoked utilizing the next snippet:

	for {
		consumer := &http.Consumer{
			Timeout: 95 * time.Second,
		}

		req, err := http.NewRequest("GET", "http://<service-name>:<port>", nil)
		if err != nil {
			fmt.Println("Error creating request:", err)
			return
		}

		resp, err := consumer.Do(req)
		if err != nil {
			fmt.Println("Error making request:", err)
			return
		}
		defer resp.Physique.Shut()
		time.Sleep(5 * time.Second)
	}

Requests created from the above with go1.23.1 are getting load balanced appropriately(undecided if it’s spherical robin although). I in contrast the transport logic for each the variations however couldn’t discover something concrete which may trigger this downside. Are you able to consultants please assist me out?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments