其他分享
首页 > 其他分享> > CKA易错题整理:五、配置⽹络策略 NetworkPolicy

CKA易错题整理:五、配置⽹络策略 NetworkPolicy

作者:互联网

参考文档:https://kubernetes.io/zh-cn/docs/concepts/services-networking/network-policies/#networkpolicy-resource

官方截图: 三个from 代表三个策略的叠加

考题要求:

错误示范:

正确示范

点击查看 yaml 文件
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-port-from-namespace
  namespace: fubar
spec:
  podSelector:
    matchLabels: {}
  policyTypes:
    - Ingress
  ingress:
    - from:
        - namespaceSelector:
            matchLabels:
              kubernetes.io/metadata.name: corp-net
          podSelector:
            matchLabels: {}

      ports:
        - protocol: TCP
          port: 8080

标签:CKA,NetworkPolicy,matchLabels,namespace,错题,io,networking,port,name
来源: https://www.cnblogs.com/vmsky/p/16390117.html