Skip to content

Instantly share code, notes, and snippets.

View joeywhelan's full-sized avatar

Joey Whelan joeywhelan

View GitHub Profile
from elasticsearch import Elasticsearch
WEST_IP = "172.18.0.4"
client = Elasticsearch(f"https://{WEST_IP}:9200", ca_certs="../../west/west-http-ca.crt", basic_auth=("elastic", "elastic"))
resp = client.search(index=["west_ccs", "east_remote:east_ccs"], query={"range": {"release_date": {"gte": 1985}}})
for hit in resp["hits"]["hits"]:
print(hit["_source"])
echo -e "\n*** Activate East as a Remote Cluster on West ***"
json=$(jq -nc \
--arg proxy_address "$EAST_ELASTIC_IP":9300 \
'{
persistent: {
cluster: {
remote: {
east_remote: {
mode: "proxy",
$ node ccr_test.js
*** West CCR ***
{
name: 'Snow Crash',
author: 'Neal Stephenson',
release_date: '1992-06-01',
page_count: 470
}
{
name: 'Revelation Space',
echo -e "\n*** Create a Follower Index, east_ccr on East Cluster ***"
json=$(jq -nc \
'{
remote_cluster: "west_remote",
leader_index: "west_ccr",
max_read_request_operation_count: 5120,
max_outstanding_read_requests: 12,
max_read_request_size: "32mb",
max_write_request_operation_count: 5120,
max_write_request_size: "9223372036854775807b",
echo -e "\n*** Activate West as a Remote Cluster on East ***"
WEST_TRANS_IP=$(kubectl get service westcluster-es-transport -o=jsonpath='{.status.loadBalancer.ingress[0].ip}')
json=$(jq -nc \
--arg proxy_address "$WEST_TRANS_IP":9300 \
'{
persistent: {
cluster: {
remote: {
west_remote: {
mode: "proxy",
echo -e "\n*** Connect Networks ***"
docker network connect kind east-es01-1
docker network connect east_net kind-control-plane
echo -e "\n*** Create east_ccs index ***"
curl -s -k -u "elastic:elastic" "https://$EAST_ELASTIC_IP:9200/_bulk?pretty" \
-H "Content-Type: application/json" \
-d'
{ "index" : { "_index" : "east_ccs" } }
{"name": "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268}
{ "index" : { "_index" : "east_ccs" } }
{"name": "The Handmaid'"'"'s Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311}
' > /dev/null
volumes:
- certs:/usr/share/elasticsearch/config/certs
- ${PWD}/../west/west-ca.crt:/usr/share/elasticsearch/config/remote/west-ca.crt
environment:
- xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt,remote/west-ca.crt
echo -e "\n*** Create west_ccr index ***"
curl -s -k -u "elastic:elastic" "https://$WEST_ELASTIC_IP:9200/_bulk?pretty" \
-H "Content-Type: application/json" \
-d'
{ "index" : { "_index" : "west_ccr" } }
{"name": "Snow Crash", "author": "Neal Stephenson", "release_date": "1992-06-01", "page_count": 470}
{ "index" : { "_index" : "west_ccr" } }
{"name": "Revelation Space", "author": "Alastair Reynolds", "release_date": "2000-03-15", "page_count": 585}
' > /dev/null
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: westcluster-es-elastic-user
data:
elastic: ZWxhc3RpYw==
---
apiVersion: v1
kind: Secret