Skip to content

Commit ec3f876

Browse files
Meet k6 registry requirements (#9)
With this commit we: * Simplify the docker-compose file and improve docs * Move the example script to the required directory * Upgrade to the most recent version of k6 Relates #8
1 parent 696ac9f commit ec3f876

File tree

7 files changed

+41
-987
lines changed

7 files changed

+41
-987
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ELASTIC_PASSWORD=changeme
55
KIBANA_PASSWORD=changeme
66

77
# Version of Elastic products
8-
STACK_VERSION=8.7.0
8+
STACK_VERSION=8.8.0
99

1010
# Set the cluster name
1111
CLUSTER_NAME=docker-cluster
@@ -23,4 +23,4 @@ KIBANA_PORT=5601
2323
#KIBANA_PORT=80
2424

2525
# Increase or decrease based on the available host memory (in bytes)
26-
MEM_LIMIT=1073741824
26+
MEM_LIMIT=2147483648

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Alternatively, you can send metrics to a local (unsecured) cluster:
4646
```shell
4747
export K6_ELASTICSEARCH_URL=http://localhost:9200
4848

49-
./k6 run ./samples/script.js -o output-elasticsearch
49+
./k6 run ./examples/script.js -o output-elasticsearch
5050
```
5151

5252
If running locally with TLS (with a self-signed certificate), set `K6_ELASTICSEARCH_INSECURE_SKIP_VERIFY` to `true` (defaults to `false`):
@@ -55,7 +55,7 @@ If running locally with TLS (with a self-signed certificate), set `K6_ELASTICSEA
5555
export K6_ELASTICSEARCH_URL=https://localhost:9200
5656
export K6_ELASTICSEARCH_INSECURE_SKIP_VERIFY=true
5757

58-
./k6 run ./samples/script.js -o output-elasticsearch
58+
./k6 run ./examples/script.js -o output-elasticsearch
5959
```
6060

6161
The metrics are stored in the index `k6-metrics` which will be automatically created by this extension. See the [mapping](pkg/esoutput/mapping.json) for details.
@@ -68,7 +68,7 @@ Note that some variables (Stack version, elastic and Kibana users' passwords) ar
6868

6969
Clone the repo to get started and follow these steps:
7070

71-
1. Put your `k6` scripts in the `samples` directory or use the [`script.js`](./samples/script.js) example.
71+
1. Put your `k6` scripts in the `examples` directory or use the [`script.js`](examples/script.js) example.
7272

7373
3. Start the `docker-compose` environment.
7474

@@ -79,16 +79,16 @@ Clone the repo to get started and follow these steps:
7979
4. Use the k6 Docker image to run the k6 script and send metrics to the Elasticsearch cluster started in the previous step.
8080

8181
```shell
82-
docker-compose run --rm -T k6 run -<samples/script.js --tag testid=<SOME-ID>
82+
docker-compose run --rm -T k6 run -<examples/script.js --tag testid=<SOME-ID>
8383
```
8484

8585
> Note that the [docker-compose command to run k6 tests](https://k6.io/docs/getting-started/running-k6/) might differ depending your OS.
8686

87-
5. Visit http://localhost:5601/ to view results in Kibana.
87+
5. Visit http://localhost:5601/ to view results in Kibana (default credentials are `elastic` / `changeme`).
8888

8989
- Create a [Data View](https://www.elastic.co/guide/en/kibana/current/data-views.html) for the index `k6-metrics`.
9090
![Kibana Data View](./images/kibana-data-view.png)
9191
- Go to [Discover](https://www.elastic.co/guide/en/kibana/current/discover.html) to start exploring the metrics.
9292
![Kibana Discover](./images/kibana-discover.png)
9393

94-
When done, to clean up run `docker-compose down -v`.
94+
When done, to clean up run `docker-compose down -v`.

docker-compose.yml

Lines changed: 7 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "3.7"
1+
version: "2.2"
22

33
services:
44
setup:
@@ -30,18 +30,6 @@ services:
3030
" - localhost\n"\
3131
" ip:\n"\
3232
" - 127.0.0.1\n"\
33-
" - name: es02\n"\
34-
" dns:\n"\
35-
" - es02\n"\
36-
" - localhost\n"\
37-
" ip:\n"\
38-
" - 127.0.0.1\n"\
39-
" - name: es03\n"\
40-
" dns:\n"\
41-
" - es03\n"\
42-
" - localhost\n"\
43-
" ip:\n"\
44-
" - 127.0.0.1\n"\
4533
> config/certs/instances.yml;
4634
bin/elasticsearch-certutil cert --silent --pem -out config/certs/certs.zip --in config/certs/instances.yml --ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key;
4735
unzip config/certs/certs.zip -d config/certs;
@@ -57,7 +45,7 @@ services:
5745
echo "All done!";
5846
'
5947
healthcheck:
60-
test: [ "CMD-SHELL", "[ -f config/certs/es01/es01.crt ]" ]
48+
test: ["CMD-SHELL", "[ -f config/certs/es01/es01.crt ]"]
6149
interval: 1s
6250
timeout: 5s
6351
retries: 120
@@ -75,10 +63,10 @@ services:
7563
environment:
7664
- node.name=es01
7765
- cluster.name=${CLUSTER_NAME}
78-
- cluster.initial_master_nodes=es01,es02,es03
79-
- discovery.seed_hosts=es02,es03
66+
- discovery.type=single-node
8067
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
8168
- bootstrap.memory_lock=true
69+
- xpack.ml.enabled=false
8270
- xpack.security.enabled=true
8371
- xpack.security.http.ssl.enabled=true
8472
- xpack.security.http.ssl.key=certs/es01/es01.key
@@ -105,92 +93,11 @@ services:
10593
timeout: 10s
10694
retries: 120
10795

108-
es02:
109-
depends_on:
110-
- es01
111-
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
112-
volumes:
113-
- certs:/usr/share/elasticsearch/config/certs
114-
- esdata02:/usr/share/elasticsearch/data
115-
environment:
116-
- node.name=es02
117-
- cluster.name=${CLUSTER_NAME}
118-
- cluster.initial_master_nodes=es01,es02,es03
119-
- discovery.seed_hosts=es01,es03
120-
- bootstrap.memory_lock=true
121-
- xpack.security.enabled=true
122-
- xpack.security.http.ssl.enabled=true
123-
- xpack.security.http.ssl.key=certs/es02/es02.key
124-
- xpack.security.http.ssl.certificate=certs/es02/es02.crt
125-
- xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
126-
- xpack.security.transport.ssl.enabled=true
127-
- xpack.security.transport.ssl.key=certs/es02/es02.key
128-
- xpack.security.transport.ssl.certificate=certs/es02/es02.crt
129-
- xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
130-
- xpack.security.transport.ssl.verification_mode=certificate
131-
- xpack.license.self_generated.type=${LICENSE}
132-
mem_limit: ${MEM_LIMIT}
133-
ulimits:
134-
memlock:
135-
soft: -1
136-
hard: -1
137-
healthcheck:
138-
test:
139-
[
140-
"CMD-SHELL",
141-
"curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 | grep -q 'missing authentication credentials'"
142-
]
143-
interval: 10s
144-
timeout: 10s
145-
retries: 120
146-
147-
es03:
148-
depends_on:
149-
- es02
150-
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
151-
volumes:
152-
- certs:/usr/share/elasticsearch/config/certs
153-
- esdata03:/usr/share/elasticsearch/data
154-
environment:
155-
- node.name=es03
156-
- cluster.name=${CLUSTER_NAME}
157-
- cluster.initial_master_nodes=es01,es02,es03
158-
- discovery.seed_hosts=es01,es02
159-
- bootstrap.memory_lock=true
160-
- xpack.security.enabled=true
161-
- xpack.security.http.ssl.enabled=true
162-
- xpack.security.http.ssl.key=certs/es03/es03.key
163-
- xpack.security.http.ssl.certificate=certs/es03/es03.crt
164-
- xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
165-
- xpack.security.transport.ssl.enabled=true
166-
- xpack.security.transport.ssl.key=certs/es03/es03.key
167-
- xpack.security.transport.ssl.certificate=certs/es03/es03.crt
168-
- xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
169-
- xpack.security.transport.ssl.verification_mode=certificate
170-
- xpack.license.self_generated.type=${LICENSE}
171-
mem_limit: ${MEM_LIMIT}
172-
ulimits:
173-
memlock:
174-
soft: -1
175-
hard: -1
176-
healthcheck:
177-
test:
178-
[
179-
"CMD-SHELL",
180-
"curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 | grep -q 'missing authentication credentials'"
181-
]
182-
interval: 10s
183-
timeout: 10s
184-
retries: 120
18596

18697
kibana:
18798
depends_on:
18899
es01:
189100
condition: service_healthy
190-
es02:
191-
condition: service_healthy
192-
es03:
193-
condition: service_healthy
194101
image: docker.elastic.co/kibana/kibana:${STACK_VERSION}
195102
volumes:
196103
- certs:/usr/share/kibana/config/certs
@@ -208,7 +115,7 @@ services:
208115
test:
209116
[
210117
"CMD-SHELL",
211-
"curl -s -I http://localhost:5601 | grep -q 'HTTP/1.1 302 Found'"
118+
"curl -s -I http://localhost:5601 | grep -q 'HTTP/1.1 302 Found'",
212119
]
213120
interval: 10s
214121
timeout: 10s
@@ -225,16 +132,12 @@ services:
225132
- K6_ELASTICSEARCH_PASSWORD=${ELASTIC_PASSWORD}
226133
- K6_ELASTICSEARCH_INSECURE_SKIP_VERIFY=true
227134
volumes:
228-
- ./samples:/scripts
135+
- ./examples:/scripts
229136

230137
volumes:
231138
certs:
232139
driver: local
233140
esdata01:
234141
driver: local
235-
esdata02:
236-
driver: local
237-
esdata03:
238-
driver: local
239142
kibanadata:
240-
driver: local
143+
driver: local
File renamed without changes.

go.mod

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,28 @@ go 1.17
55
require (
66
github.com/elastic/go-elasticsearch/v8 v8.1.0
77
github.com/sirupsen/logrus v1.9.0
8-
go.k6.io/k6 v0.43.1
8+
go.k6.io/k6 v0.45.0
99
gopkg.in/guregu/null.v3 v3.5.0
1010
)
1111

1212
require (
1313
github.com/kubernetes/helm v2.17.0+incompatible
14-
github.com/mattn/go-isatty v0.0.17 // indirect
14+
github.com/mattn/go-isatty v0.0.18 // indirect
1515
github.com/spf13/afero v1.9.3 // indirect
1616
golang.org/x/time v0.3.0 // indirect
1717
)
1818

1919
require (
2020
github.com/elastic/elastic-transport-go/v8 v8.1.0 // indirect
21-
github.com/fatih/color v1.13.0 // indirect
21+
github.com/fatih/color v1.15.0 // indirect
2222
github.com/ghodss/yaml v1.0.0 // indirect
2323
github.com/josharian/intern v1.0.0 // indirect
24-
github.com/klauspost/compress v1.15.14 // indirect
2524
github.com/kr/pretty v0.3.0 // indirect
2625
github.com/mailru/easyjson v0.7.7 // indirect
2726
github.com/mattn/go-colorable v0.1.13 // indirect
2827
github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd // indirect
29-
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
30-
github.com/stretchr/testify v1.8.1 // indirect
31-
golang.org/x/crypto v0.5.0 // indirect
32-
golang.org/x/net v0.5.0 // indirect
33-
golang.org/x/sys v0.4.0 // indirect
34-
golang.org/x/text v0.6.0 // indirect
35-
google.golang.org/genproto v0.0.0-20230119192704-9d59e20e5cd1 // indirect
36-
google.golang.org/grpc v1.52.0 // indirect
28+
golang.org/x/sys v0.8.0 // indirect
29+
golang.org/x/text v0.9.0 // indirect
3730
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
3831
gopkg.in/yaml.v2 v2.4.0 // indirect
3932
)

0 commit comments

Comments
 (0)