Skip to content

Instantly share code, notes, and snippets.

View denzhel's full-sized avatar
🇺🇦

Dennis Zheleznyak denzhel

🇺🇦
View GitHub Profile
@denzhel
denzhel / es_fast_recovery.md
Created December 24, 2021 20:31
es fast shards recovery

Use the following command to recover your Elasticsearch cluster faster than ever:

curl -X PUT localhost:9200/_cluster/settings -H 'Content-Type: application/json' -d'
{
  "transient": {
    "cluster.routing.allocation.node_concurrent_recoveries":30,
    "indices.recovery.max_bytes_per_sec": "100mb"
  }
}'
@denzhel
denzhel / es_default_settings.md
Created December 24, 2021 20:30
elasticsearch show defaults settings

To show the default settings of your Elasticsearch cluster, use the following:

GET /_cluster/settings?include_defaults
@denzhel
denzhel / aws_sm_force_delete_secrets.md
Created December 7, 2021 08:53
aws secret manager - force delete secrets without recovery

To delete a secret immediately, use the following command:

aws secretsmanager delete-secret --secret-id <SECRET_NAME> --force-delete-without-recovery --region <AWS_SM_REGION>
@denzhel
denzhel / helm_template_first_element.md
Created December 5, 2021 19:52
helm template get first element and value

I had this YAML list and I needed to extract the name of the first server without the port:

global:
  datastores:
     db:
       hosts:
       - name: prod-mongo-11
         port: 27017
       - name: prod-mongo-12
 port: 27017
@denzhel
denzhel / es_disable_shard_allocation.md
Last active January 15, 2023 11:33
elasticsearch disable shard allocation

I used this on a ES 5.5 cluster to disable shard allocation and do some maintainance work:

curl -X PUT "http://localhost:9250/_cluster/settings?pretty" \
-H 'Content-Type: application/json' -d \
'{   "persistent": {     "cluster.routing.allocation.enable": "none"   } }'

Then enable shard allocation:

curl -X PUT "http://localhost:9250/_cluster/settings?pretty" \
@denzhel
denzhel / avoid_vim_binary_mode.md
Created November 14, 2021 22:33
Avoid vim binary mode

To avoid the annoying vim binary end of line , set the following in your vim config file:

set noendofline
set nofixendofline
@denzhel
denzhel / helm_hosts_with_ports.md
Created August 19, 2021 06:32
helm helper function: hosts with ports

The following function takes a map of hosts and ports:

  datastores:
    db:
      database: data
      replicaSet: mongo
      servers:
      - host: a
        port: 27017
 - host: b
@denzhel
denzhel / remove_new_line_vim.md
Created August 15, 2021 04:13
remove new line in vim

Since I use VIM as my main IDE, alot of times I have to remove the new line that is added to files when I edit them. To do that, edit the file you are working on and type the following:

:set noendofline binary
:wq!
@denzhel
denzhel / destroy_multiple_terraform.md
Last active August 2, 2021 17:59
Apply or Destroy Terraform resources

If you want to destroy something from your state that has a lot of resources with a common name you can use the following:

terraform apply $(for i in $(tf state list | grep <Name>); do echo -n "-target=$i " ; done) 

e.g I use it to destroy a datastore that has many resources such as EC2, Route53 records, EBS and etc ..

#terraform

@denzhel
denzhel / consume_kafka_msgs.md
Last active July 20, 2021 18:01
Consume Kafka messages

If you don't have Kafkacat installed you can use the default tools installed with the server:

./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic <TopicNaame> --from-beginning

#kafka