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
1c25c2cd
Commit
1c25c2cd
authored
Sep 21, 2015
by
gmarek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor KubeProxy to allow mocking of all moving parts.
parent
45a8b5f9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
15 deletions
+44
-15
kube-proxy.go
cmd/hyperkube/kube-proxy.go
+17
-6
server.go
cmd/kube-proxy/app/server.go
+0
-0
proxy.go
cmd/kube-proxy/proxy.go
+9
-3
kube-proxy.go
contrib/mesos/cmd/km/kube-proxy.go
+18
-6
No files found.
cmd/hyperkube/kube-proxy.go
View file @
1c25c2cd
...
@@ -19,24 +19,35 @@ limitations under the License.
...
@@ -19,24 +19,35 @@ limitations under the License.
package
main
package
main
import
(
import
(
"fmt"
"os"
kubeproxy
"k8s.io/kubernetes/cmd/kube-proxy/app"
kubeproxy
"k8s.io/kubernetes/cmd/kube-proxy/app"
)
)
// NewKubeProxy creates a new hyperkube Server object that includes the
// NewKubeProxy creates a new hyperkube Server object that includes the
// description and flags.
// description and flags.
func
NewKubeProxy
()
*
Server
{
func
NewKubeProxy
()
*
Server
{
s
:=
kubeproxy
.
NewProxyServer
()
config
:=
kubeproxy
.
NewProxyConfig
()
hks
:=
Server
{
hks
:=
Server
{
SimpleUsage
:
"proxy"
,
SimpleUsage
:
"proxy"
,
Long
:
`The Kubernetes proxy server is responsible for taking traffic directed at
Long
:
`The Kubernetes proxy server is responsible for taking traffic directed at
services and forwarding it to the appropriate pods.
It generally runs on
services and forwarding it to the appropriate pods. It generally runs on
nodes next to the Kubelet and proxies traffic from local pods to remote pods.
nodes next to the Kubelet and proxies traffic from local pods to remote pods.
It is also used when handling incoming external traffic.`
,
It is also used when handling incoming external traffic.`
,
Run
:
func
(
_
*
Server
,
args
[]
string
)
error
{
return
s
.
Run
(
args
)
},
}
}
s
.
AddFlags
(
hks
.
Flags
())
config
.
AddFlags
(
hks
.
Flags
())
s
,
err
:=
kubeproxy
.
NewProxyServerDefault
(
config
)
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%v
\n
"
,
err
)
os
.
Exit
(
1
)
}
hks
.
Run
=
func
(
_
*
Server
,
args
[]
string
)
error
{
return
s
.
Run
(
args
)
}
return
&
hks
return
&
hks
}
}
cmd/kube-proxy/app/server.go
View file @
1c25c2cd
This diff is collapsed.
Click to expand it.
cmd/kube-proxy/proxy.go
View file @
1c25c2cd
...
@@ -35,8 +35,8 @@ func init() {
...
@@ -35,8 +35,8 @@ func init() {
func
main
()
{
func
main
()
{
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
s
:=
app
.
NewProxyServer
()
config
:=
app
.
NewProxyConfig
()
s
.
AddFlags
(
pflag
.
CommandLine
)
config
.
AddFlags
(
pflag
.
CommandLine
)
util
.
InitFlags
()
util
.
InitFlags
()
util
.
InitLogs
()
util
.
InitLogs
()
...
@@ -44,7 +44,13 @@ func main() {
...
@@ -44,7 +44,13 @@ func main() {
verflag
.
PrintAndExitIfRequested
()
verflag
.
PrintAndExitIfRequested
()
if
err
:=
s
.
Run
(
pflag
.
CommandLine
.
Args
());
err
!=
nil
{
s
,
err
:=
app
.
NewProxyServerDefault
(
config
)
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%v
\n
"
,
err
)
os
.
Exit
(
1
)
}
if
err
=
s
.
Run
(
pflag
.
CommandLine
.
Args
());
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%v
\n
"
,
err
)
fmt
.
Fprintf
(
os
.
Stderr
,
"%v
\n
"
,
err
)
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
...
...
contrib/mesos/cmd/km/kube-proxy.go
View file @
1c25c2cd
...
@@ -18,25 +18,37 @@ limitations under the License.
...
@@ -18,25 +18,37 @@ limitations under the License.
package
main
package
main
import
(
import
(
"fmt"
"os"
kubeproxy
"k8s.io/kubernetes/cmd/kube-proxy/app"
kubeproxy
"k8s.io/kubernetes/cmd/kube-proxy/app"
"k8s.io/kubernetes/contrib/mesos/pkg/hyperkube"
"k8s.io/kubernetes/contrib/mesos/pkg/hyperkube"
)
)
// NewKubeProxy creates a new hyperkube Server object that includes the
// NewKubeProxy creates a new hyperkube Server object that includes the
// description and flags.
// description and flags.
func
NewKubeProxy
()
*
Server
{
func
NewKubeProxy
()
*
Server
{
s
:=
kubeproxy
.
NewProxyServer
()
config
:=
kubeproxy
.
NewProxyConfig
()
hks
:=
Server
{
hks
:=
Server
{
SimpleUsage
:
hyperkube
.
CommandProxy
,
SimpleUsage
:
hyperkube
.
CommandProxy
,
Long
:
`The Kubernetes proxy server is responsible for taking traffic directed at
Long
:
`The Kubernetes proxy server is responsible for taking traffic directed at
services and forwarding it to the appropriate pods.
It generally runs on
services and forwarding it to the appropriate pods. It generally runs on
nodes next to the Kubelet and proxies traffic from local pods to remote pods.
nodes next to the Kubelet and proxies traffic from local pods to remote pods.
It is also used when handling incoming external traffic.`
,
It is also used when handling incoming external traffic.`
,
Run
:
func
(
_
*
Server
,
args
[]
string
)
error
{
return
s
.
Run
(
args
)
},
}
}
s
.
AddFlags
(
hks
.
Flags
())
config
.
AddFlags
(
hks
.
Flags
())
s
,
err
:=
kubeproxy
.
NewProxyServerDefault
(
config
)
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%v
\n
"
,
err
)
os
.
Exit
(
1
)
}
hks
.
Run
=
func
(
_
*
Server
,
args
[]
string
)
error
{
return
s
.
Run
(
args
)
}
return
&
hks
return
&
hks
}
}
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