mirror of https://github.com/k3s-io/k3s
abstract proxy servicePort and endpoints
parent
3cf94ef125
commit
2ee1c80d0f
|
@ -20,11 +20,12 @@ import (
|
|||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
)
|
||||
|
||||
// ProxyProvider is the interface provided by proxier implementations.
|
||||
type ProxyProvider interface {
|
||||
// Sync immediately synchronizes the ProxyProvider's current state to iptables.
|
||||
// Sync immediately synchronizes the ProxyProvider's current state to proxy rules.
|
||||
Sync()
|
||||
// SyncLoop runs periodic work.
|
||||
// This is expected to run as a goroutine or as the main loop of the app.
|
||||
|
@ -33,7 +34,7 @@ type ProxyProvider interface {
|
|||
}
|
||||
|
||||
// ServicePortName carries a namespace + name + portname. This is the unique
|
||||
// identfier for a load-balanced service.
|
||||
// identifier for a load-balanced service.
|
||||
type ServicePortName struct {
|
||||
types.NamespacedName
|
||||
Port string
|
||||
|
@ -42,3 +43,34 @@ type ServicePortName struct {
|
|||
func (spn ServicePortName) String() string {
|
||||
return fmt.Sprintf("%s:%s", spn.NamespacedName.String(), spn.Port)
|
||||
}
|
||||
|
||||
// ServicePort is an interface which abstracts information about a service.
|
||||
type ServicePort interface {
|
||||
// String returns service string. An example format can be: `IP:Port/Protocol`.
|
||||
String() string
|
||||
// ClusterIP returns service cluster IP.
|
||||
ClusterIP() string
|
||||
// Protocol returns service protocol.
|
||||
Protocol() api.Protocol
|
||||
// HealthCheckNodePort returns service health check node port if present. If return 0, it means not present.
|
||||
HealthCheckNodePort() int
|
||||
}
|
||||
|
||||
// Endpoint in an interface which abstracts information about an endpoint.
|
||||
type Endpoint interface {
|
||||
// String returns endpoint string. An example format can be: `IP:Port`.
|
||||
// We take the returned value as ServiceEndpoint.Endpoint.
|
||||
String() string
|
||||
// IsLocal returns true if the endpoint is running in same host as kube-proxy, otherwise returns false.
|
||||
IsLocal() bool
|
||||
// IP returns IP part of endpoints.
|
||||
IP() string
|
||||
// Equal checks if two endpoints are equal.
|
||||
Equal(Endpoint) bool
|
||||
}
|
||||
|
||||
// ServiceEndpoint is used to identify a service and one of its endpoint pair.
|
||||
type ServiceEndpoint struct {
|
||||
Endpoint string
|
||||
ServicePortName ServicePortName
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue