1
1
# kubernetes-elasticsearch-cluster
2
- Elasticsearch (2.3.4 ) cluster on top of Kubernetes made easy.
2
+ Elasticsearch (2.4.1 ) cluster on top of Kubernetes made easy.
3
3
4
4
Elasticsearch best-practices recommend to separate nodes in three roles:
5
5
* ` Master ` nodes - intended for clustering management only, no data, no HTTP API
@@ -16,7 +16,7 @@ Given this, I'm hereby making possible for you to scale as needed. For instance,
16
16
17
17
## Pre-requisites
18
18
19
- * Kubernetes cluster (tested with v1.3.5 on top of [ Vagrant + CoreOS] ( https://github.com/pires/kubernetes-vagrant-coreos-cluster ) )
19
+ * Kubernetes cluster (tested with v1.4.3 on top of [ Vagrant + CoreOS] ( https://github.com/pires/kubernetes-vagrant-coreos-cluster ) )
20
20
* ` kubectl ` configured to access your cluster master API Server
21
21
22
22
## Build images (optional)
@@ -51,36 +51,36 @@ Now, I leave up to you how to validate the cluster, but a first step is to wait
51
51
52
52
```
53
53
$ kubectl get svc,deployment,pods
54
- NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
55
- elasticsearch 10.100.166.126 <pending> 9200/TCP 36m
56
- elasticsearch-discovery 10.100.103.179 <none> 9300/TCP 36m
57
- kubernetes 10.100.0.1 <none> 443/TCP 42m
58
- NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
59
- es-client 1 1 1 1 1m
60
- es-data 1 1 1 1 51s
61
- es-master 1 1 1 1 8m
62
- NAME READY STATUS RESTARTS AGE
63
- es-client-1532011931-ik7ld 1/1 Running 0 1m
64
- es-data-2129027932-9wyey 1/1 Running 0 51s
65
- es-master-3368190183-4ux7v 1/1 Running 0 8m
66
- ```
67
-
68
- ```
69
- $ kubectl logs -f es-master-3368190183-4ux7v
70
- [2016-08-22 11:50:46,704 ][INFO ][node ] [The Destroyer ] version[2.3.5 ], pid[11], build[90f439f /2016-07-27T10:36:52Z ]
71
- [2016-08-22 11:50:46,705 ][INFO ][node ] [The Destroyer ] initializing ...
72
- [2016-08-22 11:50:47,764 ][INFO ][plugins ] [The Destroyer ] modules [reindex, lang-expression, lang-groovy], plugins [cloud-kubernetes], sites []
73
- [2016-08-22 11:50:47,824 ][INFO ][env ] [The Destroyer ] using [1] data paths, mounts [[/data (/dev/sda9)]], net usable_space [13.5gb ], net total_space [15.5gb], spins? [possibly], types [ext4]
74
- [2016-08-22 11:50:47,825 ][INFO ][env ] [The Destroyer ] heap size [503 .6mb], compressed ordinary object pointers [true]
75
- [2016-08-22 11:50:52,800 ][INFO ][node ] [The Destroyer ] initialized
76
- [2016-08-22 11:50:52,800 ][INFO ][node ] [The Destroyer ] starting ...
77
- [2016-08-22 11:50:53,053 ][INFO ][transport ] [The Destroyer ] publish_address {10.244.72 .2:9300}, bound_addresses {10.244.72 .2:9300}
78
- [2016-08-22 11:50:53,067 ][INFO ][discovery ] [The Destroyer ] myesdb/eO4Xb_xQSBGUvchOvMR_jA
79
- [2016-08-22 11:50:58,757 ][INFO ][cluster.service ] [The Destroyer ] new_master {The Destroyer}{eO4Xb_xQSBGUvchOvMR_jA }{10.244.72 .2}{10.244.72 .2:9300}{data=false, master=true}, reason: zen-disco-join(elected_as_master, [0] joins received)
80
- [2016-08-22 11:50:58,767 ][INFO ][node ] [The Destroyer ] started
81
- [2016-08-22 11:50:58,806 ][INFO ][gateway ] [The Destroyer ] recovered [0] indices into cluster_state
82
- [2016-08-22 11:57:33,414 ][INFO ][cluster.service ] [The Destroyer ] added {{St. John Allerdyce}{6gSJOytcRXG_zYkBksGDEA }{10.244.74 .2}{10.244.74 .2:9300}{data=false, master=false},}, reason: zen-disco-join(join from node[{St. John Allerdyce}{6gSJOytcRXG_zYkBksGDEA }{10.244.74 .2}{10.244.74 .2:9300}{data=false, master=false}])
83
- [2016-08-22 11:58:21,927 ][INFO ][cluster.service ] [The Destroyer ] added {{Amergin}{JdCvogNSR5KDuawdIP5QDQ }{10.244.83 .2}{10.244.83 .2:9300}{master=false},}, reason: zen-disco-join(join from node[{Amergin}{JdCvogNSR5KDuawdIP5QDQ }{10.244.83 .2}{10.244.83 .2:9300}{master=false}])
54
+ NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
55
+ svc/ elasticsearch 10.100.59.70 <pending> 9200/TCP 3m
56
+ svc/ elasticsearch-discovery 10.100.206.207 <none> 9300/TCP 3m
57
+ svc/ kubernetes 10.100.0.1 <none> 443/TCP 17h
58
+ NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
59
+ deploy/ es-client 1 1 1 1 2m
60
+ deploy/ es-data 1 1 1 1 51s
61
+ deploy/ es-master 1 1 1 1 3m
62
+ NAME READY STATUS RESTARTS AGE
63
+ po/ es-client-893446138-z6v0v 1/1 Running 0 2m
64
+ po/ es-data-2462033339-dfede 1/1 Running 0 51s
65
+ po/ es-master-3681665862-0p6wc 1/1 Running 0 3m
66
+ ```
67
+
68
+ ```
69
+ $ kubectl logs -f es-master-3681665862-0p6wc
70
+ [2016-10-19 10:27:31,629 ][INFO ][node ] [Cottonmouth ] version[2.4.1 ], pid[11], build[c67dc32 /2016-09-27T18:57:55Z ]
71
+ [2016-10-19 10:27:31,630 ][INFO ][node ] [Cottonmouth ] initializing ...
72
+ [2016-10-19 10:27:32,844 ][INFO ][plugins ] [Cottonmouth ] modules [reindex, lang-expression, lang-groovy], plugins [cloud-kubernetes], sites []
73
+ [2016-10-19 10:27:32,923 ][INFO ][env ] [Cottonmouth ] using [1] data paths, mounts [[/data (/dev/sda9)]], net usable_space [13.1gb ], net total_space [15.5gb], spins? [possibly], types [ext4]
74
+ [2016-10-19 10:27:32,924 ][INFO ][env ] [Cottonmouth ] heap size [247 .6mb], compressed ordinary object pointers [true]
75
+ [2016-10-19 10:27:38,469 ][INFO ][node ] [Cottonmouth ] initialized
76
+ [2016-10-19 10:27:38,475 ][INFO ][node ] [Cottonmouth ] starting ...
77
+ [2016-10-19 10:27:38,666 ][INFO ][transport ] [Cottonmouth ] publish_address {10.244.36 .2:9300}, bound_addresses {10.244.36 .2:9300}
78
+ [2016-10-19 10:27:38,676 ][INFO ][discovery ] [Cottonmouth ] myesdb/B1gZ7EA0T1C0HBmQHqa-9w
79
+ [2016-10-19 10:27:43,837 ][INFO ][cluster.service ] [Cottonmouth ] new_master {Cottonmouth}{B1gZ7EA0T1C0HBmQHqa-9w }{10.244.36 .2}{10.244.36 .2:9300}{data=false, master=true}, reason: zen-disco-join(elected_as_master, [0] joins received)
80
+ [2016-10-19 10:27:43,854 ][INFO ][node ] [Cottonmouth ] started
81
+ [2016-10-19 10:27:43,912 ][INFO ][gateway ] [Cottonmouth ] recovered [0] indices into cluster_state
82
+ [2016-10-19 10:29:01,809 ][INFO ][cluster.service ] [Cottonmouth ] added {{Steve Rogers}{lgXWvPt-TbKF8ZoWsH0QwQ }{10.244.95 .2}{10.244.95 .2:9300}{data=false, master=false},}, reason: zen-disco-join(join from node[{Steve Rogers}{lgXWvPt-TbKF8ZoWsH0QwQ }{10.244.95 .2}{10.244.95 .2:9300}{data=false, master=false}])
83
+ [2016-10-19 10:30:32,536 ][INFO ][cluster.service ] [Cottonmouth ] added {{Man-Thing}{9ZKhq0u5R4-Ry1mhEwcFJA }{10.244.18 .2}{10.244.18 .2:9300}{master=false},}, reason: zen-disco-join(join from node[{Man-Thing}{9ZKhq0u5R4-Ry1mhEwcFJA }{10.244.18 .2}{10.244.18 .2:9300}{master=false}])
84
84
```
85
85
86
86
As you can assert, the cluster is up and running. Easy, wasn't it?
@@ -99,41 +99,42 @@ Did it work?
99
99
100
100
```
101
101
$ kubectl get deployments,pods
102
- NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
103
- es-client 2 2 2 2 3m
104
- es-data 2 2 2 2 3m
105
- es-master 3 3 3 3 10m
106
- NAME READY STATUS RESTARTS AGE
107
- es-client-1532011931-ik7ld 1/1 Running 2 3m
108
- es-client-1532011931-ps1ly 1/1 Running 0 1m
109
- es-data-2129027932-3asba 1/1 Running 1 1m
110
- es-data-2129027932-9wyey 1/1 Running 0 3m
111
- es-master-3368190183-4ux7v 1/1 Running 0 10m
112
- es-master-3368190183-n7tcq 1/1 Running 0 1m
113
- es-master-3368190183-v8yxv 1/1 Running 0 1m
102
+ NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
103
+ deploy/ es-client 2 2 2 2 5m
104
+ deploy/ es-data 2 2 2 2 4m
105
+ deploy/ es-master 3 3 3 3 6m
106
+ NAME READY STATUS RESTARTS AGE
107
+ po/ es-client-893446138-rdb9y 1/1 Running 0 1m
108
+ po/ es-client-893446138-z6v0v 1/1 Running 0 5m
109
+ po/ es-data-2462033339-dfede 1/1 Running 0 4m
110
+ po/ es-data-2462033339-scgek 1/1 Running 0 30s
111
+ po/ es-master-3681665862-0p6wc 1/1 Running 0 6m
112
+ po/ es-master-3681665862-rljxr 1/1 Running 0 1m
113
+ po/ es-master-3681665862-zkhwi 1/1 Running 0 1m
114
114
```
115
115
116
116
Let's take another look at the logs of one of the Elasticsearch ` master ` nodes:
117
117
118
118
```
119
- $ kubectl logs -f es-master-3368190183-4ux7v
120
- [2016-08-22 11:50:46,704][INFO ][node ] [The Destroyer] version[2.3.5], pid[11], build[90f439f/2016-07-27T10:36:52Z]
121
- [2016-08-22 11:50:46,705][INFO ][node ] [The Destroyer] initializing ...
122
- [2016-08-22 11:50:47,764][INFO ][plugins ] [The Destroyer] modules [reindex, lang-expression, lang-groovy], plugins [cloud-kubernetes], sites []
123
- [2016-08-22 11:50:47,824][INFO ][env ] [The Destroyer] using [1] data paths, mounts [[/data (/dev/sda9)]], net usable_space [13.5gb], net total_space [15.5gb], spins? [possibly], types [ext4]
124
- [2016-08-22 11:50:47,825][INFO ][env ] [The Destroyer] heap size [503.6mb], compressed ordinary object pointers [true]
125
- [2016-08-22 11:50:52,800][INFO ][node ] [The Destroyer] initialized
126
- [2016-08-22 11:50:52,800][INFO ][node ] [The Destroyer] starting ...
127
- [2016-08-22 11:50:53,053][INFO ][transport ] [The Destroyer] publish_address {10.244.72.2:9300}, bound_addresses {10.244.72.2:9300}
128
- [2016-08-22 11:50:53,067][INFO ][discovery ] [The Destroyer] myesdb/eO4Xb_xQSBGUvchOvMR_jA
129
- [2016-08-22 11:50:58,757][INFO ][cluster.service ] [The Destroyer] new_master {The Destroyer}{eO4Xb_xQSBGUvchOvMR_jA}{10.244.72.2}{10.244.72.2:9300}{data=false, master=true}, reason: zen-disco-join(elected_as_master, [0] joins received)
130
- [2016-08-22 11:50:58,767][INFO ][node ] [The Destroyer] started
131
- [2016-08-22 11:50:58,806][INFO ][gateway ] [The Destroyer] recovered [0] indices into cluster_state
132
- [2016-08-22 11:57:33,414][INFO ][cluster.service ] [The Destroyer] added {{St. John Allerdyce}{6gSJOytcRXG_zYkBksGDEA}{10.244.74.2}{10.244.74.2:9300}{data=false, master=false},}, reason: zen-disco-join(join from node[{St. John Allerdyce}{6gSJOytcRXG_zYkBksGDEA}{10.244.74.2}{10.244.74.2:9300}{data=false, master=false}])
133
- [2016-08-22 11:58:21,927][INFO ][cluster.service ] [The Destroyer] added {{Amergin}{JdCvogNSR5KDuawdIP5QDQ}{10.244.83.2}{10.244.83.2:9300}{master=false},}, reason: zen-disco-join(join from node[{Amergin}{JdCvogNSR5KDuawdIP5QDQ}{10.244.83.2}{10.244.83.2:9300}{master=false}])
134
- [2016-08-22 12:04:31,859][INFO ][cluster.service ] [The Destroyer] added {{Beta Ray Bill}{oO8X5HIZQbeIb4guf8Yh_w}{10.244.74.2}{10.244.74.2:9300}{data=false, master=true},}, reason: zen-disco-join(join from node[{Beta Ray Bill}{oO8X5HIZQbeIb4guf8Yh_w}{10.244.74.2}{10.244.74.2:9300}{data=false, master=true}])
135
- [2016-08-22 12:04:32,034][INFO ][cluster.service ] [The Destroyer] added {{Tiger Shark}{T59rILwORPGvjmszgSBaCA}{10.244.83.3}{10.244.83.3:9300}{data=false, master=true},}, reason: zen-disco-join(join from node[{Tiger Shark}{T59rILwORPGvjmszgSBaCA}{10.244.83.3}{10.244.83.3:9300}{data=false, master=true}])
136
- [2016-08-22 12:05:50,791][INFO ][cluster.service ] [The Destroyer] added {{Doug and Jerry}{4j8AK5lvQPeXLGUeP7G17w}{10.244.74.3}{10.244.74.3:9300}{data=false, master=false},}, reason: zen-disco-join(join from node[{Doug and Jerry}{4j8AK5lvQPeXLGUeP7G17w}{10.244.74.3}{10.244.74.3:9300}{data=false, master=false}])
119
+ $ kubectl logs -f es-master-3681665862-0p6wc
120
+ [2016-10-19 10:27:31,629][INFO ][node ] [Cottonmouth] version[2.4.1], pid[11], build[c67dc32/2016-09-27T18:57:55Z]
121
+ [2016-10-19 10:27:31,630][INFO ][node ] [Cottonmouth] initializing ...
122
+ [2016-10-19 10:27:32,844][INFO ][plugins ] [Cottonmouth] modules [reindex, lang-expression, lang-groovy], plugins [cloud-kubernetes], sites []
123
+ [2016-10-19 10:27:32,923][INFO ][env ] [Cottonmouth] using [1] data paths, mounts [[/data (/dev/sda9)]], net usable_space [13.1gb], net total_space [15.5gb], spins? [possibly], types [ext4]
124
+ [2016-10-19 10:27:32,924][INFO ][env ] [Cottonmouth] heap size [247.6mb], compressed ordinary object pointers [true]
125
+ [2016-10-19 10:27:38,469][INFO ][node ] [Cottonmouth] initialized
126
+ [2016-10-19 10:27:38,475][INFO ][node ] [Cottonmouth] starting ...
127
+ [2016-10-19 10:27:38,666][INFO ][transport ] [Cottonmouth] publish_address {10.244.36.2:9300}, bound_addresses {10.244.36.2:9300}
128
+ [2016-10-19 10:27:38,676][INFO ][discovery ] [Cottonmouth] myesdb/B1gZ7EA0T1C0HBmQHqa-9w
129
+ [2016-10-19 10:27:43,837][INFO ][cluster.service ] [Cottonmouth] new_master {Cottonmouth}{B1gZ7EA0T1C0HBmQHqa-9w}{10.244.36.2}{10.244.36.2:9300}{data=false, master=true}, reason: zen-disco-join(elected_as_master, [0] joins received)
130
+ [2016-10-19 10:27:43,854][INFO ][node ] [Cottonmouth] started
131
+ [2016-10-19 10:27:43,912][INFO ][gateway ] [Cottonmouth] recovered [0] indices into cluster_state
132
+ [2016-10-19 10:29:01,809][INFO ][cluster.service ] [Cottonmouth] added {{Steve Rogers}{lgXWvPt-TbKF8ZoWsH0QwQ}{10.244.95.2}{10.244.95.2:9300}{data=false, master=false},}, reason: zen-disco-join(join from node[{Steve Rogers}{lgXWvPt-TbKF8ZoWsH0QwQ}{10.244.95.2}{10.244.95.2:9300}{data=false, master=false}])
133
+ [2016-10-19 10:30:32,536][INFO ][cluster.service ] [Cottonmouth] added {{Man-Thing}{9ZKhq0u5R4-Ry1mhEwcFJA}{10.244.18.2}{10.244.18.2:9300}{master=false},}, reason: zen-disco-join(join from node[{Man-Thing}{9ZKhq0u5R4-Ry1mhEwcFJA}{10.244.18.2}{10.244.18.2:9300}{master=false}])
134
+ [2016-10-19 10:32:29,849][INFO ][cluster.service ] [Cottonmouth] added {{Marduk Kurios}{5_Ds0dGvTqGNLCX6MKjWZQ}{10.244.95.3}{10.244.95.3:9300}{data=false, master=true},}, reason: zen-disco-join(join from node[{Marduk Kurios}{5_Ds0dGvTqGNLCX6MKjWZQ}{10.244.95.3}{10.244.95.3:9300}{data=false, master=true}])
135
+ [2016-10-19 10:32:30,299][INFO ][cluster.service ] [Cottonmouth] added {{Wizard}{5V2ss-97TcmfcFqzMH73jw}{10.244.18.3}{10.244.18.3:9300}{data=false, master=true},}, reason: zen-disco-join(join from node[{Wizard}{5V2ss-97TcmfcFqzMH73jw}{10.244.18.3}{10.244.18.3:9300}{data=false, master=true}])
136
+ [2016-10-19 10:32:50,862][INFO ][cluster.service ] [Cottonmouth] added {{Vavavoom}{LuomxPAjSKuGSEBL1bgKeQ}{10.244.36.3}{10.244.36.3:9300}{data=false, master=false},}, reason: zen-disco-join(join from node[{Vavavoom}{LuomxPAjSKuGSEBL1bgKeQ}{10.244.36.3}{10.244.36.3:9300}{data=false, master=false}])
137
+ [2016-10-19 10:33:26,239][INFO ][cluster.service ] [Cottonmouth] added {{Karl Lykos}{BDJolawXRaCNqlBd3IgKig}{10.244.36.4}{10.244.36.4:9300}{master=false},}, reason: zen-disco-join(join from node[{Karl Lykos}{BDJolawXRaCNqlBd3IgKig}{10.244.36.4}{10.244.36.4:9300}{master=false}])
137
138
138
139
```
139
140
@@ -143,28 +144,29 @@ $ kubectl logs -f es-master-3368190183-4ux7v
143
144
144
145
```
145
146
$ kubectl get svc elasticsearch
146
- NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
147
- elasticsearch 10.100.166.126 <pending> 9200/TCP 11m
147
+ NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
148
+ elasticsearch 10.100.59.70 <pending> 9200/TCP 7m
148
149
```
149
150
150
151
From any host on your cluster (that's running ` kube-proxy ` ), run:
151
152
152
153
```
153
- curl http://10.100.166.126 :9200
154
+ curl http://10.100.59.70 :9200
154
155
```
155
156
156
157
You should see something similar to the following:
157
158
158
159
``` json
159
160
{
160
- "name" : " Doug and Jerry " ,
161
+ "name" : " Steve Rogers " ,
161
162
"cluster_name" : " myesdb" ,
163
+ "cluster_uuid" : " oEklUx7mRMOBvG7MiAMjEA" ,
162
164
"version" : {
163
- "number" : " 2.3.5 " ,
164
- "build_hash" : " e455fd0c13dceca8dbbdbb1665d068ae55dabe3f " ,
165
- "build_timestamp" : " 2016-07-27T11:24:31Z " ,
165
+ "number" : " 2.4.1 " ,
166
+ "build_hash" : " c67dc32e24162035d18d6fe1e952c4cbcbe79d16 " ,
167
+ "build_timestamp" : " 2016-09-27T18:57:55Z " ,
166
168
"build_snapshot" : false ,
167
- "lucene_version" : " 5.5.0 "
169
+ "lucene_version" : " 5.5.2 "
168
170
},
169
171
"tagline" : " You Know, for Search"
170
172
}
@@ -173,7 +175,7 @@ You should see something similar to the following:
173
175
Or if you want to see cluster information:
174
176
175
177
```
176
- curl http://10.100.166.126 :9200/_cluster/health?pretty
178
+ curl http://10.100.59.70 :9200/_cluster/health?pretty
177
179
```
178
180
179
181
You should see something similar to the following:
0 commit comments