-
-
Save Savemech/7e725a9f00013fa0d3366741fbcd12f8 to your computer and use it in GitHub Desktop.
kubernetes-namespace-rolebinding-operator-main
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
// Set logging output to standard console out | |
log.SetOutput(os.Stdout) | |
sigs := make(chan os.Signal, 1) // Create channel to receive OS signals | |
stop := make(chan struct{}) // Create channel to receive stop signal | |
signal.Notify(sigs, os.Interrupt, syscall.SIGTERM, syscall.SIGINT) // Register the sigs channel to receieve SIGTERM | |
wg := &sync.WaitGroup{} // Goroutines can add themselves to this to be waited on so that they finish | |
runOutsideCluster := flag.Bool("run-outside-cluster", false, "Set this flag when running outside of the cluster.") | |
flag.Parse() | |
// Create clientset for interacting with the kubernetes cluster | |
clientset, err := newClientSet(*runOutsideCluster) | |
if err != nil { | |
panic(err.Error()) | |
} | |
controller.NewNamespaceController(clientset).Run(stop, wg) | |
<-sigs // Wait for signals (this hangs until a signal arrives) | |
log.Printf("Shutting down...") | |
close(stop) // Tell goroutines to stop themselves | |
wg.Wait() // Wait for all to be stopped | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment