securityContextをつける。つけない場合で、そのマウントポイントにユーザー権限で書き込み操作がある場合はPermissionErrorが出力される。
ちなみに、fluentdのDockerfileで実行されるfluentduserのidはこのような感じ。
uid=100(fluent) gid=65533(nogroup) groups=65533(nogroup)
securityContext:
runAsUser: 100
runAsNonRoot: true
fsGroup: 65533
全体
apiVersion: apps/v1
kind: StatefulSet
spec:
selector:
matchLabels:
app: fluentd
serviceName: fluentd
template:
spec:
securityContext:
runAsUser: 100
runAsNonRoot: true
fsGroup: 65533
containers:
- image: fluent/fluentd
args:
imagePullPolicy: Always
volumeMounts:
- name: recive
mountPath: /fluentd/log
name: fluentd-container
replicas: 1
volumeClaimTemplates:
- spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
