Skip to content

Instantly share code, notes, and snippets.

View lwolf's full-sized avatar

Sergii Nuzhdin lwolf

View GitHub Profile
@lwolf
lwolf / env2secret.py
Created April 22, 2016 12:30
Script to convert docker-compose compatible environment files into kubernetes secrets
"""
requires click package:
- pip install click
Example usage:
- python env2secret.py --src=production-ru.env --dst=production-ru-secret.yaml --fmt=yaml --name=my-app-secret
"""
import base64
import click
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-load-balancer-conf
data:
body-size: "0"
proxy-connect-timeout: "10"
proxy-read-timeout: "360"
proxy-send-imeout: "360"
@lwolf
lwolf / iptables_rules.sh
Created December 5, 2016 09:30 — forked from virtualstaticvoid/iptables_rules.sh
25 Most Frequently Used Linux IPTables Rules Examples
# Modify this file accordingly for your specific requirement.
# http://www.thegeekstuff.com
# 1. Delete all existing rules
iptables -F
# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
#!/bin/sh
########
# originaly from https://github.com/mlafeldt/chef-runner/blob/v0.7.0/script/coverage
#######
# Generate test coverage statistics for Go packages.
#
# Works around the fact that `go test -coverprofile` currently does not work
# with multiple packages, see https://code.google.com/p/go/issues/detail?id=6909
#
# Usage: script/coverage [--html|--coveralls]
@lwolf
lwolf / cloud-config.yml
Created June 22, 2017 13:13 — forked from socketwiz/cloud-config.yml
CoreOS cloud-config for DigitalOcean with iptables firewall
#cloud-config
coreos:
etcd2:
# generate a new token for each unique cluster from https://discovery.etcd.io/new?size=3
# specify the initial size of your cluster with ?size=X
discovery: https://discovery.etcd.io/<token>
# multi-region and multi-cloud deployments need to use $public_ipv4
advertise-client-urls: http://$private_ipv4:2379,http://$private_ipv4:4001
initial-advertise-peer-urls: http://$private_ipv4:2380
@lwolf
lwolf / cleanup
Created September 16, 2017 10:21
Error adding network: no IP addresses available in network: cbr0”
$ cd /var/lib/cni/networks/kubenet
$ ls
10.180.2.2 10.180.2.3 10.180.2.4 last_reserved_ip
$ echo foobar > 10.180.2.244
$ for hash in $(tail -n +1 * | grep '^[A-Za-z0-9]*$' | cut -c 1-8); do if [ -z $(docker ps -a | grep $hash | awk '{print $1}') ]; then grep -ir $hash ./; fi; done
./10.180.2.244:foobar
$ for hash in $(tail -n +1 * | grep '^[A-Za-z0-9]*$' | cut -c 1-8); do if [ -z $(docker ps -a | grep $hash | awk '{print $1}') ]; then grep -ilr $hash ./; fi; done | xargs rm
kubectl get pods -w -l release=stolon-kube
NAME READY STATUS RESTARTS AGE
stolon-kube-stolon-ht89t 0/1 Completed 0 1m
stolon-kube-stolon-keeper-0 1/1 Running 0 1m
stolon-kube-stolon-keeper-1 1/1 Running 0 1m
stolon-kube-stolon-keeper-2 1/1 Running 0 59s
stolon-kube-stolon-proxy-c87c57676-h8pxj 1/1 Running 0 1m
stolon-kube-stolon-proxy-c87c57676-rcbdz 1/1 Running 0 1m
stolon-kube-stolon-proxy-c87c57676-zdcrc 1/1 Running 0 1m
stolon-kube-stolon-sentinel-5dc5fd564f-56z89 1/1 Running 0 1m
#!/usr/bin/env bash
set -e
start=$(date -ud 20170413 "+%s") # start time in epoch time (seconds since Jan. 1st, 1970)
end=$(date -ud 20180831 "+%s") # end time
period=$((86400 * 7)) # 86400 is 24 hours
for ((i=start; i <= end; i+=$period)); do
@lwolf
lwolf / gist:b94d702e0e754e5f40d7febcc25e7b5d
Created November 14, 2018 18:46
GlusterFS notes 01. heketi logs
$ kubectl describe pod heketi-679447869-25f6n
...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 7m default-scheduler Successfully assigned default/heketi-679447869-25f6n to srv-vm-02
Warning FailedMount 7m kubelet, srv-vm-02 MountVolume.SetUp failed for volume "db" : mount failed: mount failed: exit status 1
Mounting command: systemd-run
Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/pods/c5c266b6-da0f-11e8-bd66-000c29769173/volumes/kubernetes.io~glusterfs/db --scope -- mount -t glusterfs -o log-file=/var/lib/kubelet/plugins/kubernetes.io/glusterfs/db/heketi-679447869-25f6n-glusterfs.log,log-level=ERROR,backup-volfile-servers=192.168.11.14:192.168.11.15:192.168.11.16,auto_unmount 192.168.11.14:heketidbstorage /var/lib/kubelet/pods/c5c266b6-da0f-11e8-bd66-000c29769173/volumes/kubernetes.io~glusterfs/db
# roles/download/defaults/main.yaml
kubeadm:
enabled: "{{ kubeadm_enabled }}"
file: true
version: "{{ kubeadm_version }}"
dest: "{{local_release_dir}}/kubeadm"
# sha256: "{{ kubeadm_binary_checksum }}"
url: "{{ kubeadm_download_url }}"
unarchive: false
owner: "root"