// Module included in the following assemblies:
//
// assembly-cluster-operator.adoc
// assembly-operators-cluster-operator.adoc

[id='deploying-cluster-operator-kubernetes-to-watch-whole-cluster-{context}']
= Deploying the Cluster Operator to watch all namespaces

You can configure the Cluster Operator to watch {ProductName} resources across all {Namespaces} in your {ProductPlatformName} cluster. When running in this mode, the Cluster Operator automatically manages clusters in any new projects or namespaces that are created.

.Prerequisites

* Your {ProductPlatformName} cluster is running.

.Procedure

. Configure the Cluster Operator to watch all namespaces:
  
.. Edit the `050-Deployment-strimzi-cluster-operator.yaml` file.

.. Set the value of the `STRIMZI_NAMESPACE` environment variable to `*`.
+
[source,yaml]
----
apiVersion: extensions/v1beta1
kind: Deployment
spec:
  template:
    spec:
      # ...
      serviceAccountName: strimzi-cluster-operator
      containers:
      - name: strimzi-cluster-operator
        image: strimzi/cluster-operator:latest
        imagePullPolicy: IfNotPresent
        env:
        - name: STRIMZI_NAMESPACE
          value: "*"
        # ...
----

. Create `ClusterRoleBindings` that grant cluster-wide access to all {Namespaces} to the Cluster Operator.
+
On {OpenShiftName}, use the `oc adm policy` command:
+
[source,shell,subs=+quotes]
oc adm policy add-cluster-role-to-user strimzi-cluster-operator-namespaced --serviceaccount strimzi-cluster-operator -n _my-project_
oc adm policy add-cluster-role-to-user strimzi-entity-operator --serviceaccount strimzi-cluster-operator -n _my-project_
oc adm policy add-cluster-role-to-user strimzi-topic-operator --serviceaccount strimzi-cluster-operator -n _my-project_
+
Replace `_my-project_` with the project in which you want to install the Cluster Operator.
+
// upstream only
ifdef::Kubernetes[]
On {KubernetesName}, use the `kubectl create` command:
+
[source,shell,subs=+quotes]
kubectl create clusterrolebinding strimzi-cluster-operator-namespaced --clusterrole=strimzi-cluster-operator-namespaced --serviceaccount _my-namespace_:strimzi-cluster-operator
kubectl create clusterrolebinding strimzi-cluster-operator-entity-operator-delegation --clusterrole=strimzi-entity-operator --serviceaccount _my-namespace_:strimzi-cluster-operator
kubectl create clusterrolebinding strimzi-cluster-operator-topic-operator-delegation --clusterrole=strimzi-topic-operator --serviceaccount _my-namespace_:strimzi-cluster-operator
+
Replace `_my-namespace_` with the namespace in which you want to install the Cluster Operator.
endif::Kubernetes[]
// end
+
. Deploy the Cluster Operator to your {ProductPlatformName} cluster.
+
On {OpenShiftName}, use the `oc apply` command:
+
[source,shell,subs=+quotes]
oc apply -f install/cluster-operator -n _my-project_
+
// upstream only
ifdef::Kubernetes[]
On {KubernetesName}, use the `kubectl apply` command:
+
[source,shell,subs=+quotes]
kubectl apply -f install/cluster-operator -n _my-namespace_
endif::Kubernetes[]
+
// end