我正在尝试添加一个印花布网络策略,以允许我的命名空间与 kube-system 命名空间通信。但是在我的 k8s 集群中,kube-system 没有附加标签,所以我无法在其中选择 pod。以下是我尝试过的,但它不起作用。
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-kube-system
namespace: advanced-policy-demo
spec:
podSelector: {} # select all pods in current namespace.
policyTypes:
- Ingress
- Egress
ingress:
- from:
- namespaceSelector:
matchLabels: {}
podSelector:
matchLabels:
tier: control-plane
egress:
- to:
- namespaceSelector:
matchLabels: {}
podSelector:
matchLabels:
tier: control-plane
$ kubectl describe ns kube-system
Name: kube-system
Labels: <none>
Annotations: <none>
Status: Active
No resource quota.
No resource limits.
我有一种方法可以仅按名称选择名称空间吗?