<p>I would like to deploy my pods in a specific namespace. I think about Pod Affinity but can't find a solution on how to select specific namespace.
Does anybody do it?</p>

debek
<p>As part of Anti-Affinity you can provide <code>namespaceSelector: {}</code> to allow the <code>labelSelector</code> to match labels on pods from all namespaces instead of the pod's own namespace only.</p>
<p>The comment in the source code about the NamespaceSelector:
<a href="https://github.com/kubernetes/kubernetes/blob/287888b191968198679159580b1bb76b529aa8c0/staging/src/k8s.io/api/core/v1/types.go#L2927" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/blob/287888b191968198679159580b1bb76b529aa8c0/staging/src/k8s.io/api/core/v1/types.go#L2927</a></p>
<p>Example</p>
<pre class="lang-yaml prettyprint-override"><code>          affinity:
            podAntiAffinity:
              preferredDuringSchedulingIgnoredDuringExecution:
                - weight: 100
                  podAffinityTerm:
                    labelSelector:
                      matchExpressions:
                        - key: app.kubernetes.io/name
                          operator: In
                          values:
                            - foobar
                    topologyKey: &quot;kubernetes.io/hostname&quot;
                    namespaceSelector: {}
</code></pre>
<p>EDIT:
The namespaceSelctor for pod affinity is in Alpha v1.21</p>
<p>Feature disscusion: <a href="https://github.com/kubernetes/kubernetes/issues/68827" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/68827</a></p>
