diff --git a/helm/templates/networkpolicy.yaml b/helm/templates/networkpolicy.yaml new file mode 100644 index 00000000..33a0e06d --- /dev/null +++ b/helm/templates/networkpolicy.yaml @@ -0,0 +1,73 @@ +{{- if .Values.networkPolicy.enabled }} +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ include "open-git.fullname" . }}-backend-egress + labels: + {{- include "open-git.labels" . | nindent 4 }} +spec: + podSelector: + matchLabels: + {{- include "open-git.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: backend + policyTypes: + - Ingress + - Egress + egress: + - to: + - podSelector: + matchLabels: + app.kubernetes.io/name: postgresql + app.kubernetes.io/instance: {{ .Release.Name }} + ports: + - protocol: TCP + port: 5432 + - to: + - podSelector: + matchLabels: + app.kubernetes.io/name: redis + app.kubernetes.io/instance: {{ .Release.Name }} + ports: + - protocol: TCP + port: 6379 + - to: + - podSelector: + matchLabels: + app.kubernetes.io/name: minio + app.kubernetes.io/instance: {{ .Release.Name }} + ports: + - protocol: TCP + port: 9000 + - ports: + - protocol: UDP + port: 53 + - protocol: TCP + port: 53 +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ include "open-git.fullname" . }}-postgresql-ingress + labels: + {{- include "open-git.labels" . | nindent 4 }} +spec: + podSelector: + matchLabels: + app.kubernetes.io/name: postgresql + app.kubernetes.io/instance: {{ .Release.Name }} + policyTypes: + - Ingress + ingress: + - from: + - podSelector: + matchLabels: + {{- include "open-git.selectorLabels" . | nindent 14 }} + app.kubernetes.io/component: backend + - podSelector: + matchLabels: + {{- include "open-git.selectorLabels" . | nindent 14 }} + app.kubernetes.io/component: worker + ports: + - protocol: TCP + port: 5432 +{{- end }} diff --git a/helm/templates/servicemonitor.yaml b/helm/templates/servicemonitor.yaml new file mode 100644 index 00000000..0c7e27fa --- /dev/null +++ b/helm/templates/servicemonitor.yaml @@ -0,0 +1,20 @@ +{{- if .Values.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "open-git.fullname" . }}-backend + labels: + {{- include "open-git.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + app.kubernetes.io/name: {{ include "open-git.name" . }} + app.kubernetes.io/component: backend + endpoints: + - port: http + path: /metrics + interval: 30s + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} +{{- end }}