# Pod placement

> Pod placement for Apache Kafka brokers, covering the default anti-affinity and placement next to OPA when OPA authorization is used.

You can configure Pod placement for Kafka brokers and controllers as described in [Pod placement](https://docs.stackable.tech/home/stable/concepts/operations/pod_placement/index.md).

By default, the operator configures the following Pod placement constraints:

```yaml
affinity:
  podAntiAffinity:
    preferredDuringSchedulingIgnoredDuringExecution:
    - podAffinityTerm:
        labelSelector:
          matchLabels:
            app.kubernetes.io/component: broker
            app.kubernetes.io/instance: cluster-name
            app.kubernetes.io/name: kafka
        topologyKey: kubernetes.io/hostname
      weight: 70
```

In the example above `cluster-name` is the name of the Kafka custom resource that owns this Pod.

If OPA authorization is configured, the broker and controller Pods additionally prefer to run on the same Kubernetes nodes as the OPA Pods (weight 50). Both roles run the OPA authorizer, so both issue OPA requests.

```yaml
affinity:
  podAffinity:
    preferredDuringSchedulingIgnoredDuringExecution:
    - podAffinityTerm:
        labelSelector:
          matchLabels:
            app.kubernetes.io/component: server
            app.kubernetes.io/instance: opa-cluster-name
            app.kubernetes.io/name: opa
        topologyKey: kubernetes.io/hostname
      weight: 50
```

`opa-cluster-name` is the `configMapName` from `spec.clusterConfig.authorization.opa`, which by convention is the name of the OpaCluster.
