diff --git a/Makefile b/Makefile index a3b54375df01..65d41a0adad3 100755 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ endif # Set the version information for the Kubernetes servers MINIKUBE_LDFLAGS := -X k8s.io/minikube/pkg/version.version=$(VERSION) -X k8s.io/minikube/pkg/version.isoVersion=$(ISO_VERSION) -X k8s.io/minikube/pkg/version.isoPath=$(ISO_BUCKET) -X k8s.io/minikube/pkg/version.gitCommitID=$(COMMIT) -PROVISIONER_LDFLAGS := "-X k8s.io/minikube/pkg/storage.version=$(STORAGE_PROVISIONER_TAG) -s -w" +PROVISIONER_LDFLAGS := "-X k8s.io/minikube/pkg/storage.version=$(STORAGE_PROVISIONER_TAG) -s -w -extldflags '-static'" MINIKUBEFILES := ./cmd/minikube/ HYPERKIT_FILES := ./cmd/drivers/hyperkit diff --git a/cmd/storage-provisioner/main.go b/cmd/storage-provisioner/main.go index 6b097496a375..2350ef997bd6 100644 --- a/cmd/storage-provisioner/main.go +++ b/cmd/storage-provisioner/main.go @@ -25,6 +25,8 @@ import ( "k8s.io/minikube/pkg/storage" ) +var pvDir = "/tmp/hostpath-provisioner" + func main() { // Glog requires that /tmp exists. if err := os.MkdirAll("/tmp", 0755); err != nil { @@ -33,7 +35,7 @@ func main() { } flag.Parse() - if err := storage.StartStorageProvisioner(); err != nil { + if err := storage.StartStorageProvisioner(pvDir); err != nil { glog.Exit(err) } diff --git a/deploy/addons/storage-provisioner/storage-provisioner.yaml.tmpl b/deploy/addons/storage-provisioner/storage-provisioner.yaml.tmpl index d87939b529ec..e5f2dc28a4ce 100644 --- a/deploy/addons/storage-provisioner/storage-provisioner.yaml.tmpl +++ b/deploy/addons/storage-provisioner/storage-provisioner.yaml.tmpl @@ -31,7 +31,7 @@ metadata: roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: system:persistent-volume-provisioner + name: cluster-admin subjects: - kind: ServiceAccount name: storage-provisioner diff --git a/deploy/storage-provisioner/Dockerfile b/deploy/storage-provisioner/Dockerfile index cff513291247..268eb186b93d 100644 --- a/deploy/storage-provisioner/Dockerfile +++ b/deploy/storage-provisioner/Dockerfile @@ -14,5 +14,5 @@ FROM scratch ARG arch -COPY out/storage-provisioner-${arch} storage-provisioner +COPY out/storage-provisioner-${arch} /storage-provisioner CMD ["/storage-provisioner"] diff --git a/pkg/storage/storage_provisioner.go b/pkg/storage/storage_provisioner.go index 953b80aba944..3d29cc22b594 100644 --- a/pkg/storage/storage_provisioner.go +++ b/pkg/storage/storage_provisioner.go @@ -45,9 +45,9 @@ type hostPathProvisioner struct { } // NewHostPathProvisioner creates a new Provisioner using host paths -func NewHostPathProvisioner() controller.Provisioner { +func NewHostPathProvisioner(pvDir string) controller.Provisioner { return &hostPathProvisioner{ - pvDir: "/tmp/hostpath-provisioner", + pvDir: pvDir, identity: uuid.NewUUID(), } } @@ -57,7 +57,7 @@ var _ controller.Provisioner = &hostPathProvisioner{} // Provision creates a storage asset and returns a PV object representing it. func (p *hostPathProvisioner) Provision(options controller.ProvisionOptions) (*core.PersistentVolume, error) { glog.Infof("Provisioning volume %v", options) - path := path.Join(p.pvDir, options.PVName) + path := path.Join(p.pvDir, options.PVC.Name) if err := os.MkdirAll(path, 0777); err != nil { return nil, err } @@ -103,8 +103,7 @@ func (p *hostPathProvisioner) Delete(volume *core.PersistentVolume) error { return &controller.IgnoredError{Reason: "identity annotation on PV does not match ours"} } - path := path.Join(p.pvDir, volume.Name) - if err := os.RemoveAll(path); err != nil { + if err := os.RemoveAll(volume.Spec.PersistentVolumeSource.HostPath.Path); err != nil { return errors.Wrap(err, "removing hostpath PV") } @@ -112,7 +111,7 @@ func (p *hostPathProvisioner) Delete(volume *core.PersistentVolume) error { } // StartStorageProvisioner will start storage provisioner server -func StartStorageProvisioner() error { +func StartStorageProvisioner(pvDir string) error { glog.Infof("Initializing the Minikube storage provisioner...") config, err := rest.InClusterConfig() if err != nil { @@ -132,7 +131,7 @@ func StartStorageProvisioner() error { // Create the provisioner: it implements the Provisioner interface expected by // the controller - hostPathProvisioner := NewHostPathProvisioner() + hostPathProvisioner := NewHostPathProvisioner(pvDir) // Start the provision controller which will dynamically provision hostPath // PVs