I am trying to host a web app in a container with read only file system. Whenever I try to configure the root file system as read only through the SecurityContext
of the container I get the following error:
Ports: 80/TCP, 443/TCP
Host Ports: 0/TCP, 0/TCP
State: Terminated
Reason: Error
Exit Code: 137
Started: Thu, 23 Sep 2021 18:13:08 +0300
Finished: Thu, 23 Sep 2021 18:13:08 +0300
Ready: False
I've tried to achieve the same using an AppArmor profile as follows:
profile parser-profile flags=(attach_disconnected) {
#include <abstractions/base>
...
deny /** wl,
...
Unfortunately the result is the same.
What I assume is happening is that the container is not capable of saving the files for the web app and fails.
In my scenario, I will be running untrusted code and I must make sure that users are not allowed to access the file system.
Any ideas of what I am doing wrong and how can I achieve a read only file system?
I am using AKS and below is my deployment configuration:
apiVersion: v1
kind: Service
metadata:
name: parser-service
spec:
selector:
app: parser
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
- port: 443
targetPort: 443
protocol: TCP
name: https
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: parser-deployment
spec:
replicas: 5
selector:
matchLabels:
app: parser
template:
metadata:
labels:
app: parser
annotations:
container.apparmor.security.beta.kubernetes.io/parser: localhost/parser-profile
spec:
containers:
- name: parser
image: parser.azurecr.io/parser:latest
ports:
- containerPort: 80
- containerPort: 443
resources:
limits:
cpu: "1.20"
securityContext:
readOnlyRootFilesystem: true
Edit: I also tried creating a cluster level PSP which also did not work.
kubectl logs {pod-name}
and paste logs in your question? Also I tried to replicate your issue, but I can't pull image fromazurecr.io
. Could you please give link to this image on Docker hub? – Kyleekylen