Merge pull request #3550 from chrislovecnm/protokube-kubectl

Automatic merge from submit-queue.

mounting kubectl from the host instead to installing in protokube

So this will fix our protokube kubectl versioning issue.  Kubectl is in on host, if we are on a master, and is always the right version, so let's use it!  Refactored a bit to get the distro path for kubectl.  Need to test on gossip.  Set the path on protokube and mounted kubectl in `/opt/kops/bin`.

/approve

TODO

- [ ] test gossip

Fixes https://github.com/kubernetes/kops/issues/3518
This commit is contained in:
Kubernetes Submit Queue 2017-10-10 03:50:15 -07:00 committed by GitHub
commit 2500ee07f8
5 changed files with 30 additions and 21 deletions

View File

@ -32,9 +32,4 @@ cp /src/.build/local/protokube /src/.build/artifacts/
make channels
cp /src/.build/local/channels /src/.build/artifacts/
# channels uses protokube
cd /src/.build/artifacts/
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.6.6/bin/linux/amd64/kubectl
chmod +x kubectl
chown -R $HOST_UID:$HOST_GID /src/.build/artifacts

View File

@ -21,8 +21,6 @@ RUN apt-get update && apt-get install --yes \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY /.build/artifacts/kubectl /usr/bin/kubectl
COPY /.build/artifacts/protokube /usr/bin/protokube
COPY /.build/artifacts/channels /usr/bin/channels

View File

@ -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"
if c.Distribution == distros.DistributionCoreOS {
kubeletCommand = "/opt/bin"
}
if c.Distribution == distros.DistributionContainerOS {
kubeletCommand = "/home/kubernetes/bin"
}
return kubeletCommand
}

View File

@ -52,7 +52,7 @@ func (b *KubectlBuilder) Build(c *fi.ModelBuilderContext) error {
}
t := &nodetasks.File{
Path: b.kubectlPath(),
Path: b.KubectlPath() + "/" + assetName,
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
}

View File

@ -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",
"--env", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/kops/bin",
}...)
}
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{}