Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#22 from rombert/master
Browse files Browse the repository at this point in the history
Add a flag to disable leader election
  • Loading branch information
k8s-ci-robot authored Dec 2, 2020
2 parents 13cc737 + 4cef281 commit 920c708
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down
16 changes: 15 additions & 1 deletion cmd/nfs-subdir-external-provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,27 @@ 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,
path: path,
}
// 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)
}

0 comments on commit 920c708

Please sign in to comment.