network-policy.yaml 945 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. apiVersion: networking.k8s.io/v1
  2. kind: NetworkPolicy
  3. metadata:
  4. name: auto-put-ad-mini-policy
  5. namespace: ad-automation
  6. labels:
  7. app: auto-put-ad-mini
  8. spec:
  9. podSelector:
  10. matchLabels:
  11. app: auto-put-ad-mini
  12. policyTypes:
  13. - Egress
  14. - Ingress
  15. ingress:
  16. # 允许同命名空间内的 Pod 访问(例如监控、日志收集)
  17. - from:
  18. - namespaceSelector:
  19. matchLabels:
  20. name: ad-automation
  21. ports:
  22. - protocol: TCP
  23. port: 8080
  24. egress:
  25. # 允许访问 DNS
  26. - to:
  27. - namespaceSelector: {}
  28. ports:
  29. - protocol: UDP
  30. port: 53
  31. # 允许访问代理服务(如果需要)
  32. - to:
  33. - podSelector:
  34. matchLabels:
  35. app: proxy
  36. ports:
  37. - protocol: TCP
  38. port: 8080
  39. # 允许访问外部 HTTPS(腾讯广告 API、飞书 API等)
  40. - to:
  41. - namespaceSelector: {}
  42. ports:
  43. - protocol: TCP
  44. port: 443
  45. - protocol: TCP
  46. port: 80