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
|
||||
/_gopath
|
||||
|
||||
/pkg/minikube/cluster/localkubecontents.go
|
||||
/pkg/minikube/cluster/assets.go
|
||||
/minikube
|
||||
|
|
10
Makefile
10
Makefile
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
for {
|
||||
nConn, err := listener.Accept()
|
||||
if err != nil {
|
||||
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
|
||||
go func() {
|
||||
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)
|
||||
_, chans, reqs, err := ssh.NewServerConn(nConn, s.Config)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
s.Commands[cmd.Command] = 1
|
||||
channel.SendRequest("exit-status", false, []byte{0, 0, 0, 0})
|
||||
// The incoming Request channel must be serviced.
|
||||
go ssh.DiscardRequests(reqs)
|
||||
|
||||
// Store anything that comes in over stdin.
|
||||
io.Copy(s.Transfers, channel)
|
||||
channel.Close()
|
||||
}
|
||||
// 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 {
|
||||
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()
|
||||
}
|
||||
}()
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
Loading…
Reference in New Issue