Skip to content

Instantly share code, notes, and snippets.

View nithu0115's full-sized avatar
🍻
Work Hard, Have Fun “¯\_(ツ)_/¯“

Nithish Murcherla nithu0115

🍻
Work Hard, Have Fun “¯\_(ツ)_/¯“
View GitHub Profile
@nithu0115
nithu0115 / download-docker-image.sh
Created July 28, 2020 19:02
It allows you to download a docker image in a loadable tar-format, but without using docker pull, and only relies on bash and some other CLI tools.
#!/usr/bin/env bash
## Origin: https://raw.githubusercontent.com/moby/moby/master/contrib/download-frozen-image-v2.sh
# We extend our path to include local directory to ease jq finding.
export PATH=$PATH:.
# List of external commands we need currently
NEEDCMD=(
curl jq awk sha256sum uname
#!/bin/bash
# If only one argument is given when calling this script, we do a namespace switch.
# If a second argument exists when calling this script, we do a cluster switch.
# When switching clusters, alert the user if that cluster is not found.
# The trap provides the current context on exit. The context names are sorted to provide consistency.
LRED=$(echo -en '\033[01;31m')
RESTORE=$(echo -en '\033[0m')
trap 'CURRENT_CONTEXT=$(kubectl config current-context) && echo && kubectl config get-contexts | head -n1 && kubectl config get-contexts | sed 1d | sort --key=1 -b | sed "s|\*\(.*\)${CURRENT_CONTEXT}\(.*\)$|${LRED}\*\1${CURRENT_CONTEXT}\2${RESTORE}|g"' 0 1 3 15
#include <bcc/proto.h>
#include <uapi/linux/ip.h>
#include <uapi/linux/ipv6.h>
#include <net/inet_sock.h>
//Newer kernel bug so need to #define before including ip_fib.h
#define KBUILD_MODNAME "foo"
#include <net/ip_fib.h>
#include <linux/netfilter/x_tables.h>
#define ROUTE_EVT_IF 1
\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
\n
@nithu0115
nithu0115 / skbtracer.c
Created August 16, 2021 15:30 — forked from chendotjs/skbtracer.c
ebpf-skbtracer
#include <bcc/proto.h>
#include <uapi/linux/ip.h>
#include <uapi/linux/ipv6.h>
#include <uapi/linux/icmp.h>
#include <uapi/linux/tcp.h>
#include <uapi/linux/udp.h>
#include <uapi/linux/icmpv6.h>
#include <net/inet_sock.h>
#include <linux/netfilter/x_tables.h>
#!/bin/sh
#
# The access this gives you is rather terrifing. Use sparingly.
#
set -e -x
node=$1
trap "kubectl delete pod nodesh-$node" EXIT
#!/usr/bin/env python
# coding: utf-8
import sys
from socket import inet_ntop, AF_INET, AF_INET6
from bcc import BPF
import ctypes as ct
import subprocess
import struct
from struct import pack
#include <bcc/proto.h>
#include <uapi/linux/ip.h>
#include <uapi/linux/ipv6.h>
#include <net/inet_sock.h>
//Newer kernel bug so need to #define before including ip_fib.h
#define KBUILD_MODNAME "foo"
#include <net/ip_fib.h>
#include <linux/netfilter/x_tables.h>
#include <net/route.h>
#/usr/bin/env python
# coding: utf-8
import sys
from socket import inet_ntop, AF_INET, AF_INET6
from bcc import BPF
import ctypes as ct
import subprocess
import struct
from struct import pack
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: ssm-agent
namespace: kube-system
labels:
k8s-app: ssm-agent
spec:
selector:
matchLabels: