diff --git a/README.md b/README.md index f0ef68b2..54aa044a 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,9 @@ spec: path: /var/nfs ``` -You may also want to change the PROVISIONER_NAME above from `fuseim.pri/ifs` to something more descriptive like `nfs-storage`, but if you do remember to also change the PROVISIONER_NAME in the storage class definition below: +You may also want to change the PROVISIONER_NAME above from `fuseim.pri/ifs` to something more descriptive like `nfs-storage`, but if you do remember to also change the PROVISIONER_NAME in the storage class definition below. + +To disable leader election, define an env variable named ENABLE_LEADER_ELECTION and set its value to false. **Step 5: Deploying your storage class** diff --git a/cmd/nfs-subdir-external-provisioner/provisioner.go b/cmd/nfs-subdir-external-provisioner/provisioner.go index 2de8064b..8b2218b4 100644 --- a/cmd/nfs-subdir-external-provisioner/provisioner.go +++ b/cmd/nfs-subdir-external-provisioner/provisioner.go @@ -247,6 +247,15 @@ func main() { glog.Fatalf("Error getting server version: %v", err) } + leaderElection := true + leaderElectionEnv := os.Getenv("ENABLE_LEADER_ELECTION") + if ( leaderElectionEnv != "" ) { + leaderElection, err = strconv.ParseBool(leaderElectionEnv) + if err != nil { + glog.Fatalf("Unable to parse ENABLE_LEADER_ELECTION env var: %v", err) + } + } + clientNFSProvisioner := &nfsProvisioner{ client: clientset, server: server, @@ -254,6 +263,11 @@ func main() { } // Start the provision controller which will dynamically provision efs NFS // PVs - pc := controller.NewProvisionController(clientset, provisionerName, clientNFSProvisioner, serverVersion.GitVersion) + pc := controller.NewProvisionController(clientset, + provisionerName, + clientNFSProvisioner, + serverVersion.GitVersion, + controller.LeaderElection(leaderElection), + ) pc.Run(wait.NeverStop) }