mirror of https://github.com/kubernetes/kops.git
				
				
				
			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:
		
						commit
						2500ee07f8
					
				|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
| } | ||||
|  |  | |||
|  | @ -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 | ||||
| } | ||||
|  |  | |||
|  | @ -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{} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue