Skip to content

Instantly share code, notes, and snippets.

View daniilyar's full-sized avatar
💭
Build systems for people, not only for money

Daniil Yaroslavtsev daniilyar

💭
Build systems for people, not only for money
View GitHub Profile
@daniilyar
daniilyar / gist:e433cab6c9d25ba600c4
Created March 18, 2016 21:32
logstash_calculate_message_charts_count
# Calculate message chars count
ruby {
code => "if !event['message'].nil?
message_chars_count = event['message'].length
event.to_hash.merge!('message_chars_count' => message_chars_count)
end"
}
@daniilyar
daniilyar / check_reserved_instances.sh
Created May 4, 2016 09:24
AWS: check if all reserved instances are in use by appropriate on-demand ones
#!/bin/bash
set -e
REGION="us-west-2"
RUNNING_INSTANCES=`aws ec2 describe-instances --region $REGION --filters Name=instance-state-name,Values=running --query Reservations[*].Instances[*].InstanceType --output text | sort | uniq -c | awk ' { t = $1; $1 = $2; $2 = t; print; } '`
# Example:
#m3.medium 11
#r3.large 3
@daniilyar
daniilyar / Dockerfile for Checkstyle master branch compilation
Last active May 14, 2016 15:31
Dockerfile for Checkstyle master branch compilation
FROM ubuntu:14.04
MAINTAINER Daniil Yaroslavtsev <Daniil.Yaroslavtsev@gmail.com>
ENV DEBIAN_FRONTEND noninteractive
ENV MAVEN_VERSION 3.3.9
# Java Version
ENV JAVA_VERSION_MAJOR 8
ENV JAVA_VERSION_MINOR 45
ENV JAVA_VERSION_BUILD 14
@daniilyar
daniilyar / gelf_input_tcp
Last active July 15, 2016 07:14
Logstash GELF input with TCP support added
# encoding: utf-8
require "date"
require "logstash/inputs/base"
require "logstash/namespace"
require "socket"
# This input will read GELF messages as events over the network,
# making it a good choice if you already use Graylog2 today.
#
# The main use case for this input is to leverage existing GELF
{
"order": 0,
"template": "metrics-spark-*",
"settings": {
"index": {
"number_of_shards": "3",
"number_of_replicas": "1",
"refresh_interval": "15s"
}
},
@daniilyar
daniilyar / public key
Created May 10, 2017 21:38
public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeh9PfEk8w+uEfw5Om4vkGVAaYG8G1NSDCwi13i8XYY8xlMFPHMtu+Wo9hmndvJmZAGEa2nMdhRZL0HxL+YQUWlScWnfz5CSh30di3vdojWBHPGbb4aTQm3UuxJHUuwoPeN79UUshW2RPcX7Mv+9RIU1sCc0YDYAsmbtpOrZ3YZMtQXxp87lv865voAbkoA+/SEDf6hVRFvOM8+qVajIrkCRGkXe2yEsJFNn2enTcxb3MveLGPZZeqiXGohDmn7JKl4NpMpmAGDeugeSWdJuzRtN/c8wKvxLZ6sPqp1sCctIvfsq85vKx3G5zcfjNvQ1xRyXDgtpfIngtkTmt5XZvV
@daniilyar
daniilyar / gist:6478af7683d25e664f96
Last active July 25, 2017 02:09
Packer config for provisioning AWS EBS AMIs
{
"variables": {
"vault_pass": "{{ env `VAULT_PASS` }}",
"aws_access_key": "{{ env `AWS_ACCESS_KEY` }}",
"aws_secret_key": "{{ env `AWS_SECRET_KEY` }}",
"source_ami_id": "{{ env `SOURCE_AMI_ID` }}",
"playbook": "{{ env `PLAYBOOK` }}",
"ami_description": "{{ env `AMI_DESCRIPTION` }}",
"roles_path": "{{ env `ROLES_PATH` }}"
},
@daniilyar
daniilyar / give-ssh.txt
Last active May 7, 2019 20:12
How to give me an SSH access to your Debian machine
sudo -i
apt-get -y install curl
useradd dyaroslavtsev -m -d /home/dyaroslavtsev -s /bin/bash
echo "dyaroslavtsev ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
mkdir -p /home/dyaroslavtsev/.ssh
curl -sL https://goo.gl/jS8729 > /home/dyaroslavtsev/.ssh/authorized_keys
chown -R dyaroslavtsev:dyaroslavtsev /home/dyaroslavtsev
@daniilyar
daniilyar / ecr_secrets_refresher.sh
Created May 16, 2019 09:45
AWS ECR token refresh script
#!/bin/bash
HELP_MSG="This script read the AWS credentials from the execution environment and does the docker-login via the AWS-CLI utility.\n
Available arguments: '-s' for the name of the ECR secret will add, '-p' for the profile, '-h' for this message."
while getopts :r:p:h: option
do
case "${option}"
in
r) AWS_REGION="$OPTARG";;
@daniilyar
daniilyar / ecr_secrets_refresher.sh
Last active June 1, 2019 01:26
Script for refreshing the ECR secret in all Kubernetes namespaces
#!/bin/bash
HELP_MSG="This script read the AWS credentials from the execution environment, get the docker-login scring by the AWS-CLI utility, creates the k8s secret with
this docker-login and add it as a a part of "imagePullSecrets" option to the 'default' serviceaccounts in all k8s namespaces.\n
Available arguments: '-s' for the name of the ECR secret will add, '-p' for the patchstring, '-h' for this message."
while getopts :r:p:s:a:h: option
do
case "${option}"
in