networkpolicy.yaml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. {{- if .Values.networkPolicy.enabled }}
  2. apiVersion: networking.k8s.io/v1
  3. kind: NetworkPolicy
  4. metadata:
  5. name: {{ include "shop-recycle.fullname" . }}-gateway
  6. labels:
  7. app: {{ include "shop-recycle.fullname" . }}-gateway
  8. {{- include "shop-recycle.labels" . | nindent 4 }}
  9. namespace: {{ .Release.Namespace }}
  10. spec:
  11. podSelector:
  12. matchLabels:
  13. app: {{ include "shop-recycle.fullname" . }}-gateway
  14. policyTypes:
  15. {{- toYaml .Values.networkPolicy.policyTypes | nindent 4 }}
  16. ingress:
  17. - from:
  18. - namespaceSelector:
  19. matchLabels:
  20. name: {{ .Release.Namespace }}
  21. - podSelector:
  22. matchLabels:
  23. app: {{ include "shop-recycle.fullname" . }}-gateway
  24. ports:
  25. - protocol: TCP
  26. port: 8080
  27. egress:
  28. - to:
  29. - podSelector:
  30. matchLabels:
  31. app: {{ include "shop-recycle.fullname" . }}-order-service
  32. ports:
  33. - protocol: TCP
  34. port: 8081
  35. - to:
  36. - podSelector:
  37. matchLabels:
  38. app: {{ include "shop-recycle.fullname" . }}-payment-service
  39. ports:
  40. - protocol: TCP
  41. port: 8082
  42. - to:
  43. - namespaceSelector: {}
  44. ports:
  45. - protocol: TCP
  46. port: 53
  47. - protocol: UDP
  48. port: 53
  49. ---
  50. apiVersion: networking.k8s.io/v1
  51. kind: NetworkPolicy
  52. metadata:
  53. name: {{ include "shop-recycle.fullname" . }}-order-service
  54. labels:
  55. app: {{ include "shop-recycle.fullname" . }}-order-service
  56. {{- include "shop-recycle.labels" . | nindent 4 }}
  57. namespace: {{ .Release.Namespace }}
  58. spec:
  59. podSelector:
  60. matchLabels:
  61. app: {{ include "shop-recycle.fullname" . }}-order-service
  62. policyTypes:
  63. {{- toYaml .Values.networkPolicy.policyTypes | nindent 4 }}
  64. ingress:
  65. - from:
  66. - podSelector:
  67. matchLabels:
  68. app: {{ include "shop-recycle.fullname" . }}-gateway
  69. ports:
  70. - protocol: TCP
  71. port: 8081
  72. egress:
  73. - to:
  74. - namespaceSelector: {}
  75. ports:
  76. - protocol: TCP
  77. port: 53
  78. - protocol: UDP
  79. port: 53
  80. ---
  81. apiVersion: networking.k8s.io/v1
  82. kind: NetworkPolicy
  83. metadata:
  84. name: {{ include "shop-recycle.fullname" . }}-payment-service
  85. labels:
  86. app: {{ include "shop-recycle.fullname" . }}-payment-service
  87. {{- include "shop-recycle.labels" . | nindent 4 }}
  88. namespace: {{ .Release.Namespace }}
  89. spec:
  90. podSelector:
  91. matchLabels:
  92. app: {{ include "shop-recycle.fullname" . }}-payment-service
  93. policyTypes:
  94. {{- toYaml .Values.networkPolicy.policyTypes | nindent 4 }}
  95. ingress:
  96. - from:
  97. - podSelector:
  98. matchLabels:
  99. app: {{ include "shop-recycle.fullname" . }}-gateway
  100. ports:
  101. - protocol: TCP
  102. port: 8082
  103. egress:
  104. - to:
  105. - namespaceSelector: {}
  106. ports:
  107. - protocol: TCP
  108. port: 53
  109. - protocol: UDP
  110. port: 53
  111. {{- end }}