-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(monitoring): add network policies for ingress
- Loading branch information
Simone Bruzzese
committed
Nov 7, 2024
1 parent
405039d
commit 346206c
Showing
3 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,6 @@ spec: | |
ports: | ||
- protocol: UDP | ||
port: 53 | ||
- protocol: TCP | ||
port: 53 | ||
|
145 changes: 145 additions & 0 deletions
145
templates/distribution/manifests/monitoring/policies/ingress.yaml.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
# Copyright (c) 2017-present SIGHUP s.r.l All rights reserved. | ||
# Use of this source code is governed by a BSD-style | ||
# license that can be found in the LICENSE file. | ||
|
||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: grafana-ingress-nginxingresscontroller | ||
namespace: monitoring | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/component: grafana | ||
app.kubernetes.io/name: grafana | ||
app.kubernetes.io/part-of: kube-prometheus | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
# single nginx, no sso | ||
{{if and (eq .spec.distribution.modules.ingress.nginx.type "single") (ne .spec.distribution.modules.auth.provider.type "sso") }} | ||
- from: | ||
- namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: ingress-nginx | ||
podSelector: | ||
matchLabels: | ||
app: ingress-nginx | ||
# dual nginx, no sso | ||
{{ else if (eq .spec.distribution.modules.ingress.nginx.type "dual") (ne .spec.distribution.modules.auth.provider.type "sso") }} | ||
- from: | ||
- namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: ingress-nginx | ||
podSelector: | ||
matchLabels: | ||
app: ingress | ||
# sso | ||
{{ else if (eq .spec.distribution.modules.auth.provider.type "sso") }} | ||
- from: | ||
- namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: ingress-nginx | ||
podSelector: | ||
matchLabels: | ||
app: pomerium | ||
{{ end }} | ||
ports: | ||
- port: 3000 | ||
protocol: TCP | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: prometheus-ingress-nginxingresscontroller | ||
namespace: monitoring | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/component: alert-router | ||
app.kubernetes.io/instance: main | ||
app.kubernetes.io/name: alertmanager | ||
app.kubernetes.io/part-of: kube-prometheus | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
# single nginx, no sso | ||
{{if and (eq .spec.distribution.modules.ingress.nginx.type "single") (ne .spec.distribution.modules.auth.provider.type "sso") }} | ||
- from: | ||
- namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: ingress-nginx | ||
podSelector: | ||
matchLabels: | ||
app: ingress-nginx | ||
# dual nginx, no sso | ||
{{ else if (eq .spec.distribution.modules.ingress.nginx.type "dual") (ne .spec.distribution.modules.auth.provider.type "sso") }} | ||
- from: | ||
- namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: ingress-nginx | ||
podSelector: | ||
matchLabels: | ||
app: ingress | ||
# sso | ||
{{ else if (eq .spec.distribution.modules.auth.provider.type "sso") }} | ||
- from: | ||
- namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: ingress-nginx | ||
podSelector: | ||
matchLabels: | ||
app: pomerium | ||
{{ end }} | ||
ports: | ||
- port: 9090 | ||
protocol: TCP | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: alertmanager-ingress-nginxingresscontroller | ||
namespace: monitoring | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/component: prometheus | ||
app.kubernetes.io/instance: k8s | ||
app.kubernetes.io/name: prometheus | ||
app.kubernetes.io/part-of: kube-prometheus | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
# single nginx, no sso | ||
{{if and (eq .spec.distribution.modules.ingress.nginx.type "single") (ne .spec.distribution.modules.auth.provider.type "sso") }} | ||
- from: | ||
- namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: ingress-nginx | ||
podSelector: | ||
matchLabels: | ||
app: ingress-nginx | ||
# dual nginx, no sso | ||
{{ else if (eq .spec.distribution.modules.ingress.nginx.type "dual") (ne .spec.distribution.modules.auth.provider.type "sso") }} | ||
- from: | ||
- namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: ingress-nginx | ||
podSelector: | ||
matchLabels: | ||
app: ingress | ||
# sso | ||
{{ else if (eq .spec.distribution.modules.auth.provider.type "sso") }} | ||
- from: | ||
- namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: ingress-nginx | ||
podSelector: | ||
matchLabels: | ||
app: pomerium | ||
{{ end }} | ||
ports: | ||
- port: 9093 | ||
protocol: TCP | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters