Skip to content

Instantly share code, notes, and snippets.


Alastair Firth afirth

View GitHub Profile
afirth / kustomization.yaml
Created Aug 21, 2020
kustomize patch service for NEGs ingress (GKE)
View kustomization.yaml
- target:
version: v1
kind: Service
name: NAME
namespace: NS
patch: |-
- op: add
path: "/metadata/annotations"
afirth / gist:fb3b4dcd3ce1db9adc58993ff09cd02d
Created Aug 13, 2020
recover staged or reset files in git (ran git add but somehow discarded without committing)
View gist:fb3b4dcd3ce1db9adc58993ff09cd02d
export UNIQUE_CODE=sops_version
for b in $(git fsck --lost-found | grep blob | awk '{print $3}'); do git cat-file -p $b | grep -q ${UNIQUE_CODE} && echo $b && git cat-file -p $b && echo; done
afirth / gist:35f2e422fd056c776a4463a5948cf6fd
Created Jul 31, 2020
JSON logs for ingress-nginx (stackdriver compatible)
View gist:35f2e422fd056c776a4463a5948cf6fd
log-format-escape-json: "true"
http-snippet: |
map $msec $timestamp_secs { ~(.*)\..* $1; }
map $msec $timestamp_nanos { ~.*\.(?<tsn>.*) "${tsn}000000"; }
log-format-upstream: '{"timestampSeconds":"$timestamp_secs", "timestampNanos":"$timestamp_nanos", "time_epoch":"$msec", "time_iso8601":"$time_iso8601", "remote_addr":"$proxy_protocol_addr", "x-forward-for":"$proxy_add_x_forwarded_for", "request_id":"$req_id", "remote_user":"$remote_user", "bytes_sent":$bytes_sent, "request_time":$request_time, "status":$status, "vhost":"$host", "request_proto":"$server_protocol", "path":"$uri", "request_query":"$args", "request_length":$request_length, "duration":$request_time, "method":"$request_method", "http_referrer":"$http_referer", "http_user_agent":"$http_user_agent" }'
View gist:147fe2d1e5d2cd673216c30e96d637e5
.PHONY: sops
SOPS_URL=$(shell curl -s "" | grep -o "http.*sops_.*_amd64\.deb")
sops: $(curl)
wget $(SOPS_URL) -O ~/Downloads/sops.deb
sudo apt install ~/Downloads/sops.deb
afirth /
Last active Apr 19, 2020
kubectl view all secrets in namespace
#requires jq >= 1.6
k get secret -o json -n <namespace> | jq -r '.items[] | [, (.data |map_values(@base64d) )]'
# only keys
k get secret -o json -n <namespace> | jq -r '.items[] | [, (.data |map_values(@base64d) )] | to_entries | .[] | [.value] ' | grep ':'
# better format
k get secret -o json -n accounts-web | jq -r '.items[] | [, (.data |map_values(@base64d) )]' | grep --color=never -P '\w'
afirth / gist:13630e948592966f1ac44532175a3696
Last active Jan 15, 2020
vim add phony targets for makefiles
View gist:13630e948592966f1ac44532175a3696
%s/^\([a-z-]\+\):/.PHONY: \1\r\1:/
#name and status
k get zb -o json | jq -r '.items[] | [, .status.ready] | @tsv'
#get pods by label, show image and ready status
kgp --all-namespaces -l -o json | jq -r '.items[] |[ .metadata.namespace, .status.containerStatuses[0].ready, .status.containerStatuses[0].image ] | @tsv' | grep alpha <<<
View flamegraph java profile notes
sudo apt-install openjfx
java --module-path /usr/share/openjfx/lib --add-modules=javafx.base,javafx.controls,javafx.fxml,,,javafx.swing,javafx.web -cp ~/honest-profiler/honest-profiler.jar com.insightfullogic.honest_profiler.ports.console.FlameGraphDumperApplication ~/Downloads/honest-profiler-log-05.hpl ~/Downloads/honest-profiler-log-05.folded
git clone --depth 1
cd FlameGraph
View gist:3b78034d5df5ffa5c7416f03bf26d319
dlv test -- -test.v
b filename:ln