Native Kubernetes service load-balancing
This commit is contained in:
parent
7af9d16208
commit
6e460cd652
37 changed files with 1013 additions and 67 deletions
|
@ -10,8 +10,10 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -395,6 +397,7 @@ func (p *Provider) loadConfigurationFromCRD(ctx context.Context, client Client)
|
|||
return conf
|
||||
}
|
||||
|
||||
// getServicePort always returns a valid port, an error otherwise.
|
||||
func getServicePort(svc *corev1.Service, port intstr.IntOrString) (*corev1.ServicePort, error) {
|
||||
if svc == nil {
|
||||
return nil, errors.New("service is not defined")
|
||||
|
@ -427,6 +430,18 @@ func getServicePort(svc *corev1.Service, port intstr.IntOrString) (*corev1.Servi
|
|||
return &corev1.ServicePort{Port: port.IntVal}, nil
|
||||
}
|
||||
|
||||
func getNativeServiceAddress(service corev1.Service, svcPort corev1.ServicePort) (string, error) {
|
||||
if service.Spec.ClusterIP == "None" {
|
||||
return "", fmt.Errorf("no clusterIP on headless service: %s/%s", service.Namespace, service.Name)
|
||||
}
|
||||
|
||||
if service.Spec.ClusterIP == "" {
|
||||
return "", fmt.Errorf("no clusterIP found for service: %s/%s", service.Namespace, service.Name)
|
||||
}
|
||||
|
||||
return net.JoinHostPort(service.Spec.ClusterIP, strconv.Itoa(int(svcPort.Port))), nil
|
||||
}
|
||||
|
||||
func createPluginMiddleware(k8sClient Client, ns string, plugins map[string]apiextensionv1.JSON) (map[string]dynamic.PluginConf, error) {
|
||||
if plugins == nil {
|
||||
return nil, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue