官方文档 https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-overview.html
安装 eck operator1
2
3
4kubectl create -f https://download.elastic.co/downloads/eck/2.8.0/crds.yaml
kubectl apply -f https://download.elastic.co/downloads/eck/2.8.0/operator.yaml
kubectl -n elastic-system logs -f statefulset.apps/elastic-operator
安装 es 参考 https://www.bladewan.com/2020/09/25/logging_1/
https://blog.csdn.net/cr7258/article/details/126613064
关闭 xpack1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: imwl
namespace: elastic-system
spec:
version: 7.17.9
http:
tls:
selfSignedCertificate:
disabled: true # 关闭tls
nodeSets:
- name: es-nodes
count: 3
podTemplate:
spec:
containers:
- name: elasticsearch
env:
# - name: ES_JAVA_OPTS
# value: -Xms2g -Xmx2g
# - name: READINESS_PROBE_PROTOCOL
# value: http
resources:
requests:
memory: 4Gi
cpu: 0.5
# limits:
# memory: 4Gi
# cpu: 2
image: registry.test.datacanvas.com:55443/test/elasticsearch-with-ik:7.17.9
initContainers:
- name: increase-vm-max-map
image: registry.test.datacanvas.com:55443/test/busybox:latest
command: ["sysctl", "-w", "vm.max_map_count=262144"]
securityContext:
privileged: true
- name: increase-fd-ulimit
image: registry.test.datacanvas.com:55443/test/busybox:latest
command: ["sh", "-c", "ulimit -n 65536"]
config:
xpack.security.enabled: false
volumeClaimTemplates:
- metadata:
name: elasticsearch-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: local-path
不关闭 xpack 设置自定义密码
只需要有这两个文件就行1
2
3
4
5
6
7[root@172-20-19-20 ~]# mkdir filerealm
[root@172-20-19-20 ~]# touch filerealm/users filerealm/users_roles
[root@172-20-19-20 ~]# docker run -v $(pwd)/filerealm:/usr/share/elasticsearch/config registry.test.datacanvas.com:55443/test/elasticsearch-with-ik:7.17.9 bin/elasticsearch-users useradd imwl -p password -r superuser
[root@172-20-19-20 filerealm]# cat filerealm/users
imwl:$2a$10$odysEuoTiHUqgt1Un0fo0Oapu9w4KF/uRrTXY.NvXB/e8lKA6V9Bu
[root@172-20-19-20 filerealm]# cat filerealm/users_roles
superuser:imwl
创建 secret1
kubectl create secret generic imwl-elasticsearch-realm-secret --from-file filerealm -n elastic-system
修改1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: imwl
namespace: elastic-system
spec:
version: 7.17.9
auth:
fileRealm:
- secretName: imwl-elasticsearch-realm-secret
nodeSets:
- name: es-nodes
count: 3
podTemplate:
spec:
containers:
- name: elasticsearch
env:
# - name: ES_JAVA_OPTS
# value: -Xms2g -Xmx2g
# - name: READINESS_PROBE_PROTOCOL
# value: http
resources:
requests:
memory: 4Gi
cpu: 0.5
# limits:
# memory: 4Gi
# cpu: 2
image: registry.test.datacanvas.com:55443/test/elasticsearch-with-ik:7.17.9
initContainers:
- name: increase-vm-max-map
image: registry.test.datacanvas.com:55443/test/busybox:latest
command: ["sysctl", "-w", "vm.max_map_count=262144"]
securityContext:
privileged: true
- name: increase-fd-ulimit
image: registry.test.datacanvas.com:55443/test/busybox:latest
command: ["sh", "-c", "ulimit -n 65536"]
volumeClaimTemplates:
- metadata:
name: elasticsearch-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: local-path
暴露端口
暴露端口1
2
3kubectl patch svc -n elastic-system imwl-es-http -p '{"spec": {"type": "NodePort"}}'
kubectl patch svc -n elastic-system imwl-es-http --type='json' -p='[{"op": "replace", "path": "/spec/ports/0/nodePort", "value": 31920}]'
访问1
2curl --insecure -u "imwl:password" -k https://192.168.2.100:31920/_cat/health?v
curl --insecure -u "imwl:password" -k https://192.168.2.100:31920/_cat/nodes?v
分离节点
可以粗略划分 [“master”, “data”, “ingest”, “ml”] # [] 表示 coordinating
按实际情况,可以分很多节点,也可以合并节点
1 | apiVersion: elasticsearch.k8s.elastic.co/v1 |
开启 kibana
1 | apiVersion: kibana.k8s.elastic.co/v1 |
其他插件类似
fluent-bit 放在同一命名空间
1 | [OUTPUT] |