返回顶部

k8s--must specify a peer

k8s--must specify a peer

在创建k8s的networkpolicy中报错如下

$ kubectl apply -f policy.yaml
The NetworkPolicy "allow-port-from-namespace" is invalid: spec.ingress[0].from[0]: Required value: must specify a peer

报错原因为:

提示报错为yaml文件的格式问题,查找对应yaml格式及等级

$ cat policy.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-port-from-namespace
  namespace: my-app
spec:
  podSelector:
    matchLabels:
  policyTypes:
   - Ingress
  ingress:
    - from:
      - podSelector:
          matchLabels:   #之前此处少了两个空格导致,注意缩进
      ports:
        - protocol: TCP
          port: 9200

 

posted @ 2022-07-07 17:15  九尾cat  阅读(173)  评论(0编辑  收藏  举报