Skip to content

Instantly share code, notes, and snippets.

View frjaraur's full-sized avatar

Javier Ramirez frjaraur

View GitHub Profile
@frjaraur
frjaraur / python_scripting.rst
Last active September 18, 2015 23:57 — forked from jasonkeene/python_scripting.rst
Get started with writing your own python scripts to automate system tasks.

Python for System Admins / Operators

Installing Python

Most Unix/Linux systems come with python pre-installed:

$ python -V

Quick start


This API allows organization owners to add users to, delete users from or modify users in their organization.

The endpoint is <org>.cartodb.com/u/<org_owner>/api/v1/organization/<org>/users.

Create a user

The parameters sent (via POST; * means they're compulsory) are:

  • username (*) - username for the new user
@frjaraur
frjaraur / userDefineLang_Dockerfile.xml
Created January 27, 2016 17:20 — forked from centic9/userDefineLang_Dockerfile.xml
notepad++ syntax highlighting for Dockerfiles
<NotepadPlus>
<UserLang name="Dockerfile" ext="Dockerfile" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">03 04 00# 01 02</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>

Experimental Docker Libnetwork DHCP Driver

The DHCP driver is intended for users to be able to integrate Docker IP address management with their existing IPAM strategies that use DHCP for dynamic address assignment. DHCP enables users to allocate addresses in an organized fashion that will prevent overlapping IP address assignment by associating a unique MAC address from the container eth0 Ethernet interface to an IP address as determined by the DHCP pools defined in the DHCP configuration.

This driver only provides the DHCP client functionality. It does not include a DHCP server. The default driver offers single-host IPAM or for distributed multi-host orchestrated IPAM see the libnetwork overlay driver.

Getting Started

@frjaraur
frjaraur / docker-compose.yml
Created March 25, 2017 21:31 — forked from ajeetraina/docker-compose.yml
Docker Compose v3.1 file for Secret Management under Docker 1.13
version: "3.1"
services:
db:
image: "mysql:latest"
networks:
collabnet:
aliases: ["db"]
volumes:
- "db_data:/var/lib/mysql"
secrets:
@frjaraur
frjaraur / Docker Stats Review
Created September 26, 2017 15:12
Docker Stats
for I in $(curl --unix-socket /var/run/docker.sock -sS http://localhost/containers/json|jq '.[].Id'|cut -d '"' -f2 );do curl --unix-socket /var/run/docker.sock -sS http://localhost/containers/${I}/stats?stream=false;done
curl --unix-socket /var/run/docker.sock -sS http://localhost/containers/json|jq '.[].Names'
@frjaraur
frjaraur / luks_crypt.md
Created January 16, 2018 18:08
create a simple LUKS partition on a single physical volume

LUKS crypt

In this guide, I'm going to setup a keyfile-encrypted LUKS partition. I will be using a single, max-size partition on a single physical device. My physical device is located at /dev/sde

partition the physical device

parted /dev/sde
@frjaraur
frjaraur / Dockerfile
Created March 5, 2018 22:20
no-shell nginx
FROM alpine
RUN apk add --update --no-cache nginx tzdata \
&& rm -rf /var/cache/apk \
&& rm -f /bin/sh \
&& mkdir /run/nginx \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
ENTRYPOINT ["/usr/sbin/nginx","-g","daemon off;"]

Docker Swarm with Macvlan, Consul and Autoscaling

TL;DR:

This will get you routable containers with IPs on your existing subnets, advertising to Consul. They will also be scalable and placed across a cluster of Swarm hosts. It's assumed that you are already running Consul, so if not, there are a ton of tutorials out there. It's also assumed you know how to install Docker and various Linux kernels.

Bonus: We add an autoscaling API called Orbiter (https://gianarb.it/blog/orbiter-the-swarm-autoscaler-moves).

I just want to run containers, like now, on my existing infrastructure and networks!

So you have an existing environment. You use Consul for service discovery. Life is good. Containers are now a thing and you want to work them in without having to worry about overlay networking or reverse proxies. You also don't want to add extra latency (as some naysayers could use it as fuel to kill your hopes and dreams). Lastly, you don't have a lot of time to invest in a complex orchestration tool, such a

@frjaraur
frjaraur / setup-win10docker.ps1
Created April 23, 2018 14:23 — forked from TerribleDev/setup-win10docker.ps1
install hyper-v, containers, and beta docker on windows so you can use windows containers
# allow scripts to run
set-executionpolicy unrestricted -Force
Get-WindowsOptionalFeature -Online | where {$_.FeatureName -like "*Hyper*" -or $_.FeatureName -like "containers" } | Enable-WindowsOptionalFeature -Online -NoRestart
(new-object net.webclient).DownloadFile('https://download.docker.com/win/beta/InstallDocker.msi','docker.msi')
Start-Process 'docker.msi' /qn -Wait