Created
November 7, 2019 19:42
-
-
Save thbkrkr/bc12a3457fd0f71c5a2106b11ce8801e to your computer and use it in GitHub Desktop.
Set vm.max_map_count=262144 on the nodes of a GKE cluster #k8s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
# Increase Virtual Memory for Elasticsearch on GKE | |
# https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html | |
# Dependencies: kubectl, gcloud, jq | |
nodes() { | |
kubectl get nodes -o custom-columns=n:.metadata.name --no-headers | |
} | |
zone_by_node() { | |
local node=$1 | |
kubectl get node $node -o json \ | |
| jq -r '.metadata.labels["failure-domain.beta.kubernetes.io/zone"]' | |
} | |
gcloud_ssh() { | |
local node=$1 && shift | |
echo ">> ssh $node" | |
gcloud compute ssh --zone $(zone_by_node $node) $node -- sudo bash -c "'"$@"'" | |
} | |
main() { | |
for node in $(nodes); do | |
gcloud_ssh $node \ | |
"sysctl -w vm.max_map_count=262144 && sysctl -n vm.max_map_count" | |
done | |
} | |
main |
awesome !!! thanks so much !!!! ❤️
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍 ❤️