Watch the namespace where operator deploys to unless told otherwise
This commit is contained in:
		
							parent
							
								
									dc4229e84d
								
							
						
					
					
						commit
						06fd9e33f5
					
				|  | @ -37,7 +37,10 @@ func init() { | |||
| 	if configMapRawName != "" { | ||||
| 
 | ||||
| 		operatorNamespace := string(operatorNamespaceBytes) | ||||
| 		config.Namespace = operatorNamespace | ||||
| 
 | ||||
| 		namespacedConfigMapName := operatorNamespace + "/" + configMapRawName | ||||
| 
 | ||||
| 		log.Printf("Looking for the operator configmap at the same namespace the operator resides. Fully qualified configmap name: %v", namespacedConfigMapName) | ||||
| 
 | ||||
| 		err := config.ConfigMapName.Decode(namespacedConfigMapName) | ||||
|  |  | |||
|  | @ -105,8 +105,13 @@ func (c *Controller) initOperatorConfig() { | |||
| 	} | ||||
| 
 | ||||
| 	if configMapData["watched_namespace"] == "" { | ||||
| 		c.logger.Infoln("No namespace to watch specified. Fall back to watching the 'default' namespace.") | ||||
| 		configMapData["watched_namespace"] = v1.NamespaceDefault | ||||
| 		c.logger.Infof("No namespace to watch specified. By convention, the operator falls back to watching the  namespace it is deployed to: '%v' \n", c.config.Namespace) | ||||
| 		configMapData["watched_namespace"] = c.config.Namespace | ||||
| 	} | ||||
| 
 | ||||
| 	_, err := c.KubeClient.ServiceAccounts(configMapData["watched_namespace"]).Get("operator", metav1.GetOptions{}) | ||||
| 	if err != nil { | ||||
| 		c.logger.Warnf("Cannot find the 'operator' service account in the watched namepsace %q. Pods will not be able to start. Error: %v", c.opConfig.WatchedNamespace, err) | ||||
| 	} | ||||
| 
 | ||||
| 	if c.config.NoDatabaseAccess { | ||||
|  |  | |||
|  | @ -32,6 +32,7 @@ type KubernetesClient struct { | |||
| 	v1core.PersistentVolumeClaimsGetter | ||||
| 	v1core.ConfigMapsGetter | ||||
| 	v1core.NodesGetter | ||||
| 	v1core.ServiceAccountsGetter | ||||
| 	v1beta1.StatefulSetsGetter | ||||
| 	policyv1beta1.PodDisruptionBudgetsGetter | ||||
| 	apiextbeta1.CustomResourceDefinitionsGetter | ||||
|  | @ -72,6 +73,7 @@ func NewFromConfig(cfg *rest.Config) (KubernetesClient, error) { | |||
| 	kubeClient.ServicesGetter = client.CoreV1() | ||||
| 	kubeClient.EndpointsGetter = client.CoreV1() | ||||
| 	kubeClient.SecretsGetter = client.CoreV1() | ||||
| 	kubeClient.ServiceAccountsGetter = client.CoreV1() | ||||
| 	kubeClient.ConfigMapsGetter = client.CoreV1() | ||||
| 	kubeClient.PersistentVolumeClaimsGetter = client.CoreV1() | ||||
| 	kubeClient.PersistentVolumesGetter = client.CoreV1() | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue