Skip to content

Instantly share code, notes, and snippets.

Bogdan metallica127

Block or report user

Report or block metallica127

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@metallica127
metallica127 / simple_backup.sh
Last active Sep 30, 2018
Example script for "Consul - the swiss knife by Hashicorp" article.
View simple_backup.sh
#!/usr/bin/env bash
function perform_backup(){
echo -n "Copying some stuff on S3.."
echo "Done!"
}
perform_backup
@metallica127
metallica127 / Installation.md
Last active Dec 20, 2018
Install docker and docker compose on Ubuntu
View Installation.md

Lightweight script to install Docker CE and docker-compose on Ubuntu.

To run script simply execute:

curl https://gist.githubusercontent.com/metallica127/a6c1960502ae8ef61782f527eed1e343/raw/51cbf65b1fe1e213725822354ad16c479b928239/install_docker_compose.sh | sudo bash -s
@metallica127
metallica127 / Bash_at_exit_command.md
Last active Dec 20, 2018
Bash run command at exit
View Bash_at_exit_command.md

If set -e is set, non-zero exit code during script run will terminate the execution.
To prevent immidient termination and add some logic to cleanup stuff, you may need to use trap command:

#!/usr/bin/env bash

set -e

function cleanup {
  echo "Removing $TMP_STUFF_DIR"
View SYSTEMD.md

Verify you .service file

systemd-analyze verify /path/to/your/file.service
View DOCKER_OVERLAY.md

Network

We need a global docker network in order to communicate between docker-compose setups on different hosts

Step 1: Install and run Consul (as a key-value storage for docker)

https://www.consul.io/intro/getting-started/install.html

Step 2: Edit docker configuration (on each docker host)

@metallica127
metallica127 / gotchas.md
Last active Nov 14, 2017
List of some weirdness and gotchas
View gotchas.md

Ruby

  1. Outside ENV strings are frozen:

example.rb:

ENV['foo'].strip!

Run:

View CHEF_SOLO_PROGRAMMATICALLY.md

How to run Chef-Solo programmatically:

require 'chef'
require 'chef/application/solo'

Chef::Config[:solo_legacy_mode] = true
Chef::Config[:cookbook_path] = [File.join(File.absolute_path(File.dirname(__FILE__)), 'cookbooks')]

chef_client = Chef::Application::Solo.new
View DOCKER_PUBLIC_IP.md

Actually, it's a guide to setup docker macvlan network and it can be used to attach static ip to container on public/local network.

  1. Create docker public network:
docker network create -d macvlan --subnet=$SUBNET --gateway=$GATEWAY_IP -o parent=eth0 public

Where:
$SUBNET - your public network subnet
$GATEWAY_IP - your public network gateway

@metallica127
metallica127 / AWS_SWAP.md
Last active Nov 14, 2017
Create and use swap on aws instance (or any other ubuntu machine)
View AWS_SWAP.md

Platform: Ubuntu 16.04

  1. It is common practice to create swap that equals to your RAM. So firstly, you should find out your RAM:
free -m

Which outputs like:

              total        used        free      shared  buff/cache   available
View Install_docker_specific_version.md
  1. Add docker repo
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
  1. Update
You can’t perform that action at this time.