-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook-setup-elastic.yml
61 lines (53 loc) · 2.09 KB
/
playbook-setup-elastic.yml
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
50
51
52
53
54
55
56
57
---
# ###########################
# Setup elastic on k3s
# ###########################
- name: Elastic setup
hosts: masters
become: yes
become_user: root
tasks:
- name: Install custom resource definitions
shell: kubectl get crd | grep -q "elasticsearches.elasticsearch.k8s.elastic.co" || kubectl create -f https://download.elastic.co/downloads/eck/2.4.0/crds.yaml
- name: Install ECK
shell: kubectl apply -f https://download.elastic.co/downloads/eck/2.4.0/operator.yaml
- name: Create Elastic deployment descriptor
copy:
dest: "/root/elastic.yml"
content: |
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: quickstart
spec:
version: 8.4.3
nodeSets:
- name: default
count: 3
podTemplate:
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
elasticsearch.k8s.elastic.co/cluster-name: quickstart
topologyKey: kubernetes.io/hostname
- name: Deploy Elastic cluster
shell: kubectl apply -f /root/elastic.yml
register: cmd
- debug: var=cmd.stdout_lines
- name: Check cluster status
shell: |
kubectl get pods -o wide
kubectl get elasticsearch
kubectl get pods --selector='elasticsearch.k8s.elastic.co/cluster-name=quickstart'
register: cmd
- debug: var=cmd.stdout_lines
#kubectl get service quickstart-es-http
#PASSWORD=$(kubectl get secret quickstart-es-elastic-user -o go-template='{{.data.elastic | base64decode}}')
#kubectl port-forward service/quickstart-es-http 9200
#curl -u "elastic:$PASSWORD" -k "https://localhost:9200"
#k3s kubectl get pod -o=custom-columns=NAME:.metadata.name,STATUS:.status.phase,NODE:.spec.nodeName --all-namespaces