forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a HollowProxy to the HollowNode.
- Loading branch information
gmarek
committed
Oct 27, 2015
1 parent
a10ed3e
commit 5a4e4d4
Showing
7 changed files
with
258 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
Copyright 2015 The Kubernetes Authors All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package kubemark | ||
|
||
import ( | ||
"time" | ||
|
||
proxyapp "k8s.io/kubernetes/cmd/kube-proxy/app" | ||
"k8s.io/kubernetes/pkg/api" | ||
"k8s.io/kubernetes/pkg/client/record" | ||
client "k8s.io/kubernetes/pkg/client/unversioned" | ||
proxyconfig "k8s.io/kubernetes/pkg/proxy/config" | ||
"k8s.io/kubernetes/pkg/types" | ||
utiliptables "k8s.io/kubernetes/pkg/util/iptables" | ||
|
||
"github.com/golang/glog" | ||
) | ||
|
||
type HollowProxy struct { | ||
ProxyServer *proxyapp.ProxyServer | ||
} | ||
|
||
type FakeProxyHandler struct{} | ||
|
||
func (*FakeProxyHandler) OnServiceUpdate(services []api.Service) {} | ||
func (*FakeProxyHandler) OnEndpointsUpdate(endpoints []api.Endpoints) {} | ||
|
||
type FakeProxier struct{} | ||
|
||
func (*FakeProxier) OnServiceUpdate(services []api.Service) {} | ||
func (*FakeProxier) Sync() {} | ||
func (*FakeProxier) SyncLoop() { | ||
select {} | ||
} | ||
|
||
func NewHollowProxyOrDie( | ||
nodeName string, | ||
client *client.Client, | ||
endpointsConfig *proxyconfig.EndpointsConfig, | ||
serviceConfig *proxyconfig.ServiceConfig, | ||
iptInterface utiliptables.Interface, | ||
broadcaster record.EventBroadcaster, | ||
recorder record.EventRecorder, | ||
) *HollowProxy { | ||
// Create and start Hollow Proxy | ||
config := proxyapp.NewProxyConfig() | ||
config.OOMScoreAdj = 0 | ||
config.ResourceContainer = "" | ||
config.NodeRef = &api.ObjectReference{ | ||
Kind: "Node", | ||
Name: nodeName, | ||
UID: types.UID(nodeName), | ||
Namespace: "", | ||
} | ||
proxyconfig.NewSourceAPI( | ||
client, | ||
30*time.Second, | ||
serviceConfig.Channel("api"), | ||
endpointsConfig.Channel("api"), | ||
) | ||
|
||
hollowProxy, err := proxyapp.NewProxyServer(client, config, iptInterface, &FakeProxier{}, broadcaster, recorder) | ||
if err != nil { | ||
glog.Fatalf("Error while creating ProxyServer: %v\n", err) | ||
} | ||
return &HollowProxy{ | ||
ProxyServer: hollowProxy, | ||
} | ||
} | ||
|
||
func (hp *HollowProxy) Run() { | ||
if err := hp.ProxyServer.Run(make([]string, 0)); err != nil { | ||
glog.Fatalf("Error while running proxy: %v\n", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
Copyright 2015 The Kubernetes Authors All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package testing | ||
|
||
import "k8s.io/kubernetes/pkg/util/iptables" | ||
|
||
// no-op implemenatation of iptables Interface | ||
type fake struct{} | ||
|
||
func NewFake() *fake { | ||
return &fake{} | ||
} | ||
|
||
func (*fake) EnsureChain(table iptables.Table, chain iptables.Chain) (bool, error) { | ||
return true, nil | ||
} | ||
|
||
func (*fake) FlushChain(table iptables.Table, chain iptables.Chain) error { | ||
return nil | ||
} | ||
|
||
func (*fake) DeleteChain(table iptables.Table, chain iptables.Chain) error { | ||
return nil | ||
} | ||
|
||
func (*fake) EnsureRule(position iptables.RulePosition, table iptables.Table, chain iptables.Chain, args ...string) (bool, error) { | ||
return true, nil | ||
} | ||
|
||
func (*fake) DeleteRule(table iptables.Table, chain iptables.Chain, args ...string) error { | ||
return nil | ||
} | ||
|
||
func (*fake) IsIpv6() bool { | ||
return false | ||
} | ||
|
||
func (*fake) Save(table iptables.Table) ([]byte, error) { | ||
return make([]byte, 0), nil | ||
} | ||
|
||
func (*fake) SaveAll() ([]byte, error) { | ||
return make([]byte, 0), nil | ||
} | ||
|
||
func (*fake) Restore(table iptables.Table, data []byte, flush iptables.FlushFlag, counters iptables.RestoreCountersFlag) error { | ||
return nil | ||
} | ||
|
||
func (*fake) RestoreAll(data []byte, flush iptables.FlushFlag, counters iptables.RestoreCountersFlag) error { | ||
return nil | ||
} | ||
func (*fake) AddReloadFunc(reloadFunc func()) {} | ||
|
||
func (*fake) Destroy() {} | ||
|
||
var _ = iptables.Interface(&fake{}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.