Skip to content

Instantly share code, notes, and snippets.

View brandond's full-sized avatar

Brad Davidson brandond

View GitHub Profile
@brandond
brandond / panel.h
Last active January 14, 2020 07:52
ESPHome Addressable Light Groups
#include "esphome/core/component.h"
#include "esphome/components/light/addressable_light.h"
namespace esphome {
namespace panel {
static const char *TAG = "panel.light";
class AddressablePanel;
class PanelLightOutput;
@brandond
brandond / menlo.py
Last active December 16, 2020 16:10
Sample Menlo Security logging API client
#!/usr/bin/env python
import logging
import requests
import click
import itertools
from dateutil.parser import isoparse
from datetime import datetime, timezone
from time import time
@brandond
brandond / k3s-kk.sh
Last active January 20, 2022 20:40
Various scripts for doing K3s/RKE2 release stuff
#!/bin/bash
# This script assumes a couple things:
# * you have a copy of kubernetes/kubernetes checked out to $GOPATH/src/github.com/kubernetes/kubernetes
# * you have a copy of k3s-io/k3s checked out to $GOPATH/src/github.com/k3s-io/k3s
# * the repos listed above have an origin named ${USER} (your login) that points to your personal fork of that repo
# * the repos listed above have an origin named k3s-io that points to the k3s-io fork of that repo
# * the kubernetes repo has an origin that points at the kubernetes upstream (doesn't matter what it's called)
set -euxo pipefail
@brandond
brandond / mirror-image.sh
Last active May 11, 2021 14:44
Ignorant hack of a script to mirror multiarch images on Docker Hub. Requires docker and jq.
#!/bin/bash
FLAGS=""
SOURCE="docker.io/library"
DEST="docker.io/brandond"
IMAGE="busybox"
TAG="1.32.0-uclibc"
docker buildx imagetools inspect ${SOURCE}/${IMAGE}:${TAG} --raw | \
jq -r '.manifests[] | (.digest + " " + .platform.architecture)' | \
@brandond
brandond / kubelet.stack.log
Created September 17, 2020 06:43
static build kubelet log
iptables: Chain already exists.
iptables: Chain already exists.
iptables: Chain already exists.
iptables: Chain already exists.
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x63 pc=0x7ff71c04a5ed]
runtime stack:
runtime.throw(0x43bae6b, 0x2a)
/usr/local/go/src/runtime/panic.go:1116 +0x72
@brandond
brandond / modsync.sh
Last active May 15, 2021 00:10
K3s => RKE2 go.mod replacement sync script
#!/bin/bash
K3S_VERSION=$(go mod edit --json | jq -r '.Require[] | select(.Path | contains("rancher/k3s")) | .Version')
K3S_COMMIT=$(grep -oE '\w{12}$' <<< ${K3S_VERSION})
K3S_GO_MOD=$(curl -qsL "https://raw.githubusercontent.com/k3s-io/k3s/${K3S_COMMIT}/go.mod")
echo "Updating go.mod replacements from k3s ${K3S_VERSION}"
for MODPATH in $(go mod edit --json | jq -r '.Replace[] | .Old.Path'); do
REPLACEMENT=$(go mod edit --json /dev/stdin <<<${K3S_GO_MOD} | jq -r --arg MODPATH "${MODPATH}" '.Replace[] | select(.Old.Path==$MODPATH) | .Old.Path + "=" + .New.Path + "@" + .New.Version')
if [ -n "${REPLACEMENT}" ]; then
@brandond
brandond / apiserver-etcd-perf.json
Created May 25, 2021 20:25
WIP grafana dashboard for Kubernetes apiserver datastore performance metrics
{
"__inputs": [],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "7.4.5"
},
{
@brandond
brandond / ntop.yaml
Last active August 11, 2021 22:06
zbalance_ipc + pfcount in a pod
apiVersion: v1
kind: Pod
metadata:
name: ntop
namespace: default
spec:
hostNetwork: true
terminationGracePeriodSeconds: 15
containers:
- image: ntop/ntopng:stable
apiVersion: v1
kind: Secret
metadata:
name: sleep
stringData:
sleep.txt: zzz
---
apiVersion: v1
kind: Pod
metadata:
@brandond
brandond / rke2-releases.sh
Last active October 26, 2021 22:29
RKE2 release cut script
#!/usr/bin/env bash
set -e
set -o noglob
ORIGIN="${ORIGIN:-rancher}"
USERNAME="${USERNAME:-${USER}}"
print() {
echo -e "\033[0;32m$@\033[0m" >&2
}