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
parent
cda67a4c15
commit
ac14eff554
|
@ -26,5 +26,5 @@ _testmain.go
|
||||||
/out
|
/out
|
||||||
/_gopath
|
/_gopath
|
||||||
|
|
||||||
/pkg/minikube/cluster/localkubecontents.go
|
/pkg/minikube/cluster/assets.go
|
||||||
/minikube
|
/minikube
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -43,7 +43,7 @@ LOCALKUBE_LDFLAGS := "$(K8S_VERSION_LDFLAGS) $(MINIKUBE_LDFLAGS) -s -w -extldfla
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(GOPATH)
|
rm -rf $(GOPATH)
|
||||||
rm -rf $(BUILD_DIR)
|
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)
|
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
|
docker run -w /go/src/$(REPOPATH) -e IN_DOCKER=1 -v $(shell pwd):/go/src/$(REPOPATH) $(BUILD_IMAGE) make out/localkube
|
||||||
endif
|
endif
|
||||||
|
|
||||||
out/minikube-$(GOOS)-$(GOARCH): $(MINIKUBEFILES) pkg/minikube/cluster/localkubecontents.go
|
out/minikube-$(GOOS)-$(GOARCH): $(MINIKUBEFILES) pkg/minikube/cluster/assets.go
|
||||||
$(MKGOPATH)
|
$(MKGOPATH)
|
||||||
CGO_ENABLED=0 GOARCH=$(GOARCH) GOOS=$(GOOS) go build --installsuffix cgo -ldflags="$(MINIKUBE_LDFLAGS)" -a -o $(BUILD_DIR)/minikube-$(GOOS)-$(GOARCH) ./cmd/minikube
|
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
|
go test -v $(REPOPATH)/test/integration --tags=integration
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: pkg/minikube/cluster/localkubecontents.go
|
test: pkg/minikube/cluster/assets.go
|
||||||
$(MKGOPATH)
|
$(MKGOPATH)
|
||||||
./test.sh
|
./test.sh
|
||||||
|
|
||||||
pkg/minikube/cluster/localkubecontents.go: out/localkube $(GOPATH)/bin/go-bindata
|
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/localkubecontents.go -pkg cluster ./out/localkube
|
$(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:
|
$(GOPATH)/bin/go-bindata:
|
||||||
$(MKGOPATH)
|
$(MKGOPATH)
|
||||||
|
|
|
@ -26,11 +26,6 @@ ADD socat $ROOTFS/usr/bin
|
||||||
ADD ethtool $ROOTFS/usr/bin
|
ADD ethtool $ROOTFS/usr/bin
|
||||||
ADD conntrack $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
|
# Get a specific version of Docker. This will overwrite the binary installed
|
||||||
# in the base image.
|
# in the base image.
|
||||||
# The --strip-components=3 flag will have to change as we switch docker versions
|
# The --strip-components=3 flag will have to change as we switch docker versions
|
||||||
|
|
|
@ -20,8 +20,6 @@ ISO=minikube.iso
|
||||||
tmpdir=$(mktemp -d)
|
tmpdir=$(mktemp -d)
|
||||||
echo "Building in $tmpdir."
|
echo "Building in $tmpdir."
|
||||||
cp -r . $tmpdir/
|
cp -r . $tmpdir/
|
||||||
# Copy in the addons
|
|
||||||
cp ../addons/* $tmpdir/
|
|
||||||
|
|
||||||
pushd $tmpdir
|
pushd $tmpdir
|
||||||
|
|
||||||
|
|
|
@ -173,21 +173,57 @@ func StartCluster(h sshAble) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateCluster(d drivers.Driver) error {
|
type fileToCopy struct {
|
||||||
localkube, err := Asset("out/localkube")
|
AssetName string
|
||||||
if err != nil {
|
TargetDir string
|
||||||
glog.Infoln("Error loading localkube: ", err)
|
TargetName string
|
||||||
return err
|
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)
|
client, err := sshutil.NewSSHClient(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := sshutil.Transfer(localkube, "/usr/local/bin/", "localkube", "0777", client); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -74,44 +74,46 @@ func (s *SSHServer) Start() (int, error) {
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
nConn, err := listener.Accept()
|
nConn, err := listener.Accept()
|
||||||
if err != nil {
|
go func() {
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
_, chans, reqs, err := ssh.NewServerConn(nConn, s.Config)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// The incoming Request channel must be serviced.
|
|
||||||
go ssh.DiscardRequests(reqs)
|
|
||||||
|
|
||||||
// Service the incoming Channel channel.
|
|
||||||
for newChannel := range chans {
|
|
||||||
if newChannel.ChannelType() == "session" {
|
|
||||||
s.HadASessionRequested = true
|
|
||||||
}
|
|
||||||
channel, requests, err := newChannel.Accept()
|
|
||||||
s.Connected = true
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
req := <-requests
|
_, chans, reqs, err := ssh.NewServerConn(nConn, s.Config)
|
||||||
req.Reply(true, nil)
|
if err != nil {
|
||||||
|
|
||||||
//Note: string(req.Payload) adds additional characters to start of input, execRequest used to solve this issue
|
|
||||||
var cmd execRequest
|
|
||||||
if err := ssh.Unmarshal(req.Payload, &cmd); err != nil {
|
|
||||||
glog.Errorln("Unmarshall encountered error: %s", err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.Commands[cmd.Command] = 1
|
// The incoming Request channel must be serviced.
|
||||||
channel.SendRequest("exit-status", false, []byte{0, 0, 0, 0})
|
go ssh.DiscardRequests(reqs)
|
||||||
|
|
||||||
// Store anything that comes in over stdin.
|
// Service the incoming Channel channel.
|
||||||
io.Copy(s.Transfers, channel)
|
for newChannel := range chans {
|
||||||
channel.Close()
|
if newChannel.ChannelType() == "session" {
|
||||||
}
|
s.HadASessionRequested = true
|
||||||
|
}
|
||||||
|
channel, requests, err := newChannel.Accept()
|
||||||
|
s.Connected = true
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
req := <-requests
|
||||||
|
req.Reply(true, nil)
|
||||||
|
|
||||||
|
//Note: string(req.Payload) adds additional characters to start of input, execRequest used to solve this issue
|
||||||
|
var cmd execRequest
|
||||||
|
if err := ssh.Unmarshal(req.Payload, &cmd); err != nil {
|
||||||
|
glog.Errorln("Unmarshall encountered error: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s.Commands[cmd.Command] = 1
|
||||||
|
channel.SendRequest("exit-status", false, []byte{0, 0, 0, 0})
|
||||||
|
|
||||||
|
// Store anything that comes in over stdin.
|
||||||
|
io.Copy(s.Transfers, channel)
|
||||||
|
channel.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
2
test.sh
2
test.sh
|
@ -32,7 +32,7 @@ TESTS=$(go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./...)
|
||||||
go test -v ${TESTS}
|
go test -v ${TESTS}
|
||||||
|
|
||||||
# Ignore these paths in the following tests.
|
# Ignore these paths in the following tests.
|
||||||
ignore="vendor\|\_gopath\|localkubecontents.go"
|
ignore="vendor\|\_gopath\|assets.go"
|
||||||
|
|
||||||
# Check gofmt
|
# Check gofmt
|
||||||
echo "Checking gofmt..."
|
echo "Checking gofmt..."
|
||||||
|
|
Loading…
Reference in New Issue