【发布时间】:2018-03-03 05:26:08
【问题描述】:
希望有人可以帮助我解决似乎是权限错误的问题。我正在尝试使用官方的弹性搜索泊坞窗图像启动一个 3 节点弹性搜索集群。当容器启动时,我从 /usr/share/elasticsearch/data/nodes 上的 elasticsearch 收到“拒绝访问”错误,所以我尝试添加一个命令以使 elasticsearch 成为 /usr/share/elasticsearch/data 的所有者...但是当我包含 chown 命令时出现这些错误:
chown: cannot read directory '/usr/share/elasticsearch/data/lost+found': Permission denied
chown: changing ownership of '/usr/share/elasticsearch/data': Operation not permitted
这是我的 statefulset yaml 文件:
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: esnode
spec:
serviceName: elasticsearch-transport
replicas: 3
template:
metadata:
labels:
app: evo-pro-cluster
spec:
initContainers:
- name: init-sysctl
image: busybox
imagePullPolicy: IfNotPresent
command: ["sysctl", "-w", "vm.max_map_count=262144"]
securityContext:
privileged: true
containers:
- name: elasticsearch
securityContext:
privileged: true
capabilities:
add:
- IPC_LOCK
- SYS_RESOURCE
command: ["/bin/sh"]
args: ["-c", "chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data"]
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.1
imagePullPolicy: Always
env:
- name: "ES_JAVA_OPTS"
value: "-Xms6g -Xmx6g"
ports:
- containerPort: 9200
name: http
protocol: TCP
- containerPort: 9300
name: transport
protocol: TCP
volumeMounts:
- name: storage
mountPath: /usr/share/elasticsearch/data
- name: config
mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
subPath: elasticsearch.yml
volumes:
- name: config
configMap:
name: elasticsearch-config
volumeClaimTemplates:
- metadata:
name: storage
annotations:
storageClassName: standard
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 110Gi
【问题讨论】:
-
我将命令移动到初始化容器,它似乎工作:``` initContainers: - name: init-es-settings image:busybox imagePullPolicy: IfNotPresent securityContext: privileged: true command: ["sysctl ", "-w", "vm.max_map_count=262144"] 命令: ["/bin/sh"] 参数: ["-c", "chown -R 1000:1000 /usr/share/elasticsearch/data"] volumeMounts: - name: storage mountPath: /usr/share/elasticsearch/data
标签: docker elasticsearch kubernetes