Skip to content

Commit b08e2b7

Browse files
committed
added proxy-kubeconfig flag
1 parent cfb01cd commit b08e2b7

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

contrib/mesos/pkg/minion/server.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type MinionServer struct {
6868
logVerbosity int32 // see glog.Level
6969

7070
runProxy bool
71+
proxyKubeconfig string
7172
proxyLogV int
7273
proxyBindall bool
7374
proxyMode string
@@ -149,7 +150,9 @@ func (ms *MinionServer) launchProxyServer() {
149150
"--conntrack-max=" + strconv.Itoa(ms.conntrackMax),
150151
"--conntrack-tcp-timeout-established=" + strconv.Itoa(ms.conntrackTCPTimeoutEstablished),
151152
}
152-
153+
if ms.proxyKubeconfig != "" {
154+
args = append(args, fmt.Sprintf("--kubeconfig=%s", ms.proxyKubeconfig))
155+
}
153156
if ms.clientConfig.Host != "" {
154157
args = append(args, fmt.Sprintf("--master=%s", ms.clientConfig.Host))
155158
}
@@ -359,6 +362,7 @@ func (ms *MinionServer) AddMinionFlags(fs *pflag.FlagSet) {
359362

360363
// proxy flags
361364
fs.BoolVar(&ms.runProxy, "run-proxy", ms.runProxy, "Maintain a running kube-proxy instance as a child proc of this kubelet-executor.")
365+
fs.StringVar(&ms.proxyKubeconfig, "proxy-kubeconfig", ms.proxyKubeconfig, "Path to kubeconfig file used by the child kube-proxy.")
362366
fs.IntVar(&ms.proxyLogV, "proxy-logv", ms.proxyLogV, "Log verbosity of the child kube-proxy.")
363367
fs.BoolVar(&ms.proxyBindall, "proxy-bindall", ms.proxyBindall, "When true will cause kube-proxy to bind to 0.0.0.0.")
364368
fs.StringVar(&ms.proxyMode, "proxy-mode", ms.proxyMode, "Which proxy mode to use: 'userspace' (older) or 'iptables' (faster). 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.")

contrib/mesos/pkg/scheduler/service/service.go

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,11 @@ type SchedulerServer struct {
134134
launchGracePeriod time.Duration
135135
kubeletEnableDebuggingHandlers bool
136136

137-
runProxy bool
138-
proxyBindall bool
139-
proxyLogV int
140-
proxyMode string
137+
runProxy bool
138+
proxyBindall bool
139+
proxyKubeconfig string
140+
proxyLogV int
141+
proxyMode string
141142

142143
minionPathOverride string
143144
minionLogMaxSize resource.Quantity
@@ -309,6 +310,7 @@ func (s *SchedulerServer) addCoreFlags(fs *pflag.FlagSet) {
309310

310311
fs.BoolVar(&s.proxyBindall, "proxy-bindall", s.proxyBindall, "When true pass -proxy-bindall to the executor.")
311312
fs.BoolVar(&s.runProxy, "run-proxy", s.runProxy, "Run the kube-proxy as a side process of the executor.")
313+
fs.StringVar(&s.proxyKubeconfig, "proxy-kubeconfig", s.proxyKubeconfig, "Path to kubeconfig file with authorization and master location information used by the proxy.")
312314
fs.IntVar(&s.proxyLogV, "proxy-logv", s.proxyLogV, "Logging verbosity of spawned minion proxy processes.")
313315
fs.StringVar(&s.proxyMode, "proxy-mode", s.proxyMode, "Which proxy mode to use: 'userspace' (older) or 'iptables' (faster). 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.")
314316

@@ -405,6 +407,12 @@ func (s *SchedulerServer) prepareExecutorInfo(hks hyperkube.Interface) (*mesos.E
405407

406408
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--run-proxy=%v", s.runProxy))
407409
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--proxy-bindall=%v", s.proxyBindall))
410+
if s.proxyKubeconfig != "" {
411+
//TODO(jdef) should probably support non-local files, e.g. hdfs:///some/config/file
412+
uri, basename := s.serveFrameworkArtifact(s.proxyKubeconfig)
413+
ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(uri)})
414+
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--proxy-kubeconfig=%v", basename))
415+
}
408416
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--proxy-logv=%d", s.proxyLogV))
409417
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--proxy-mode=%v", s.proxyMode))
410418

@@ -459,9 +467,18 @@ func (s *SchedulerServer) prepareExecutorInfo(hks hyperkube.Interface) (*mesos.E
459467

460468
if s.kubeletKubeconfig != "" {
461469
//TODO(jdef) should probably support non-local files, e.g. hdfs:///some/config/file
462-
uri, basename := s.serveFrameworkArtifact(s.kubeletKubeconfig)
463-
ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(uri)})
464-
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--kubeconfig=%s", basename))
470+
if s.kubeletKubeconfig != s.proxyKubeconfig {
471+
if filepath.Base(s.kubeletKubeconfig) == filepath.Base(s.proxyKubeconfig) {
472+
// scheduler serves kubelet-kubeconfig and proxy-kubeconfig by their basename
473+
// we currently don't support the case where the 2 kubeconfig files have the same
474+
// basename but different absolute name, e.g., /kubelet/kubeconfig and /proxy/kubeconfig
475+
return nil, fmt.Errorf("if kubelet-kubeconfig and proxy-kubeconfig are different, they must have different basenames")
476+
}
477+
// allows kubelet-kubeconfig and proxy-kubeconfig to point to the same file
478+
uri, _ := s.serveFrameworkArtifact(s.kubeletKubeconfig)
479+
ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(uri)})
480+
}
481+
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--kubeconfig=%s", filepath.Base(s.kubeletKubeconfig)))
465482
}
466483
appendOptional := func(name string, value string) {
467484
if value != "" {

hack/verify-flags/known-flags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ private-mountns
288288
prom-push-gateway
289289
proto-import
290290
proxy-bindall
291+
proxy-kubeconfig
291292
proxy-logv
292293
proxy-mode
293294
proxy-port-range

0 commit comments

Comments
 (0)