Skip to content

Instantly share code, notes, and snippets.

View byteshiva's full-sized avatar
🎯
Focusing

Siva byteshiva

🎯
Focusing
View GitHub Profile
@byteshiva
byteshiva / deployment-tool-ansible-puppet-chef-salt.md
Created July 4, 2016 05:35 — forked from jaceklaskowski/deployment-tool-ansible-puppet-chef-salt.md
Choosing a deployment tool - ansible vs puppet vs chef vs salt

Requirements

  • no upfront installation/agents on remote/slave machines - ssh should be enough
  • application components should use third-party software, e.g. HDFS, Spark's cluster, deployed separately
  • configuration templating
  • environment requires/asserts, i.e. we need a JVM in a given version before doing deployment
  • deployment process run from Jenkins

Solution

@byteshiva
byteshiva / customparser.rb
Created August 11, 2016 11:05
Custom Library
module CustomParser
module Util
def my_echo_method(param1, param2)
puts "Hello #{param1}"
puts "Hello #{param2}"
end
@byteshiva
byteshiva / Vhostman-nginx.bash
Created August 22, 2016 11:03 — forked from willwade/Vhostman-nginx.bash
VhostMan-Nginx. A small script (and other bits) for creating virtual hosts with Nginx. Use as you wish. Download all the components - put in your path somewhere and run with vhostman-nginx.sh create domain.com app name. It doesn't need the gunicorn_start file if you don't need that.
#!/bin/bash
### Set default parameters
# somewhat follows the conventions from: http://michal.karzynski.pl/blog/2013/10/29/serving-multiple-django-applications-with-nginx-gunicorn-supervisor/
# designed to run on a debian symbiosis box if your interested why its /srv
action=$1
domain=$2
appname=$3
owner=$(who am i | awk '{print $1}')
sitesEnable='/etc/nginx/sites-enabled/'
sitesAvailable='/etc/nginx/sites-available/'
{
"acl_datacenter": "test-1",
"acl_default_policy": "deny",
"acl_down_policy": "deny",
"acl_master_token": "1234",
"acl_ttl": "30s",
"bootstrap_expect": 3,
"check_update_interval": "5m",
"datacenter": "test-1",
"data_dir": "/etc/consul.d/data",
@byteshiva
byteshiva / Service check definitions
Created August 24, 2016 12:57
Check definition
{
"services": [
{
"id": "red0",
"name": "redis",
"tags": [
"master"
],
"address": "127.0.0.1",
"port": 6000,
- What do Etcd, Consul, and Zookeeper do?
- Service Registration:
- Host, port number, and sometimes authentication credentials, protocols, versions
numbers, and/or environment details.
- Service Discovery:
- Ability for client application to query the central registry to learn of service location.
- Consistent and durable general-purpose K/V store across distributed system.
- Some solutions support this better than others.
- Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
- Centralized locking can be based on this K/V store.
@byteshiva
byteshiva / install-consul.sh
Created August 24, 2016 13:05 — forked from cbednarski/install-consul.sh
Ubuntu installer script for consul
set -x
mkdir -p /tmp/consul
cd /tmp/consul
# Consul Configuration File
tee consul.json <<CONSULCONFIG
{
"bootstrap_expect": 3,
"client_addr": "0.0.0.0",
@byteshiva
byteshiva / template.json
Created August 24, 2016 13:07 — forked from d-smith/template.json
cloudformation template lab 3
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS CloudFormation template to create the needed AWS resources for Labs 3 & 4 of the ECS Microservices Bootcamp for re:Invent 2015",
"Mappings": {
"AWSRegionToAMI": {
"eu-west-1": {
"AMI": "ami-a10897d6"
@byteshiva
byteshiva / consul.json
Created August 24, 2016 13:07
Run with: consul agent -config-file=/opt/consul/config/config.json
{
"bootstrap": false,
"bootstrap_expect": 1,
"datacenter": "east-aws",
"data_dir": "/opt/consul/data",
"log_level": "INFO",
"node_name": "60f81dc58442",
"server": true,
"telemetry": {
"dogstatsd_addr": "127.0.0.1:8125",
# Quick Measure
grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}'
# 1.37339%
# Quicker
top -bn1 | grep "Cpu(s)" | \
sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | \
awk '{print 100 - $1"%"}'
# 1.4%