@@ -21,6 +21,7 @@ package main
2121import (
2222 "flag"
2323 "os"
24+ "time"
2425
2526 "github.com/spf13/cobra"
2627 "k8s.io/klog/v2"
4041 windowsService bool
4142 logDir string
4243 caBundle string
44+ // Certificate-based authentication options
45+ certDir string
46+ certDuration string
4347)
4448
4549func init () {
@@ -50,6 +54,10 @@ func init() {
5054 "Enables running as a Windows service" )
5155 controllerCmd .PersistentFlags ().StringVar (& caBundle , "ca-bundle" , "" ,
5256 "the full path to CA bundle file containing certificates trusted by the cluster" )
57+ controllerCmd .PersistentFlags ().StringVar (& certDir , "cert-dir" , "C:\\ k\\ wicd-certs" ,
58+ "Directory to store WICD client certificates" )
59+ controllerCmd .PersistentFlags ().StringVar (& certDuration , "cert-duration" , "1h" ,
60+ "Duration for WICD certificates (e.g., 10m, 1h, 24h)" )
5361}
5462
5563func runControllerCmd (cmd * cobra.Command , args []string ) {
@@ -60,6 +68,12 @@ func runControllerCmd(cmd *cobra.Command, args []string) {
6068 fs .Set ("logtostderr" , "false" )
6169 fs .Set ("log_dir" , logDir )
6270 }
71+ duration , err := time .ParseDuration (certDuration )
72+ if err != nil {
73+ klog .Errorf ("invalid cert-duration %s: %v" , certDuration , err )
74+ os .Exit (1 )
75+ }
76+
6377 ctx := ctrl .SetupSignalHandler ()
6478 if windowsService {
6579 if err := initService (ctx ); err != nil {
@@ -68,7 +82,7 @@ func runControllerCmd(cmd *cobra.Command, args []string) {
6882 }
6983 }
7084 klog .Info ("service controller running" )
71- if err := controller .RunController (ctx , namespace , kubeconfig , caBundle ); err != nil {
85+ if err := controller .RunController (ctx , namespace , kubeconfig , caBundle , certDir , duration ); err != nil {
7286 klog .Error (err )
7387 os .Exit (1 )
7488 }
0 commit comments