请在使用站内资源的同时不要恶意进行爬取或倒链等行为,感谢支持!
相关文档:
它与 ingress 是相辅相成的,当配置 ingress 后,某一个 namespace 下的所有 pod 或者单一的 pod 只需要访问独立的几个接口时需要进行配置保护。配置如下:
apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: untitled-policy namespace: weather spec: podSelector: {} policyTypes: - Egress egress: - to: - namespaceSelector: {} podSelector: matchLabels: k8s-app: kube-dns ports: - port: 53 protocol: UDP - to: - namespaceSelector: matchLabels: name: default podSelector: matchLabels: app: busybox-lifecycles-nginx-sleep - to: - podSelector: {}
上述配置说明 weather 这个 namespace 下的所有 pod 中只能访问 kube-dns:53、default/busybox-lifecycles-nginx-sleep、当前 namespace 所有 pod,其他流量无法出网。
基于 base 配置在创建基于 pod 自身的策略如下:
apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: egress-to-private-vm-443 spec: podSelector: matchLabels: app: busybox-lifecycles-nginx-sleep egress: - ports: - port: 80 - port: 443 to: - ipBlock: cidr: 39.96.67.238/32
让 pod 可以访问某个外部的 IP:80/443 地址。
文档创建于 , 最后一次更新于 , 文档当前的状态 正式版 , 当前编写页面的版本 V1.3.1 。