Watch the namespace where operator deploys to unless told otherwise

This commit is contained in:
Sergey Dudoladov
2018-02-13 18:17:47 +01:00
parent dc4229e84d
commit 06fd9e33f5
3 changed files with 12 additions and 2 deletions
+7 -2
View File
@@ -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 {
+2
View File
@@ -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()