Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 66c7d29

Browse files
committed
Add options to disable hyper internal haproxy
1 parent a97826c commit 66c7d29

File tree

12 files changed

+111
-92
lines changed

12 files changed

+111
-92
lines changed

cmd/kube-proxy/app/options/options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func NewProxyConfig() *ProxyServerConfig {
6161
// AddFlags adds flags for a specific ProxyServer to the specified FlagSet
6262
func (s *ProxyServerConfig) AddFlags(fs *pflag.FlagSet) {
6363
fs.Var(componentconfig.IPVar{&s.BindAddress}, "bind-address", "The IP address for the proxy server to serve on (set to 0.0.0.0 for all interfaces)")
64+
fs.BoolVar(&s.DisableHyperInternalService, "disable-hyper-internal-service", s.DisableHyperInternalService, "Disable the internal haproxy service in Hyper pods")
6465
fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)")
6566
fs.IntVar(&s.HealthzPort, "healthz-port", s.HealthzPort, "The port to bind the health check server. Use 0 to disable.")
6667
fs.Var(componentconfig.IPVar{&s.HealthzBindAddress}, "healthz-bind-address", "The IP address for the health check server to serve on, defaulting to 127.0.0.1 (set to 0.0.0.0 for all interfaces)")

cmd/kube-proxy/app/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func NewProxyServerDefault(config *options.ProxyServerConfig) (*ProxyServer, err
217217
userspace.CleanupLeftovers(iptInterface)
218218
case proxyModeHaproxy:
219219
glog.V(2).Info("Using pod-buildin-haproxy proxy.")
220-
proxierBuildin, err := haproxy.NewProxier(config.ConfigSyncPeriod, client)
220+
proxierBuildin, err := haproxy.NewProxier(config.ConfigSyncPeriod, client, config.DisableHyperInternalService)
221221
if err != nil {
222222
glog.Fatalf("Unable to create proxier: %v", err)
223223
}

cmd/kubelet/app/options/options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
139139
fs.DurationVar(&s.HTTPCheckFrequency.Duration, "http-check-frequency", s.HTTPCheckFrequency.Duration, "Duration between checking http for new data")
140140
fs.StringVar(&s.ManifestURL, "manifest-url", s.ManifestURL, "URL for accessing the container manifest")
141141
fs.StringVar(&s.ManifestURLHeader, "manifest-url-header", s.ManifestURLHeader, "HTTP header to use when accessing the manifest URL, with the key separated from the value with a ':', as in 'key:value'")
142+
fs.BoolVar(&s.DisableHyperInternalService, "disable-hyper-internal-service", s.DisableHyperInternalService, "Disable the internal haproxy service in Hyper pods")
142143
fs.BoolVar(&s.EnableServer, "enable-server", s.EnableServer, "Enable the Kubelet's server")
143144
fs.Var(componentconfig.IPVar{&s.Address}, "address", "The IP address for the Kubelet to serve on (set to 0.0.0.0 for all interfaces)")
144145
fs.UintVar(&s.Port, "port", s.Port, "The port for the Kubelet to serve on.")

cmd/kubelet/app/server.go

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -195,57 +195,58 @@ func UnsecuredKubeletConfig(s *options.KubeletServer) (*KubeletConfig, error) {
195195
}
196196

197197
return &KubeletConfig{
198-
Address: net.ParseIP(s.Address),
199-
AllowPrivileged: s.AllowPrivileged,
200-
Auth: nil, // default does not enforce auth[nz]
201-
CAdvisorInterface: nil, // launches background processes, not set here
202-
VolumeStatsAggPeriod: s.VolumeStatsAggPeriod.Duration,
203-
CgroupRoot: s.CgroupRoot,
204-
CinderConfig: s.CinderConfig,
205-
Cloud: nil, // cloud provider might start background processes
206-
ClusterDNS: net.ParseIP(s.ClusterDNS),
207-
ClusterDomain: s.ClusterDomain,
208-
ConfigFile: s.Config,
209-
ConfigureCBR0: s.ConfigureCBR0,
210-
ContainerManager: nil,
211-
ContainerRuntime: s.ContainerRuntime,
212-
CPUCFSQuota: s.CPUCFSQuota,
213-
DiskSpacePolicy: diskSpacePolicy,
214-
DockerClient: dockertools.ConnectToDockerOrDie(s.DockerEndpoint),
215-
RuntimeCgroups: s.RuntimeCgroups,
216-
DockerExecHandler: dockerExecHandler,
217-
EnableCustomMetrics: s.EnableCustomMetrics,
218-
EnableDebuggingHandlers: s.EnableDebuggingHandlers,
219-
EnableServer: s.EnableServer,
220-
EventBurst: s.EventBurst,
221-
EventRecordQPS: s.EventRecordQPS,
222-
FileCheckFrequency: s.FileCheckFrequency.Duration,
223-
HostnameOverride: s.HostnameOverride,
224-
HostNetworkSources: hostNetworkSources,
225-
HostPIDSources: hostPIDSources,
226-
HostIPCSources: hostIPCSources,
227-
HTTPCheckFrequency: s.HTTPCheckFrequency.Duration,
228-
ImageGCPolicy: imageGCPolicy,
229-
KubeClient: nil,
230-
ManifestURL: s.ManifestURL,
231-
ManifestURLHeader: manifestURLHeader,
232-
MasterServiceNamespace: s.MasterServiceNamespace,
233-
MaxContainerCount: s.MaxContainerCount,
234-
MaxOpenFiles: s.MaxOpenFiles,
235-
MaxPerPodContainerCount: s.MaxPerPodContainerCount,
236-
MaxPods: s.MaxPods,
237-
MinimumGCAge: s.MinimumGCAge.Duration,
238-
Mounter: mounter,
239-
NetworkPluginName: networkPluginName,
240-
NetworkPlugins: networkPlugins,
241-
NodeLabels: s.NodeLabels,
242-
NodeStatusUpdateFrequency: s.NodeStatusUpdateFrequency.Duration,
243-
NonMasqueradeCIDR: s.NonMasqueradeCIDR,
244-
OOMAdjuster: oom.NewOOMAdjuster(),
245-
OSInterface: kubecontainer.RealOS{},
246-
PodCIDR: s.PodCIDR,
247-
ReconcileCIDR: s.ReconcileCIDR,
248-
PodInfraContainerImage: s.PodInfraContainerImage,
198+
Address: net.ParseIP(s.Address),
199+
AllowPrivileged: s.AllowPrivileged,
200+
Auth: nil, // default does not enforce auth[nz]
201+
CAdvisorInterface: nil, // launches background processes, not set here
202+
VolumeStatsAggPeriod: s.VolumeStatsAggPeriod.Duration,
203+
CgroupRoot: s.CgroupRoot,
204+
CinderConfig: s.CinderConfig,
205+
Cloud: nil, // cloud provider might start background processes
206+
ClusterDNS: net.ParseIP(s.ClusterDNS),
207+
ClusterDomain: s.ClusterDomain,
208+
ConfigFile: s.Config,
209+
ConfigureCBR0: s.ConfigureCBR0,
210+
ContainerManager: nil,
211+
ContainerRuntime: s.ContainerRuntime,
212+
CPUCFSQuota: s.CPUCFSQuota,
213+
DiskSpacePolicy: diskSpacePolicy,
214+
DockerClient: dockertools.ConnectToDockerOrDie(s.DockerEndpoint),
215+
RuntimeCgroups: s.RuntimeCgroups,
216+
DockerExecHandler: dockerExecHandler,
217+
EnableCustomMetrics: s.EnableCustomMetrics,
218+
EnableDebuggingHandlers: s.EnableDebuggingHandlers,
219+
EnableServer: s.EnableServer,
220+
EventBurst: s.EventBurst,
221+
EventRecordQPS: s.EventRecordQPS,
222+
FileCheckFrequency: s.FileCheckFrequency.Duration,
223+
HostnameOverride: s.HostnameOverride,
224+
HostNetworkSources: hostNetworkSources,
225+
HostPIDSources: hostPIDSources,
226+
HostIPCSources: hostIPCSources,
227+
HTTPCheckFrequency: s.HTTPCheckFrequency.Duration,
228+
ImageGCPolicy: imageGCPolicy,
229+
KubeClient: nil,
230+
ManifestURL: s.ManifestURL,
231+
ManifestURLHeader: manifestURLHeader,
232+
MasterServiceNamespace: s.MasterServiceNamespace,
233+
MaxContainerCount: s.MaxContainerCount,
234+
MaxOpenFiles: s.MaxOpenFiles,
235+
MaxPerPodContainerCount: s.MaxPerPodContainerCount,
236+
MaxPods: s.MaxPods,
237+
MinimumGCAge: s.MinimumGCAge.Duration,
238+
Mounter: mounter,
239+
NetworkPluginName: networkPluginName,
240+
NetworkPlugins: networkPlugins,
241+
NodeLabels: s.NodeLabels,
242+
NodeStatusUpdateFrequency: s.NodeStatusUpdateFrequency.Duration,
243+
NonMasqueradeCIDR: s.NonMasqueradeCIDR,
244+
OOMAdjuster: oom.NewOOMAdjuster(),
245+
OSInterface: kubecontainer.RealOS{},
246+
PodCIDR: s.PodCIDR,
247+
ReconcileCIDR: s.ReconcileCIDR,
248+
PodInfraContainerImage: s.PodInfraContainerImage,
249+
DisableHyperInternalService: s.DisableHyperInternalService,
249250
Port: s.Port,
250251
ReadOnlyPort: s.ReadOnlyPort,
251252
RegisterNode: s.RegisterNode,
@@ -720,6 +721,7 @@ type KubeletConfig struct {
720721
ContainerManager cm.ContainerManager
721722
ContainerRuntime string
722723
CPUCFSQuota bool
724+
DisableHyperInternalService bool
723725
DiskSpacePolicy kubelet.DiskSpacePolicy
724726
DockerClient dockertools.DockerInterface
725727
RuntimeCgroups string
@@ -879,6 +881,7 @@ func CreateAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod
879881
kc.HairpinMode,
880882
kc.BabysitDaemons,
881883
kc.Options,
884+
kc.DisableHyperInternalService,
882885
)
883886

884887
if err != nil {

docs/admin/kube-proxy.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ kube-proxy
3030
--config-sync-period=15m0s: How often configuration from the apiserver is refreshed. Must be greater than 0.
3131
--conntrack-max=262144: Maximum number of NAT connections to track (0 to leave as-is)
3232
--conntrack-tcp-timeout-established=24h0m0s: Idle timeout for established TCP connections (0 to leave as-is)
33+
--disable-hyper-internal-service[=false]: Disable the internal haproxy service in Hyper pods
3334
--google-json-key="": The Google Cloud Platform Service Account JSON Key to use for authentication.
3435
--healthz-bind-address=127.0.0.1: The IP address for the health check server to serve on, defaulting to 127.0.0.1 (set to 0.0.0.0 for all interfaces)
3536
--healthz-port=10249: The port to bind the health check server. Use 0 to disable.
@@ -43,25 +44,13 @@ kube-proxy
4344
--masquerade-all[=false]: If using the pure iptables proxy, SNAT everything
4445
--master="": The address of the Kubernetes API server (overrides any value in kubeconfig)
4546
--oom-score-adj=-999: The oom-score-adj value for kube-proxy process. Values must be within the range [-1000, 1000]
46-
<<<<<<< b1fd15c08dee9971bd6d691aba1c4676fa90fa39
4747
--proxy-mode=: Which proxy mode to use: 'userspace' (older) or 'iptables' (faster). If blank, look at the Node object on the Kubernetes API and respect the 'net.experimental.kubernetes.io/proxy-mode' annotation if provided. Otherwise use the best-available proxy (currently iptables). If the iptables proxy is selected, regardless of how, but the system's kernel or iptables versions are insufficient, this always falls back to the userspace proxy.
48-
=======
49-
--proxy-mode="haproxy": Which proxy mode to use: 'userspace' (older, stable) , 'iptables' (experimental) or haproxy (for hyper only). If blank, look at the Node object on the Kubernetes API and respect the 'net.experimental.kubernetes.io/proxy-mode' annotation if provided. Otherwise use the best-available proxy (currently userspace, but may change in future versions). If the iptables proxy is selected, regardless of how, but the system's kernel or iptables versions are insufficient, this always falls back to the userspace proxy.
50-
>>>>>>> Rebased with kubernetes upstream
5148
--proxy-port-range=: Range of host ports (beginPort-endPort, inclusive) that may be consumed in order to proxy service traffic. If unspecified (0-0) then ports will be randomly chosen.
5249
--udp-timeout=250ms: How long an idle UDP connection will be kept open (e.g. '250ms', '2s'). Must be greater than 0. Only applicable for proxy-mode=userspace
5350
```
5451

5552
###### Auto generated by spf13/cobra on 7-Feb-2016
5653

57-
58-
59-
60-
<!-- BEGIN MUNGE: IS_VERSIONED -->
61-
<!-- TAG IS_VERSIONED -->
62-
<!-- END MUNGE: IS_VERSIONED -->
63-
64-
6554
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
6655
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/admin/kube-proxy.md?pixel)]()
6756
<!-- END MUNGE: GENERATED_ANALYTICS -->

docs/admin/kubelet.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ kubelet
8181
--container-runtime="docker": The container runtime to use. Possible values: 'docker', 'rkt'. Default: 'docker'.
8282
--containerized[=false]: Experimental support for running kubelet in a container. Intended for testing. [default=false]
8383
--cpu-cfs-quota[=true]: Enable CPU CFS quota enforcement for containers that specify CPU limits
84+
--disable-hyper-internal-service[=false]: Disable the internal haproxy service in Hyper pods
8485
--docker-endpoint="": If non-empty, use this for the docker endpoint to communicate with
8586
--docker-exec-handler="native": Handler to use when executing a command in a container. Valid values are 'native' and 'nsenter'. Defaults to 'native'.
8687
--enable-custom-metrics[=false]: Support for gathering custom metrics.

hack/verify-flags/known-flags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ disable-filter
8484
docker-email
8585
docker-endpoint
8686
docker-exec-handler
87+
disable-hyper-internal-service
8788
docker-password
8889
docker-server
8990
docker-username

pkg/apis/componentconfig/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ type KubeProxyConfiguration struct {
2424
// bindAddress is the IP address for the proxy server to serve on (set to 0.0.0.0
2525
// for all interfaces)
2626
BindAddress string `json:"bindAddress"`
27+
// disableHyperInternalService disables haproxy proxy in Hyper Pod
28+
DisableHyperInternalService bool `json:"DisableHyperInternalService"`
2729
// healthzBindAddress is the IP address for the health check server to serve on,
2830
// defaulting to 127.0.0.1 (set to 0.0.0.0 for all interfaces)
2931
HealthzBindAddress string `json:"healthzBindAddress"`
@@ -102,6 +104,8 @@ type KubeletConfiguration struct {
102104
Config string `json:"config"`
103105
// cinderConfig is the config file for openstack cinder
104106
CinderConfig string `json:""CinderConfig`
107+
// disableHyperInternalService disables haproxy in Hyper pod
108+
DisableHyperInternalService bool `json:"DisableHyperInternalService"`
105109
// syncFrequency is the max period between synchronizing running
106110
// containers and config
107111
SyncFrequency unversioned.Duration `json:"syncFrequency"`

pkg/kubelet/hyper/hyper.go

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ type runtime struct {
7474
imagePuller kubecontainer.ImagePuller
7575
version kubecontainer.Version
7676

77+
// Disable the internal haproxy service in Hyper pods
78+
disableHyperInternalService bool
79+
7780
// Runner of lifecycle events.
7881
runner kubecontainer.HandlerRunner
7982
}
@@ -95,6 +98,7 @@ func New(generator kubecontainer.RunContainerOptionsGenerator,
9598
imageBackOff *util.Backoff,
9699
serializeImagePulls bool,
97100
httpClient kubetypes.HttpGetter,
101+
disableHyperInternalService bool,
98102
) (kubecontainer.Runtime, error) {
99103
// check hyper has already installed
100104
hyperBinAbsPath, err := exec.LookPath(hyperBinName)
@@ -104,16 +108,17 @@ func New(generator kubecontainer.RunContainerOptionsGenerator,
104108
}
105109

106110
hyper := &runtime{
107-
hyperBinAbsPath: hyperBinAbsPath,
108-
dockerKeyring: credentialprovider.NewDockerKeyring(),
109-
containerRefManager: containerRefManager,
110-
generator: generator,
111-
livenessManager: livenessManager,
112-
recorder: recorder,
113-
networkPlugin: networkPlugin,
114-
volumeGetter: volumeGetter,
115-
hyperClient: NewHyperClient(),
116-
kubeClient: kubeClient,
111+
hyperBinAbsPath: hyperBinAbsPath,
112+
dockerKeyring: credentialprovider.NewDockerKeyring(),
113+
containerRefManager: containerRefManager,
114+
generator: generator,
115+
livenessManager: livenessManager,
116+
recorder: recorder,
117+
networkPlugin: networkPlugin,
118+
volumeGetter: volumeGetter,
119+
hyperClient: NewHyperClient(),
120+
kubeClient: kubeClient,
121+
disableHyperInternalService: disableHyperInternalService,
117122
}
118123

119124
if serializeImagePulls {
@@ -454,17 +459,19 @@ func (r *runtime) buildHyperPod(pod *api.Pod, restartCount int, pullSecrets []ap
454459

455460
glog.V(4).Infof("Hyper volumes: %v", volumes)
456461

457-
services := r.buildHyperPodServices(pod)
458-
if services == nil {
459-
// services can't be null for kubernetes, so fake one if it is null
460-
services = []HyperService{
461-
{
462-
ServiceIP: "127.0.0.2",
463-
ServicePort: 65534,
464-
},
462+
if !r.disableHyperInternalService {
463+
services := r.buildHyperPodServices(pod)
464+
if services == nil {
465+
// services can't be null for kubernetes, so fake one if it is null
466+
services = []HyperService{
467+
{
468+
ServiceIP: "127.0.0.2",
469+
ServicePort: 65534,
470+
},
471+
}
465472
}
473+
specMap["services"] = services
466474
}
467-
specMap["services"] = services
468475

469476
// build hyper containers spec
470477
var containers []map[string]interface{}

pkg/kubelet/hyper/hyperclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const (
3939
HYPER_PROTO = "unix"
4040
HYPER_ADDR = "/var/run/hyper.sock"
4141
HYPER_SCHEME = "http"
42-
HYPER_MINVERSION = "0.4.0"
42+
HYPER_MINVERSION = "0.5.0"
4343
DEFAULT_IMAGE_TAG = "latest"
4444

4545
KEY_COMMAND = "command"

pkg/kubelet/kubelet.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ func NewMainKubelet(
218218
hairpinMode string,
219219
babysitDaemons bool,
220220
kubeOptions []Option,
221+
disableHyperInternalService bool,
221222
) (*Kubelet, error) {
222223
if rootDirectory == "" {
223224
return nil, fmt.Errorf("invalid root directory %q", rootDirectory)
@@ -341,6 +342,7 @@ func NewMainKubelet(
341342
reservation: reservation,
342343
enableCustomMetrics: enableCustomMetrics,
343344
babysitDaemons: babysitDaemons,
345+
disableHyperInternalService: disableHyperInternalService,
344346
}
345347
// TODO: Factor out "StatsProvider" from Kubelet so we don't have a cyclic dependency
346348
klet.resourceAnalyzer = stats.NewResourceAnalyzer(klet, volumeStatsAggPeriod)
@@ -444,6 +446,7 @@ func NewMainKubelet(
444446
imageBackOff,
445447
serializeImagePulls,
446448
klet.httpClient,
449+
klet.disableHyperInternalService,
447450
)
448451
if err != nil {
449452
return nil, err
@@ -775,6 +778,9 @@ type Kubelet struct {
775778

776779
// handlers called during the tryUpdateNodeStatus cycle
777780
setNodeStatusFuncs []func(*api.Node) error
781+
782+
// Disable the internal haproxy service in Hyper pods
783+
disableHyperInternalService bool
778784
}
779785

780786
// Validate given node IP belongs to the current host

pkg/proxy/haproxy/proxier.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ type Proxier struct {
6868
haveReceivedEndpointsUpdate bool // true once we've seen an OnEndpointsUpdate event
6969

7070
// These are effectively const and do not need the mutex to be held.
71-
syncPeriod time.Duration
72-
masqueradeAll bool
71+
syncPeriod time.Duration
72+
masqueradeAll bool
73+
disableHyperInternalService bool
7374
}
7475

7576
type localPort struct {
@@ -91,7 +92,7 @@ type closeable interface {
9192
var _ proxy.ProxyProvider = &Proxier{}
9293

9394
// NewProxier returns a new Proxier given an pod-buildin-haproxy Interface instance.
94-
func NewProxier(syncPeriod time.Duration, kubeClient *kubeclient.Client) (*Proxier, error) {
95+
func NewProxier(syncPeriod time.Duration, kubeClient *kubeclient.Client, disableHyperInternalService bool) (*Proxier, error) {
9596
client := hyper.NewHyperClient()
9697
_, err := client.Version()
9798
if err != nil {
@@ -100,11 +101,12 @@ func NewProxier(syncPeriod time.Duration, kubeClient *kubeclient.Client) (*Proxi
100101
}
101102

102103
return &Proxier{
103-
serviceMap: make(map[proxy.ServicePortName]*serviceInfo),
104-
portsMap: make(map[localPort]closeable),
105-
syncPeriod: syncPeriod,
106-
hyperClient: client,
107-
kubeClient: kubeClient,
104+
serviceMap: make(map[proxy.ServicePortName]*serviceInfo),
105+
portsMap: make(map[localPort]closeable),
106+
syncPeriod: syncPeriod,
107+
hyperClient: client,
108+
kubeClient: kubeClient,
109+
disableHyperInternalService: disableHyperInternalService,
108110
}, nil
109111
}
110112

@@ -352,6 +354,10 @@ func flattenValidEndpoints(endpoints []hostPortPair) []string {
352354
// This is where all of haproxy-setting calls happen.
353355
// assumes proxier.mu is held
354356
func (proxier *Proxier) syncProxyRules() {
357+
if proxier.disableHyperInternalService {
358+
return
359+
}
360+
355361
// don't sync rules till we've received services and endpoints
356362
if !proxier.haveReceivedEndpointsUpdate || !proxier.haveReceivedServiceUpdate {
357363
glog.V(2).Info("Not syncing proxy rules until Services and Endpoints have been received from master")

0 commit comments

Comments
 (0)