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

Commit 1e52028

Browse files
committed
Merge pull request #74 from feiskyer/disable-haproxy-opts
Add options to disable hyper pod-internal services
2 parents 4fd0ca1 + 4fbe317 commit 1e52028

File tree

11 files changed

+111
-82
lines changed

11 files changed

+111
-82
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type ProxyServerConfig struct {
5050
NodeRef *api.ObjectReference // Reference to this node.
5151
MasqueradeAll bool
5252
CleanupAndExit bool
53+
DisableHyperInternalService bool
5354
KubeAPIQPS float32
5455
KubeAPIBurst int
5556
UDPIdleTimeout time.Duration
@@ -77,6 +78,7 @@ func NewProxyConfig() *ProxyServerConfig {
7778
// AddFlags adds flags for a specific ProxyServer to the specified FlagSet
7879
func (s *ProxyServerConfig) AddFlags(fs *pflag.FlagSet) {
7980
fs.IPVar(&s.BindAddress, "bind-address", s.BindAddress, "The IP address for the proxy server to serve on (set to 0.0.0.0 for all interfaces)")
81+
fs.BoolVar(&s.DisableHyperInternalService, "disable-hyper-internal-service", s.DisableHyperInternalService, "Disable the internal haproxy service in Hyper pods")
8082
fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)")
8183
fs.IntVar(&s.HealthzPort, "healthz-port", s.HealthzPort, "The port to bind the health check server. Use 0 to disable.")
8284
fs.IPVar(&s.HealthzBindAddress, "healthz-bind-address", s.HealthzBindAddress, "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
@@ -200,7 +200,7 @@ func NewProxyServerDefault(config *options.ProxyServerConfig) (*ProxyServer, err
200200
userspace.CleanupLeftovers(iptInterface)
201201
case proxyModeHaproxy:
202202
glog.V(2).Info("Using pod-buildin-haproxy proxy.")
203-
proxierBuildin, err := haproxy.NewProxier(config.ConfigSyncPeriod, client)
203+
proxierBuildin, err := haproxy.NewProxier(config.ConfigSyncPeriod, client, config.DisableHyperInternalService)
204204
if err != nil {
205205
glog.Fatalf("Unable to create proxier: %v", err)
206206
}

cmd/kubelet/app/options/options.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type KubeletServer struct {
5555
ConfigureCBR0 bool
5656
ContainerRuntime string
5757
CPUCFSQuota bool
58+
DisableHyperInternalService bool
5859
DockerDaemonContainer string
5960
DockerEndpoint string
6061
DockerExecHandlerName string
@@ -202,6 +203,7 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
202203
fs.DurationVar(&s.HTTPCheckFrequency, "http-check-frequency", s.HTTPCheckFrequency, "Duration between checking http for new data")
203204
fs.StringVar(&s.ManifestURL, "manifest-url", s.ManifestURL, "URL for accessing the container manifest")
204205
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'")
206+
fs.BoolVar(&s.DisableHyperInternalService, "disable-hyper-internal-service", s.DisableHyperInternalService, "Disable the internal haproxy service in Hyper pods")
205207
fs.BoolVar(&s.EnableServer, "enable-server", s.EnableServer, "Enable the Kubelet's server")
206208
fs.IPVar(&s.Address, "address", s.Address, "The IP address for the Kubelet to serve on (set to 0.0.0.0 for all interfaces)")
207209
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
@@ -186,57 +186,58 @@ func UnsecuredKubeletConfig(s *options.KubeletServer) (*KubeletConfig, error) {
186186
}
187187

188188
return &KubeletConfig{
189-
Address: s.Address,
190-
AllowPrivileged: s.AllowPrivileged,
191-
Auth: nil, // default does not enforce auth[nz]
192-
CAdvisorInterface: nil, // launches background processes, not set here
193-
CgroupRoot: s.CgroupRoot,
194-
CinderConfig: s.CinderConfig,
195-
Cloud: nil, // cloud provider might start background processes
196-
ClusterDNS: s.ClusterDNS,
197-
ClusterDomain: s.ClusterDomain,
198-
ConfigFile: s.Config,
199-
ConfigureCBR0: s.ConfigureCBR0,
200-
ContainerManager: nil,
201-
ContainerRuntime: s.ContainerRuntime,
202-
CPUCFSQuota: s.CPUCFSQuota,
203-
DiskSpacePolicy: diskSpacePolicy,
204-
DockerClient: dockertools.ConnectToDockerOrDie(s.DockerEndpoint),
205-
DockerDaemonContainer: s.DockerDaemonContainer,
206-
DockerExecHandler: dockerExecHandler,
207-
EnableDebuggingHandlers: s.EnableDebuggingHandlers,
208-
EnableServer: s.EnableServer,
209-
EventBurst: s.EventBurst,
210-
EventRecordQPS: s.EventRecordQPS,
211-
FileCheckFrequency: s.FileCheckFrequency,
212-
HostnameOverride: s.HostnameOverride,
213-
HostNetworkSources: hostNetworkSources,
214-
HostPIDSources: hostPIDSources,
215-
HostIPCSources: hostIPCSources,
216-
HTTPCheckFrequency: s.HTTPCheckFrequency,
217-
ImageGCPolicy: imageGCPolicy,
218-
KubeClient: nil,
219-
ManifestURL: s.ManifestURL,
220-
ManifestURLHeader: manifestURLHeader,
221-
MasterServiceNamespace: s.MasterServiceNamespace,
222-
MaxContainerCount: s.MaxContainerCount,
223-
MaxOpenFiles: s.MaxOpenFiles,
224-
MaxPerPodContainerCount: s.MaxPerPodContainerCount,
225-
MaxPods: s.MaxPods,
226-
MinimumGCAge: s.MinimumGCAge,
227-
Mounter: mounter,
228-
ChownRunner: chownRunner,
229-
ChmodRunner: chmodRunner,
230-
NetworkPluginName: networkPluginName,
231-
NetworkPlugins: networkPlugins,
232-
NodeLabels: s.NodeLabels,
233-
NodeLabelsFile: s.NodeLabelsFile,
234-
NodeStatusUpdateFrequency: s.NodeStatusUpdateFrequency,
235-
OOMAdjuster: oom.NewOOMAdjuster(),
236-
OSInterface: kubecontainer.RealOS{},
237-
PodCIDR: s.PodCIDR,
238-
ReconcileCIDR: s.ReconcileCIDR,
239-
PodInfraContainerImage: s.PodInfraContainerImage,
189+
Address: s.Address,
190+
AllowPrivileged: s.AllowPrivileged,
191+
Auth: nil, // default does not enforce auth[nz]
192+
CAdvisorInterface: nil, // launches background processes, not set here
193+
CgroupRoot: s.CgroupRoot,
194+
CinderConfig: s.CinderConfig,
195+
Cloud: nil, // cloud provider might start background processes
196+
ClusterDNS: s.ClusterDNS,
197+
ClusterDomain: s.ClusterDomain,
198+
ConfigFile: s.Config,
199+
ConfigureCBR0: s.ConfigureCBR0,
200+
ContainerManager: nil,
201+
ContainerRuntime: s.ContainerRuntime,
202+
CPUCFSQuota: s.CPUCFSQuota,
203+
DisableHyperInternalService: s.DisableHyperInternalService,
204+
DiskSpacePolicy: diskSpacePolicy,
205+
DockerClient: dockertools.ConnectToDockerOrDie(s.DockerEndpoint),
206+
DockerDaemonContainer: s.DockerDaemonContainer,
207+
DockerExecHandler: dockerExecHandler,
208+
EnableDebuggingHandlers: s.EnableDebuggingHandlers,
209+
EnableServer: s.EnableServer,
210+
EventBurst: s.EventBurst,
211+
EventRecordQPS: s.EventRecordQPS,
212+
FileCheckFrequency: s.FileCheckFrequency,
213+
HostnameOverride: s.HostnameOverride,
214+
HostNetworkSources: hostNetworkSources,
215+
HostPIDSources: hostPIDSources,
216+
HostIPCSources: hostIPCSources,
217+
HTTPCheckFrequency: s.HTTPCheckFrequency,
218+
ImageGCPolicy: imageGCPolicy,
219+
KubeClient: nil,
220+
ManifestURL: s.ManifestURL,
221+
ManifestURLHeader: manifestURLHeader,
222+
MasterServiceNamespace: s.MasterServiceNamespace,
223+
MaxContainerCount: s.MaxContainerCount,
224+
MaxOpenFiles: s.MaxOpenFiles,
225+
MaxPerPodContainerCount: s.MaxPerPodContainerCount,
226+
MaxPods: s.MaxPods,
227+
MinimumGCAge: s.MinimumGCAge,
228+
Mounter: mounter,
229+
ChownRunner: chownRunner,
230+
ChmodRunner: chmodRunner,
231+
NetworkPluginName: networkPluginName,
232+
NetworkPlugins: networkPlugins,
233+
NodeLabels: s.NodeLabels,
234+
NodeLabelsFile: s.NodeLabelsFile,
235+
NodeStatusUpdateFrequency: s.NodeStatusUpdateFrequency,
236+
OOMAdjuster: oom.NewOOMAdjuster(),
237+
OSInterface: kubecontainer.RealOS{},
238+
PodCIDR: s.PodCIDR,
239+
ReconcileCIDR: s.ReconcileCIDR,
240+
PodInfraContainerImage: s.PodInfraContainerImage,
240241
Port: s.Port,
241242
ReadOnlyPort: s.ReadOnlyPort,
242243
RegisterNode: s.RegisterNode,
@@ -676,6 +677,7 @@ type KubeletConfig struct {
676677
ContainerManager cm.ContainerManager
677678
ContainerRuntime string
678679
CPUCFSQuota bool
680+
DisableHyperInternalService bool
679681
DiskSpacePolicy kubelet.DiskSpacePolicy
680682
DockerClient dockertools.DockerInterface
681683
DockerDaemonContainer string
@@ -828,6 +830,7 @@ func CreateAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod
828830
kc.OutOfDiskTransitionFrequency,
829831
kc.ExperimentalFlannelOverlay,
830832
kc.NodeIP,
833+
kc.DisableHyperInternalService,
831834
)
832835

833836
if err != nil {

docs/admin/kube-proxy.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ kube-proxy
5959
--config-sync-period=15m0s: How often configuration from the apiserver is refreshed. Must be greater than 0.
6060
--conntrack-max=262144: Maximum number of NAT connections to track (0 to leave as-is)
6161
--conntrack-tcp-timeout-established=86400: Idle timeout for established TCP connections (0 to leave as-is)
62+
--disable-hyper-internal-service[=false]: Disable the internal haproxy service in Hyper pods
6263
--google-json-key="": The Google Cloud Platform Service Account JSON Key to use for authentication.
6364
--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)
6465
--healthz-port=10249: The port to bind the health check server. Use 0 to disable.
@@ -76,7 +77,7 @@ kube-proxy
7677
--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
7778
```
7879

79-
###### Auto generated by spf13/cobra on 30-Dec-2015
80+
###### Auto generated by spf13/cobra on 23-Feb-2016
8081

8182

8283
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->

docs/admin/kubelet.md

Lines changed: 2 additions & 1 deletion
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[=false]: 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-debugging-handlers[=true]: Enables server endpoints for log collection and local running of containers and commands
@@ -146,7 +147,7 @@ kubelet
146147
--volume-plugin-dir="/usr/libexec/kubernetes/kubelet-plugins/volume/exec/": <Warning: Alpha feature> The full path of the directory in which to search for additional third party volume plugins
147148
```
148149

149-
###### Auto generated by spf13/cobra on 12-Jan-2016
150+
###### Auto generated by spf13/cobra on 23-Feb-2016
150151

151152

152153
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->

hack/verify-flags/known-flags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ disable-filter
7575
docker-email
7676
docker-endpoint
7777
docker-exec-handler
78+
disable-hyper-internal-service
7879
docker-password
7980
docker-server
8081
docker-username

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 {
@@ -446,17 +451,19 @@ func (r *runtime) buildHyperPod(pod *api.Pod, restartCount int, pullSecrets []ap
446451

447452
glog.V(4).Infof("Hyper volumes: %v", volumes)
448453

449-
services := r.buildHyperPodServices(pod)
450-
if services == nil {
451-
// services can't be null for kubernetes, so fake one if it is null
452-
services = []HyperService{
453-
{
454-
ServiceIP: "127.0.0.2",
455-
ServicePort: 65534,
456-
},
454+
if !r.disableHyperInternalService {
455+
services := r.buildHyperPodServices(pod)
456+
if services == nil {
457+
// services can't be null for kubernetes, so fake one if it is null
458+
services = []HyperService{
459+
{
460+
ServiceIP: "127.0.0.2",
461+
ServicePort: 65534,
462+
},
463+
}
457464
}
465+
specMap["services"] = services
458466
}
459-
specMap["services"] = services
460467

461468
// build hyper containers spec
462469
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
@@ -198,6 +198,7 @@ func NewMainKubelet(
198198
outOfDiskTransitionFrequency time.Duration,
199199
flannelExperimentalOverlay bool,
200200
nodeIP net.IP,
201+
disableHyperInternalService bool,
201202
) (*Kubelet, error) {
202203
if rootDirectory == "" {
203204
return nil, fmt.Errorf("invalid root directory %q", rootDirectory)
@@ -317,6 +318,7 @@ func NewMainKubelet(
317318
nodeIP: nodeIP,
318319
clock: util.RealClock{},
319320
outOfDiskTransitionFrequency: outOfDiskTransitionFrequency,
321+
disableHyperInternalService: disableHyperInternalService,
320322
}
321323
if klet.flannelExperimentalOverlay {
322324
glog.Infof("Flannel is in charge of podCIDR and overlay networking.")
@@ -403,6 +405,7 @@ func NewMainKubelet(
403405
imageBackOff,
404406
serializeImagePulls,
405407
klet.httpClient,
408+
klet.disableHyperInternalService,
406409
)
407410
if err != nil {
408411
return nil, err
@@ -686,6 +689,9 @@ type Kubelet struct {
686689
// not-out-of-disk. This prevents a pod that causes out-of-disk condition from repeatedly
687690
// getting rescheduled onto the node.
688691
outOfDiskTransitionFrequency time.Duration
692+
693+
// Disable the internal haproxy service in Hyper pods
694+
disableHyperInternalService bool
689695
}
690696

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

0 commit comments

Comments
 (0)