Elasticsearch之kubernetes集群搭建
1、镜像清单docker pull jinyidong/es-ik-pinyin:6.2.3
·
1、需求
- nfs挂载
- es-ik-pinyin
- max virtual memroy areas vm.max_map_count [65530] is too low,increase to at least [262144]
- sysctl:setting key "vm.max_map_count':Read-only file system
2、nfs挂载
nfs:network file system,网络文件系统,基于RPC实现,基于UDP协议;
ps:文件挂载失败,改为目录挂载,并指定subPath
volumes:
- name: es6-elasticsearch
nfs: {server: 10.1.2.*, path: /data/dev/es/6.2.3/elasticsearch-cfg}
***********************************
volumeMounts:
- {
name: es6-elasticsearch,
subPath: elasticsearch.yml,
mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
}
3、initContainer
初始化容器,即主容器启动之前,会先启动一个或多个容器,且由于一个Pod中的存储共享、网络共享,initContainer产生的数据可以被主容器使用。
initContainers:
- name: "sysctl"
image: "busybox"
imagePullPolicy: "Always"
command: ["sysctl", "-w", "vm.max_map_count=262144"]
securityContext:
privileged: true
解决方案2:
切至root用户,执行
sysctl -w vm.max_map_count=262144
或者修改/etc/sysctl.conf
vm.max_map_count=262144
4、k8s.Yaml
# image harbor.suiyi.com.cn/component/elasticsearch-ik-pinyin:6.2.3
kind: Deployment
apiVersion: apps/v1
metadata: {name: es6, namespace: dev}
spec:
replicas: 1
selector:
matchLabels: {app: es6}
template:
metadata:
labels: {app: es6}
spec:
volumes:
- name: es6-elasticsearch
nfs: {server: 10.1.2.*, path: /data/dev/es/6.2.3/elasticsearch-cfg}
- name: es6-nodes
nfs: {server: 10.1.2.*, path: /data/dev/es/6.2.3/nodes/}
- name: es6-logs
nfs: {server: 10.1.2.*, path: /data/dev/es/6.2.3/logs/}
- name: es6-ikcustom
nfs: {server: 10.1.2.*, path: /data/dev/es/6.2.3/analysis-ik-custom/}
- name: es6-ikcfg
nfs: {server: 10.1.2.*, path: /data/dev/es/6.2.3/analysis-ik-cfg}
initContainers:
- name: "sysctl"
image: "busybox"
imagePullPolicy: "Always"
command: ["sysctl", "-w", "vm.max_map_count=262144"]
securityContext:
privileged: true
containers:
- name: es6
image: jinyidong/es-ik-pinyin:6.2.3
ports:
- {containerPort: 9200, protocol: TCP}
- {containerPort: 9300, protocol: TCP}
resources: {}
volumeMounts:
- {
name: es6-elasticsearch,
subPath: elasticsearch.yml,
mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
}
- {name: es6-nodes, mountPath: /usr/share/elasticsearch/data/nodes/}
- {name: es6-logs, mountPath: /usr/share/elasticsearch/data/logs/}
- {name: es6-ikcustom, mountPath: /usr/share/elasticsearch/config/analysis-ik/custom/}
- {
name: es6-ikcfg,
subPath: IKAnalyzer.cfg.xml,
mountPath: /usr/share/elasticsearch/config/analysis-ik/IKAnalyzer.cfg.xml
}
---
kind: Service
apiVersion: v1
metadata:
name: es6
namespace: dev
labels: {app: es6}
spec:
ports:
- {name: tcp9200, protocol: TCP, port: 9200, targetPort: 9200, nodePort: 29200}
- {name: tcp9300, protocol: TCP, port: 9300, targetPort: 9300, nodePort: 29300}
selector: {app: es6}
type: NodePort
更多推荐
已为社区贡献2条内容
所有评论(0)