Move the addon-manager and dashboard configuration from the iso to minikube.

Minikube now copies these into the VM, just like it copies in localkube.
New ISOs will not contain these files, but this is compatible with the existing ISO
because minikube will overwrite existing files.
pull/190/head
dlorenc 2016-06-09 11:38:33 -07:00
parent cda67a4c15
commit ac14eff554
8 changed files with 113 additions and 54 deletions

2
.gitignore vendored
View File

@ -26,5 +26,5 @@ _testmain.go
/out
/_gopath
/pkg/minikube/cluster/localkubecontents.go
/pkg/minikube/cluster/assets.go
/minikube

View File

@ -43,7 +43,7 @@ LOCALKUBE_LDFLAGS := "$(K8S_VERSION_LDFLAGS) $(MINIKUBE_LDFLAGS) -s -w -extldfla
clean:
rm -rf $(GOPATH)
rm -rf $(BUILD_DIR)
rm pkg/minikube/cluster/localkubecontents.go
rm pkg/minikube/cluster/assets.go
MKGOPATH := mkdir -p $(shell dirname $(GOPATH)/src/$(REPOPATH)) && ln -s -f $(shell pwd) $(GOPATH)/src/$(REPOPATH)
@ -61,7 +61,7 @@ else
docker run -w /go/src/$(REPOPATH) -e IN_DOCKER=1 -v $(shell pwd):/go/src/$(REPOPATH) $(BUILD_IMAGE) make out/localkube
endif
out/minikube-$(GOOS)-$(GOARCH): $(MINIKUBEFILES) pkg/minikube/cluster/localkubecontents.go
out/minikube-$(GOOS)-$(GOARCH): $(MINIKUBEFILES) pkg/minikube/cluster/assets.go
$(MKGOPATH)
CGO_ENABLED=0 GOARCH=$(GOARCH) GOOS=$(GOOS) go build --installsuffix cgo -ldflags="$(MINIKUBE_LDFLAGS)" -a -o $(BUILD_DIR)/minikube-$(GOOS)-$(GOARCH) ./cmd/minikube
@ -76,12 +76,12 @@ integration: out/minikube
go test -v $(REPOPATH)/test/integration --tags=integration
.PHONY: test
test: pkg/minikube/cluster/localkubecontents.go
test: pkg/minikube/cluster/assets.go
$(MKGOPATH)
./test.sh
pkg/minikube/cluster/localkubecontents.go: out/localkube $(GOPATH)/bin/go-bindata
$(GOPATH)/bin/go-bindata -nomemcopy -o pkg/minikube/cluster/localkubecontents.go -pkg cluster ./out/localkube
pkg/minikube/cluster/assets.go: out/localkube $(GOPATH)/bin/go-bindata deploy/iso/addon-manager.yaml deploy/addons/dashboard-rc.yaml deploy/addons/dashboard-svc.yaml
$(GOPATH)/bin/go-bindata -nomemcopy -o pkg/minikube/cluster/assets.go -pkg cluster ./out/localkube deploy/iso/addon-manager.yaml deploy/addons/dashboard-rc.yaml deploy/addons/dashboard-svc.yaml
$(GOPATH)/bin/go-bindata:
$(MKGOPATH)

View File

@ -26,11 +26,6 @@ ADD socat $ROOTFS/usr/bin
ADD ethtool $ROOTFS/usr/bin
ADD conntrack $ROOTFS/usr/bin
# Add addons
ADD addon-manager.yaml $ROOTFS/etc/kubernetes/manifests/
ADD dashboard-rc.yaml $ROOTFS/etc/kubernetes/addons/
ADD dashboard-svc.yaml $ROOTFS/etc/kubernetes/addons/
# Get a specific version of Docker. This will overwrite the binary installed
# in the base image.
# The --strip-components=3 flag will have to change as we switch docker versions

View File

@ -20,8 +20,6 @@ ISO=minikube.iso
tmpdir=$(mktemp -d)
echo "Building in $tmpdir."
cp -r . $tmpdir/
# Copy in the addons
cp ../addons/* $tmpdir/
pushd $tmpdir

View File

@ -173,21 +173,57 @@ func StartCluster(h sshAble) error {
return nil
}
func UpdateCluster(d drivers.Driver) error {
localkube, err := Asset("out/localkube")
if err != nil {
glog.Infoln("Error loading localkube: ", err)
return err
}
type fileToCopy struct {
AssetName string
TargetDir string
TargetName string
Permissions string
}
var assets = []fileToCopy{
{
AssetName: "out/localkube",
TargetDir: "/usr/local/bin",
TargetName: "localkube",
Permissions: "0777",
},
{
AssetName: "deploy/iso/addon-manager.yaml",
TargetDir: "/etc/kubernetes/manifests/",
TargetName: "addon-manager.yaml",
Permissions: "0640",
},
{
AssetName: "deploy/addons/dashboard-rc.yaml",
TargetDir: "/etc/kubernetes/addons/",
TargetName: "dashboard-rc.yaml",
Permissions: "0640",
},
{
AssetName: "deploy/addons/dashboard-svc.yaml",
TargetDir: "/etc/kubernetes/addons/",
TargetName: "dashboard-svc.yaml",
Permissions: "0640",
},
}
func UpdateCluster(d drivers.Driver) error {
client, err := sshutil.NewSSHClient(d)
if err != nil {
return err
}
if err := sshutil.Transfer(localkube, "/usr/local/bin/", "localkube", "0777", client); err != nil {
for _, a := range assets {
contents, err := Asset(a.AssetName)
if err != nil {
glog.Infof("Error loading asset %s: %s", a.AssetName, err)
return err
}
if err := sshutil.Transfer(contents, a.TargetDir, a.TargetName, a.Permissions, client); err != nil {
return err
}
}
return nil
}

View File

@ -459,3 +459,31 @@ func TestGetDashboardURL(t *testing.T) {
}
}
func TestUpdate(t *testing.T) {
s, _ := tests.NewSSHServer()
port, err := s.Start()
if err != nil {
t.Fatalf("Error starting ssh server: %s", err)
}
d := &tests.MockDriver{
Port: port,
BaseDriver: drivers.BaseDriver{
IPAddress: "127.0.0.1",
SSHKeyPath: "",
},
}
if err := UpdateCluster(d); err != nil {
t.Fatalf("Error updating cluster: %s", err)
}
transferred := s.Transfers.Bytes()
for _, a := range assets {
contents, _ := Asset(a.AssetName)
if !bytes.Contains(transferred, contents) {
t.Fatalf("File not copied. Expected transfers to contain: %s. It was: %s", contents, transferred)
}
}
}

View File

@ -74,6 +74,7 @@ func (s *SSHServer) Start() (int, error) {
go func() {
for {
nConn, err := listener.Accept()
go func() {
if err != nil {
return
}
@ -112,6 +113,7 @@ func (s *SSHServer) Start() (int, error) {
io.Copy(s.Transfers, channel)
channel.Close()
}
}()
}
}()

View File

@ -32,7 +32,7 @@ TESTS=$(go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./...)
go test -v ${TESTS}
# Ignore these paths in the following tests.
ignore="vendor\|\_gopath\|localkubecontents.go"
ignore="vendor\|\_gopath\|assets.go"
# Check gofmt
echo "Checking gofmt..."