Error: preparing STATE_PATH(/usr/share/elastic-agent/state) failed: mkdir /usr/share/elastic-agent/state/data: permission denied
I got this error while the deploying of fleet server using this configuration in manifest file:
deployment:
podTemplate:
metadata:
creationTimestamp: null
spec:
automountServiceAccountToken: true
containers:
name: agent
resources: {}
securityContext:
privileged: true
runAsUser: 0
Hi,
Here is a response I got from a colleague:
The securityContext
looks good with runAsUser: 0
and privileged: true
. Maybe he missed the step to correctly configure the ServiceAccount used to deploy the Agent resource: Grant host access permission to Elastic Agent | Elastic Cloud on Kubernetes [2.13] | Elastic.
About the second thing: this involves preparing the directory (in particular executing chcon -Rt svirt_sandbox_file_t "${dir}"
). It seems to me that this is only necessary if you want to deploy the agent as non-root, not the case here.
We tried to do something in the operator, see Automatically adjust Elastic Agent hostPath permissions by naemono · Pull Request #6599 · elastic/cloud-on-k8s · GitHub
The PR showing the daemonSet: https://github.com/elastic/cloud-on-k8s/pull/6700.
There could be something odd with your storage setup. Could you give more details of their cluster (version; storage; etc)?