Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
2ee1c80d
Commit
2ee1c80d
authored
Dec 10, 2017
by
m1093782566
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
abstract proxy servicePort and endpoints
parent
3cf94ef1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
2 deletions
+34
-2
types.go
pkg/proxy/types.go
+34
-2
No files found.
pkg/proxy/types.go
View file @
2ee1c80d
...
@@ -20,11 +20,12 @@ import (
...
@@ -20,11 +20,12 @@ import (
"fmt"
"fmt"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
api
"k8s.io/kubernetes/pkg/apis/core"
)
)
// ProxyProvider is the interface provided by proxier implementations.
// ProxyProvider is the interface provided by proxier implementations.
type
ProxyProvider
interface
{
type
ProxyProvider
interface
{
// Sync immediately synchronizes the ProxyProvider's current state to
iptab
les.
// Sync immediately synchronizes the ProxyProvider's current state to
proxy ru
les.
Sync
()
Sync
()
// SyncLoop runs periodic work.
// SyncLoop runs periodic work.
// This is expected to run as a goroutine or as the main loop of the app.
// This is expected to run as a goroutine or as the main loop of the app.
...
@@ -33,7 +34,7 @@ type ProxyProvider interface {
...
@@ -33,7 +34,7 @@ type ProxyProvider interface {
}
}
// ServicePortName carries a namespace + name + portname. This is the unique
// ServicePortName carries a namespace + name + portname. This is the unique
// identfier for a load-balanced service.
// ident
i
fier for a load-balanced service.
type
ServicePortName
struct
{
type
ServicePortName
struct
{
types
.
NamespacedName
types
.
NamespacedName
Port
string
Port
string
...
@@ -42,3 +43,34 @@ type ServicePortName struct {
...
@@ -42,3 +43,34 @@ type ServicePortName struct {
func
(
spn
ServicePortName
)
String
()
string
{
func
(
spn
ServicePortName
)
String
()
string
{
return
fmt
.
Sprintf
(
"%s:%s"
,
spn
.
NamespacedName
.
String
(),
spn
.
Port
)
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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment