Skip to content

Instantly share code, notes, and snippets.

View superseb's full-sized avatar

Sebastiaan van Steenis superseb

  • Qdrant
  • Netherlands
  • 17:36 (UTC +02:00)
View GitHub Profile
@superseb
superseb / veth.sh
Last active June 7, 2017 11:08
Docker veth to container mapping
#!/bin/bash
# Credits to https://superuser.com/a/1183520
for container in $(docker ps -q); do
if docker exec -t $container which sh > /dev/null 2>&1; then
iflink=`docker exec -it $container sh -c 'cat /sys/class/net/eth0/iflink'`
iflink=`echo $iflink|tr -d '\r'`
veth=`grep -l $iflink /sys/class/net/veth*/ifindex`
veth=`echo $veth|sed -e 's;^.*net/\(.*\)/ifindex$;\1;'`
echo $container:$veth
else
@superseb
superseb / rancher-rodeo-notes.md
Last active June 27, 2017 09:57
Rancher Rodeo notes

DEPRECATED as of 2017-06-27, see README here https://github.com/chrisurwin/rancher-rodeo

Prerequisites

  • Machine with 8GB RAM, SSD – Run 1 rancher server and 3 nodes (change the RAM size)
  • Machine with 16GB RAM NVME Disk – Run 1 Rancher Server and 3 VMS
  • 4 VMs running in Cloud (2GB each, ensure security group has UDP 500 & 4500, TCP 8080, 2049 & 80 open. Recommend all traffic on UDP and TCP allowed in local network)

Only run Docker 1.12.6 if you want the K8s demo to work!

Vagrant users

@superseb
superseb / docker-compose.yml
Created June 30, 2017 14:28
Rancher simulate DB network fail
version: '2'
services:
db:
image: mariadb:5.5
command: --character-set-server=utf8 --collation-server=utf8_general_ci
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=cattle
@superseb
superseb / docker-17.06.0-ce.yml
Created July 8, 2017 07:40
RancherOS docker-17.06.0-ce
docker:
image: rancher/os-docker:17.06.0${SUFFIX}
command: ros user-docker
environment:
- HTTP_PROXY
- HTTPS_PROXY
- NO_PROXY
labels:
io.rancher.os.scope: system
io.rancher.os.after: console
@superseb
superseb / rancher.irule
Created July 12, 2017 15:47
f5 rancher irule
when HTTP_REQUEST {
HTTP::header insert "X-Forwarded-Proto" "https";
HTTP::header insert "X-Forwarded-Port" "443";
HTTP::header insert "X-Forwarded-For" [IP::client_addr];
}
@superseb
superseb / docker-compose.yml
Created July 24, 2017 13:06
rancher udp connection test
version: '2'
services:
udp:
image: mendhak/udp-listener
environment:
- UDPPORT=6343
labels:
io.rancher.scheduler.global: 'true'
ports:
@superseb
superseb / gitbackportcommitpatch.md
Created July 25, 2017 10:49
How to backport a commit to a different file (create patch and apply patch to different file)
  1. Commit your change (git commit)
  2. Create patch from commit (git format-patch master --stdout > my_patch.patch)
  3. Apply patch to other file (patch -p1 your_other_file my_patch.patch)
@superseb
superseb / getresourcelimitsrancherhost.sh
Created July 25, 2017 15:04
Calculate new resource limits for Rancher hosts
curl -s http://xxx/v2-beta/projects/1a5/hosts/1h1 | jq '.milliCpu,.memory/1024/1024'
@superseb
superseb / show_metadata_ips.sh
Created August 7, 2017 10:05
Show all IPs of the metadata containers in a Rancher environment
#!/bin/bash
curl -s $RANCHER_URL/containers | jq '.data[] | select(.data.dockerContainer.Labels["io.rancher.stack_service.name"] == "network-services/metadata") | .primaryIpAddress'
@superseb
superseb / kubernetes-troubleshoot-rancher.md
Created October 9, 2017 14:03
Troubleshooting Kubernetes in Rancher

Get nodes from API

BEARER=`cat /etc/kubernetes/ssl/kubeconfig  | grep token | awk '{ print $2 }' | sed -e "s/\"//g"` curl -H "Authorization: Bearer $BEARER" --key /etc/kubernetes/ssl/key.pem --cacert /etc/kubernetes/ssl/ca.pem https://kubernetes.kubernetes.rancher.internal:6443/api/v1/nodes | jq .items[].metadata.name