Added storage prov deps to Makefile and rewrote main file

pull/2137/head
Priya Wadhwa 2017-11-01 10:47:08 -07:00
parent 7098431c6a
commit c342ed4d57
5 changed files with 42 additions and 52 deletions

View File

@ -54,7 +54,7 @@ LOCALKUBE_LDFLAGS := "$(K8S_VERSION_LDFLAGS) $(MINIKUBE_LDFLAGS) -s -w -extldfla
LOCALKUBEFILES := GOPATH=$(GOPATH) go list -f '{{join .Deps "\n"}}' ./cmd/localkube/ | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'
MINIKUBEFILES := GOPATH=$(GOPATH) go list -f '{{join .Deps "\n"}}' ./cmd/minikube/ | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'
HYPERKIT_FILES := GOPATH=$(GOPATH) go list -f '{{join .Deps "\n"}}' k8s.io/minikube/cmd/drivers/hyperkit | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'
STORAGE_PROVISIONER_FILES := GOPATH=$(GOPATH) go list -f '{{join .Deps "\n"}}' k8s.io/minikube/cmd/storage-provisioner | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'
MINIKUBE_TEST_FILES := go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./... | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'
KVM_DRIVER_FILES := $(shell go list -f '{{join .Deps "\n"}}' ./cmd/drivers/kvm/ | grep k8s.io | xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}')
@ -300,11 +300,11 @@ $(ISO_BUILD_IMAGE): deploy/iso/minikube-iso/Dockerfile
@echo ""
@echo "$(@) successfully built"
storage-provisioner-main: cmd/storage-provisioner/main.go
go build cmd/storage-provisioner/main.go
out/storage-provisioner: $(shell $(STORAGE_PROVISIONER_FILES))
go build -o $(BUILD_DIR)/storage-provisioner cmd/storage-provisioner/main.go
.PHONY: storage-provisioner-image
storage-provisioner-image: storage-provisioner-main
storage-provisioner-image: out/storage-provisioner
docker build -t $(REGISTRY)/storage-provisioner:$(TAG) -f deploy/storage-provisioner/Dockerfile .
gcloud docker -- push $(REGISTRY)/storage-provisioner:$(TAG)

View File

@ -17,19 +17,16 @@ limitations under the License.
package main
import (
"k8s.io/minikube/cmd/localkube/cmd"
"sync"
"flag"
"github.com/golang/glog"
"k8s.io/minikube/pkg/localkube"
)
func main() {
localkubeServer := cmd.NewLocalkubeServer()
storageProvisionerServer := localkubeServer.NewStorageProvisionerServer()
flag.Parse()
if err := localkube.StartStorageProvisioner(); err != nil {
glog.Exit(err)
}
var wg sync.WaitGroup
wg.Add(2)
go func() {
defer wg.Done()
storageProvisionerServer.Start()
}()
wg.Wait()
}

View File

@ -20,7 +20,6 @@ metadata:
labels:
integration-test: storage-provisioner
addonmanager.kubernetes.io/mode: EnsureExists
kubernetes.io/minikube-addons: storage-provisioner
spec:
hostNetwork: true
containers:

View File

@ -13,6 +13,5 @@
# limitations under the License.
FROM scratch
COPY main main
CMD ["/main"]
COPY out/storage-provisioner storage-provisioner
CMD ["/storage-provisioner"]

View File

@ -109,38 +109,33 @@ func (p *hostPathProvisioner) Delete(volume *v1.PersistentVolume) error {
return nil
}
func (lk LocalkubeServer) NewStorageProvisionerServer() Server {
return NewSimpleServer("storage-provisioner", serverInterval, StartStorageProvisioner(lk), noop)
}
func StartStorageProvisioner(lk LocalkubeServer) func() error {
return func() error {
config, err := restclient.InClusterConfig()
if err != nil {
return err
}
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
glog.Fatalf("Failed to create client: %v", err)
}
// The controller needs to know what the server version is because out-of-tree
// provisioners aren't officially supported until 1.5
serverVersion, err := clientset.Discovery().ServerVersion()
if err != nil {
return fmt.Errorf("Error getting server version: %v", err)
}
// Create the provisioner: it implements the Provisioner interface expected by
// the controller
hostPathProvisioner := NewHostPathProvisioner()
// Start the provision controller which will dynamically provision hostPath
// PVs
pc := controller.NewProvisionController(clientset, provisionerName, hostPathProvisioner, serverVersion.GitVersion)
fmt.Println("wait never stop")
pc.Run(wait.NeverStop)
return nil
// Start storage provisioner server
func StartStorageProvisioner() error {
config, err := restclient.InClusterConfig()
if err != nil {
return err
}
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
glog.Fatalf("Failed to create client: %v", err)
}
// The controller needs to know what the server version is because out-of-tree
// provisioners aren't officially supported until 1.5
serverVersion, err := clientset.Discovery().ServerVersion()
if err != nil {
return fmt.Errorf("Error getting server version: %v", err)
}
// Create the provisioner: it implements the Provisioner interface expected by
// the controller
hostPathProvisioner := NewHostPathProvisioner()
// Start the provision controller which will dynamically provision hostPath
// PVs
pc := controller.NewProvisionController(clientset, provisionerName, hostPathProvisioner, serverVersion.GitVersion)
glog.Info("Starting storage provisioner server")
pc.Run(wait.NeverStop)
return nil
}