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

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

.Prerequisites

* Edit the installation files according to the {Namespace} the Cluster Operator is going to be installed in.
+
On Linux, use:
+
[source, subs="+quotes"]
----
sed -i 's/namespace: .\*/namespace: _my-namespace_/' install/cluster-operator/*RoleBinding*.yaml
----
+
On MacOS, use:
+
[source, subs="+quotes"]
----
sed -i '' 's/namespace: .\*/namespace: _my-namespace_/' install/cluster-operator/*RoleBinding*.yaml
----

.Procedure

. Edit the file `install/cluster-operator/050-Deployment-strimzi-cluster-operator.yaml` and in the environment variable `STRIMZI_NAMESPACE` list all the {Namespaces} where Cluster Operator should watch for resources.
For example:
+
[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: myproject,myproject2,myproject3
----

. For all namespaces or projects which should be watched by the Cluster Operator, install the `RoleBindings`.
Replace the `_my-namespace_` or `_my-project_` with the {Namespace} used in the previous step.
+
ifdef::Kubernetes[]
On {KubernetesName} this can be done using `kubectl apply`:
[source,shell,subs=+quotes]
kubectl apply -f install/cluster-operator/020-RoleBinding-strimzi-cluster-operator.yaml -n _my-namespace_
kubectl apply -f install/cluster-operator/031-RoleBinding-strimzi-cluster-operator-entity-operator-delegation.yaml -n _my-namespace_
kubectl apply -f install/cluster-operator/032-RoleBinding-strimzi-cluster-operator-topic-operator-delegation.yaml -n _my-namespace_
+
endif::Kubernetes[]
On {OpenShiftName} this can be done using `oc apply`:
+
[source,shell,subs=+quotes]
oc apply -f install/cluster-operator/020-RoleBinding-strimzi-cluster-operator.yaml -n _my-project_
oc apply -f install/cluster-operator/031-RoleBinding-strimzi-cluster-operator-entity-operator-delegation.yaml -n _my-project_
oc apply -f install/cluster-operator/032-RoleBinding-strimzi-cluster-operator-topic-operator-delegation.yaml -n _my-project_

. Deploy the Cluster Operator
+
ifdef::Kubernetes[]
On {KubernetesName} this can be done using `kubectl apply`:
[source,shell,subs=+quotes]
kubectl apply -f install/cluster-operator -n _my-namespace_
+
endif::Kubernetes[]
On {OpenShiftName} this can be done using `oc apply`:
+
[source,shell,subs=+quotes]
oc apply -f install/cluster-operator -n _my-project_
