我正在尝试添加 calico 网络策略以允许我的命名空间与 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
Run Code Online (Sandbox Code Playgroud)
$ kubectl describe ns kube-system
Name: kube-system
Labels: <none>
Annotations: <none>
Status: Active
No resource quota.
No resource limits.
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以仅通过名称来选择名称空间?