Drop unneeded capabilities, make container read-only (#76)

* Run CoreDNS in Docker only with CAP_NET_BIND_SERVICE, drop all other (root) privileges. Run filesystem of container and config in read-only mode.

* Run CoreDNS in Kubernetes only with CAP_NET_BIND_SERVICE, drop all other (root) privileges. Run filesystem of container and config in read-only mode.
This commit is contained in:
Nico Berlee 2018-05-29 15:02:00 +02:00 committed by Miek Gieben
parent d1771c8cde
commit aba0245609
2 changed files with 15 additions and 1 deletions

View file

@ -9,7 +9,12 @@ services:
- "53:53/tcp"
- "9153:9153/tcp"
volumes:
- coredns:/data
- coredns:/data:ro
cap_drop:
- ALL
cap_add:
- NET_BIND_SERVICE
read_only: true
deploy:
mode: global
placement:

View file

@ -94,6 +94,7 @@ spec:
volumeMounts:
- name: config-volume
mountPath: /etc/coredns
readOnly: true
ports:
- containerPort: 53
name: dns
@ -104,6 +105,14 @@ spec:
- containerPort: 9153
name: metrics
protocol: TCP
securityContext:
allowPrivilegeEscalation: false
capabilities:
add:
- NET_BIND_SERVICE
drop:
- all
readOnlyRootFilesystem: true
livenessProbe:
httpGet:
path: /health