Skip to content

Commit

Permalink
feat: support cert-manager for generating tls and ca
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksim Fedotov authored and prometherion committed May 23, 2022
1 parent 3c9228d commit 1af56b7
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ func printVersion() {

// nolint:maintidx
func main() {
var enableLeaderElection, version bool
var enableLeaderElection, enableSecretController, version bool

var metricsAddr, namespace, configurationName string

var goFlagSet goflag.FlagSet

flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
flag.BoolVar(&enableSecretController, "enable-secret-controller", true,
"Enable secret controller which reconciles TLS and CA secrets for capsule webhooks.")
flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
Expand Down Expand Up @@ -131,24 +133,26 @@ func main() {

cfg := configuration.NewCapsuleConfiguration(ctx, manager.GetClient(), configurationName)

if err = (&secretcontroller.CAReconciler{
Client: manager.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("CA"),
Namespace: namespace,
Configuration: cfg,
}).SetupWithManager(manager); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Namespace")
os.Exit(1)
}
if enableSecretController {
if err = (&secretcontroller.CAReconciler{
Client: manager.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("CA"),
Namespace: namespace,
Configuration: cfg,
}).SetupWithManager(manager); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Namespace")
os.Exit(1)
}

if err = (&secretcontroller.TLSReconciler{
Client: manager.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("Tls"),
Namespace: namespace,
Configuration: cfg,
}).SetupWithManager(manager); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Namespace")
os.Exit(1)
if err = (&secretcontroller.TLSReconciler{
Client: manager.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("Tls"),
Namespace: namespace,
Configuration: cfg,
}).SetupWithManager(manager); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Namespace")
os.Exit(1)
}
}

clientset, err := kubernetes.NewForConfig(ctrl.GetConfigOrDie())
Expand Down

0 comments on commit 1af56b7

Please sign in to comment.