-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mounting kubectl from the host instead to installing in protokube #3550
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,3 +246,15 @@ func (c *NodeupModelContext) UseSecureKubelet() bool { | |
|
||
return false | ||
} | ||
|
||
// KubectlPath returns distro based path for kubectl | ||
func (c *NodeupModelContext) KubectlPath() string { | ||
kubeletCommand := "/usr/local/bin" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: rename kubeletComamnd to kubectlPath |
||
if c.Distribution == distros.DistributionCoreOS { | ||
kubeletCommand = "/opt/bin" | ||
} | ||
if c.Distribution == distros.DistributionContainerOS { | ||
kubeletCommand = "/home/kubernetes/bin" | ||
} | ||
return kubeletCommand | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ func (b *KubectlBuilder) Build(c *fi.ModelBuilderContext) error { | |
} | ||
|
||
t := &nodetasks.File{ | ||
Path: b.kubectlPath(), | ||
Path: b.KubectlPath() + "/" + assetName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use |
||
Contents: asset, | ||
Type: nodetasks.FileType_File, | ||
Mode: s("0755"), | ||
|
@@ -100,14 +100,3 @@ func (b *KubectlBuilder) Build(c *fi.ModelBuilderContext) error { | |
|
||
return nil | ||
} | ||
|
||
func (b *KubectlBuilder) kubectlPath() string { | ||
kubeletCommand := "/usr/local/bin/kubectl" | ||
if b.Distribution == distros.DistributionCoreOS { | ||
kubeletCommand = "/opt/bin/kubectl" | ||
} | ||
if b.Distribution == distros.DistributionContainerOS { | ||
kubeletCommand = "/home/kubernetes/bin/kubectl" | ||
} | ||
return kubeletCommand | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,12 +108,27 @@ func (t *ProtokubeBuilder) buildSystemdService() (*nodetasks.Service, error) { | |
"-v", "/:/rootfs/", | ||
"-v", "/var/run/dbus:/var/run/dbus", | ||
"-v", "/run/systemd:/run/systemd", | ||
"--net=host", "--privileged", | ||
} | ||
|
||
// add kubectl only if a master | ||
// path changes depending on distro, and always mount it on /opt/kops/bin | ||
// kubectl is downloaded an installed by other tasks | ||
if t.IsMaster { | ||
dockerArgs = append(dockerArgs, []string{ | ||
"-v", t.KubectlPath() + ":/opt/kops/bin:ro", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So docker can actually bind mount a file, which is nice because it avoids dragging in everything in the bin directory. Not sure whether I care, given we mount A potential gotcha is that we have to be careful about shared libraries, but thankfully kubectl is statically linked. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, but we have a chance that protokube will start before kubectl is installed ... async tasks ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah good point, and then we would hit the docker bug where it assumes a directory. The tasks are technically ordered if we tell nodeup about our dependencies, but I do like your way better. |
||
"--env", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/kops/bin", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Probably better to put I guess the problem here is that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well ... I disagree. We need it to be at the end, so that other stuff does not get whacked. First, wins in bash? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK - we don't expect many copies of kubectl :-) Can we have a comment though about why we don't just call kubectl with an absolute path, i.e. why we are messing with the PATH at all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cause we do not want to make changes to channels :P Yes I will make a comment. |
||
}...) | ||
} | ||
|
||
dockerArgs = append(dockerArgs, []string{ | ||
"--net=host", | ||
"--privileged", | ||
"--env", "KUBECONFIG=/rootfs/var/lib/kops/kubeconfig", | ||
t.ProtokubeEnvironmentVariables(), | ||
t.ProtokubeImageName(), | ||
"/usr/bin/protokube", | ||
} | ||
}...) | ||
|
||
protokubeCommand := strings.Join(dockerArgs, " ") + " " + protokubeFlagsArgs | ||
|
||
manifest := &systemd.Manifest{} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops - that comment wasn't right :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM