fix: container hardening + NetworkPolicy for waitlist-api
- deployment.yaml: securityContext (runAsNonRoot, readOnlyRootFilesystem, drop ALL caps) - network-policy.yaml: egress only to CNPG PG (5432) + api.telegram.org (443) - kustomization.yaml: register new NetworkPolicy resource - waitlist-telegram-secret: add admin_api_key field
This commit is contained in:
parent
36b1d637f1
commit
ac994f144a
4 changed files with 72 additions and 0 deletions
|
|
@ -13,6 +13,12 @@ spec:
|
|||
labels:
|
||||
app: waitlist-api
|
||||
spec:
|
||||
serviceAccountName: waitlist-api
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
fsGroup: 1000
|
||||
containers:
|
||||
- name: api
|
||||
image: ghcr.io/sirius0xdev/waitlist-api:latest
|
||||
|
|
@ -20,6 +26,12 @@ spec:
|
|||
ports:
|
||||
- containerPort: 8080
|
||||
protocol: TCP
|
||||
securityContext:
|
||||
readOnlyRootFilesystem: true
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
env:
|
||||
- name: DB_HOST
|
||||
value: "siriusdevops-pgdb-rw.customer1.svc.cluster.local"
|
||||
|
|
@ -47,6 +59,11 @@ spec:
|
|||
secretKeyRef:
|
||||
name: waitlist-telegram-secret
|
||||
key: chat_id
|
||||
- name: ADMIN_API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: waitlist-telegram-secret
|
||||
key: admin_api_key
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
|
|
@ -55,6 +72,11 @@ spec:
|
|||
cpu: 200m
|
||||
memory: 256Mi
|
||||
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
readOnly: false
|
||||
|
||||
startupProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
|
|
@ -88,6 +110,10 @@ spec:
|
|||
failureThreshold: 3
|
||||
successThreshold: 1
|
||||
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
|
|
|
|||
|
|
@ -4,3 +4,4 @@ resources:
|
|||
- deployment.yaml
|
||||
- waitlist-telegram-secret.yaml
|
||||
- http-route.yaml
|
||||
- network-policy.yaml
|
||||
|
|
|
|||
44
apps/base/customer1/waitlist-api/network-policy.yaml
Normal file
44
apps/base/customer1/waitlist-api/network-policy.yaml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: waitlist-api-egress
|
||||
namespace: customer1
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: waitlist-api
|
||||
policyTypes:
|
||||
- Egress
|
||||
egress:
|
||||
# Allow DNS resolution (required for api.telegram.org lookups)
|
||||
- to:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: kube-system
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
k8s-app: kube-dns
|
||||
ports:
|
||||
- protocol: UDP
|
||||
port: 53
|
||||
- protocol: TCP
|
||||
port: 53
|
||||
# Allow PostgreSQL to CNPG cluster
|
||||
- to:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
cnpg.io/cluster: siriusdevops-pgdb
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 5432
|
||||
# Allow Telegram Bot API
|
||||
- to:
|
||||
- ipBlock:
|
||||
cidr: 0.0.0.0/0
|
||||
except:
|
||||
- 10.0.0.0/8
|
||||
- 172.16.0.0/12
|
||||
- 192.168.0.0/16
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 443
|
||||
|
|
@ -7,6 +7,7 @@ type: Opaque
|
|||
stringData:
|
||||
bot_token: CHANGEME
|
||||
chat_id: CHANGEME
|
||||
admin_api_key: CHANGEME
|
||||
sops:
|
||||
age:
|
||||
- recipient: age1uuxf066xuuqgvjppxfcmqkwfcufnwp3wcwnl9h20g9k4l8nkw9jsaungf7
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue