@@ -110,6 +110,7 @@ const (
110110 defaulReportMode = int (controllers .CollectFromManagementCluster )
111111 mebibytes_bytes = 1 << 20
112112 gibibytes_per_bytes = 1 << 30
113+ sveltosNamespace = "NAMESPACE"
113114)
114115
115116// Add RBAC for the authorized diagnostics endpoint.
@@ -124,15 +125,17 @@ func main() {
124125
125126 setupLogging ()
126127
128+ sveltosNamespace := os .Getenv (sveltosNamespace )
129+ if sveltosNamespace == "" {
130+ setupLog .V (logs .LogInfo ).Error (nil , "Missing required environment variables NAMESPACE" )
131+ os .Exit (1 )
132+ }
133+
127134 reportMode = controllers .ReportMode (tmpReportMode )
128135 ctrl .SetLogger (klog .Background ())
129136 ctrlOptions := getCtrlOptions (scheme )
130137
131- restConfig := ctrl .GetConfigOrDie ()
132- restConfig .QPS = restConfigQPS
133- restConfig .Burst = restConfigBurst
134- restConfig .UserAgent = remote .DefaultClusterAPIUserAgent ("addon-controller" )
135- restConfig .WarningHandler = apiwarnings .DefaultHandler (klog .Background ().WithName ("API Server Warning" ))
138+ restConfig := getRestConfig ()
136139
137140 ctx := ctrl .SetupSignalHandler ()
138141
@@ -143,6 +146,7 @@ func main() {
143146 controllers .SetCAPIOnboardAnnotation (capiOnboardAnnotation )
144147 controllers .SetDriftDetectionRegistry (registry )
145148 controllers .SetAgentInMgmtCluster (agentInMgmtCluster )
149+ controllers .SetSveltosNamespace (sveltosNamespace )
146150
147151 if isInitContainer () {
148152 runInitContainerWork (ctx , restConfig , scheme )
@@ -175,7 +179,7 @@ func main() {
175179 controllers .NewLicenseManager ()
176180
177181 if shardKey == "" && ! disableTelemetry {
178- err = telemetry .StartCollecting (ctx , mgr .GetConfig (), mgr .GetClient (), version )
182+ err = telemetry .StartCollecting (ctx , mgr .GetConfig (), mgr .GetClient (), sveltosNamespace , version )
179183 if err != nil {
180184 setupLog .Error (err , "failed starting telemetry client" )
181185 }
@@ -256,10 +260,10 @@ func initFlags(fs *pflag.FlagSet) {
256260 "Bind address to expose the pprof profiler (e.g. localhost:6060)" )
257261
258262 fs .StringVar (& driftDetectionConfigMap , "drift-detection-config" , "" ,
259- "The name of the ConfigMap in the projectsveltos namespace containing the drift-detection-manager configuration" )
263+ "The name of the ConfigMap in the namespace where projectsveltos is deployed containing the drift-detection-manager configuration" )
260264
261265 fs .StringVar (& luaConfigMap , "lua-methods" , "" ,
262- "The name of the ConfigMap in the projectsveltos namespace containing lua utilities to be loaded." +
266+ "The name of the ConfigMap in the namespace where projectsveltos is deployed containing lua utilities to be loaded." +
263267 "Changing the content of the ConfigMap does not cause Sveltos to redeploy." )
264268
265269 fs .StringVar (& registry , "registry" , "" ,
@@ -797,3 +801,12 @@ func setupLogging() {
797801
798802 ctrl .SetLogger (klog .Background ())
799803}
804+
805+ func getRestConfig () * rest.Config {
806+ restConfig := ctrl .GetConfigOrDie ()
807+ restConfig .QPS = restConfigQPS
808+ restConfig .Burst = restConfigBurst
809+ restConfig .UserAgent = remote .DefaultClusterAPIUserAgent ("addon-controller" )
810+ restConfig .WarningHandler = apiwarnings .DefaultHandler (klog .Background ().WithName ("API Server Warning" ))
811+ return restConfig
812+ }
0 commit comments