This commit is contained in:
Wolfgang Hottgenroth 2023-10-15 16:57:28 +02:00
commit b77d8da90e
Signed by: wn
GPG Key ID: 836E9E1192A6B132
2 changed files with 145 additions and 0 deletions

4
namespace.yml Normal file
View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: mainscnt

141
sinkserver/deploy.yml Normal file
View File

@ -0,0 +1,141 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
namespace: mainscnt
name: deny-all-but-dns
spec:
podSelector:
matchLabels: {}
policyTypes:
- Egress
- Ingress
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sinkserver
namespace: mainscnt
labels:
app: sinkserver
spec:
replicas: 3
selector:
matchLabels:
app: sinkserver
template:
metadata:
labels:
app: sinkserver
spec:
containers:
- name: sinkserver
image: wollud1969/sinkserver:e5f9d3e3
ports:
- containerPort: 20169
protocol: UDP
env:
- name: PGHOST
valueFrom:
configMapKeyRef:
name: sinkserver-config
key: dbhost
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: sinkserver-secret
key: dbpass
---
apiVersion: v1
kind: Service
metadata:
name: sinkserver
namespace: mainscnt
labels:
app: sinkserver
spec:
type: LoadBalancer
selector:
app: sinkserver
ports:
- protocol: UDP
port: 20169
targetPort: 20169
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-database-sinkserver
namespace: database
spec:
podSelector:
matchLabels:
app: timescaledb
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
app: sinkserver
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: mainscnt
ports:
- protocol: TCP
port: 5432
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-sinkserver-database
namespace: mainscnt
spec:
podSelector:
matchLabels:
app: sinkserver
policyTypes:
- Egress
egress:
- to:
- podSelector:
matchLabels:
app: timescaledb
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: database
ports:
- protocol: TCP
port: 5432
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-sinkserver-ingress
namespace: mainscnt
spec:
podSelector:
matchLabels:
app: sinkserver
policyTypes:
- Ingress
ingress:
- from:
- ipBlock:
cidr: 0.0.0.0/0
ports:
- protocol: UDP
port: 20169