Skip to content

Instantly share code, notes, and snippets.

View danton721's full-sized avatar

Danton Heuer danton721

View GitHub Profile

1. Send debug signal on running pod

Inside the running pod run the following command: kill -s SIGUSR1 1

2. Port forward debugger pod

In computer, run the following command to forward debug port: kubectl port-forward -n <namespace> <pod-name> <pc-port>:9229

@danton721
danton721 / backup-kubernetes-resources.sh
Last active March 8, 2024 02:20
Backup all resources in kubernetes
#!/usr/bin/env bash
# Using "--insecure-skip-tls-verify" as I need to backup a cluster before certificate rotation where already expired.
# Below script should create the following structure: ./{namespace}/{resouce-type}/{resouce-name}.yaml
for NAMESPACE in $(kubectl get ns --insecure-skip-tls-verify --no-headers -o custom-columns=":metadata.name")
do
for n in $(kubectl get -n $NAMESPACE --insecure-skip-tls-verify -o=name pvc,configmap,serviceaccount,secret,ingress,service,deployment,statefulset,hpa,job,cronjob)
do
mkdir -p $(dirname $NAMESPACE/$n)
@danton721
danton721 / debug-nodejs-kubernetes.md
Created May 5, 2023 01:52
Perform the following actions to debug NodeJS application running on Kubernetes without needing to start locally.

Debug Node.JS on Kubernetes directly

Perform the following actions to debug NodeJS application running on Kubernetes without needing to start locally.

1. Add this to your container

command:
  - /bin/sh
 - '-c'
@danton721
danton721 / script-copy-localstorage-another-domain.md
Last active February 20, 2023 05:42
Copy localStorage from a domain to another

Copy localStorage from a domain to another

In a chrome console do the following:

  1. Copy JSON of all Local Storage
JSON.stringify(localStorage)
  1. Copy JSON to clipboard
@danton721
danton721 / get-ad-country.vba
Last active April 2, 2024 18:15
Get AD country for given UPN using AZ CLI in Excel using VBA
'Usage as Excel function: =getCountryFromAD("UPN")
Function getCmdlineOutput(cmd As String)
CreateObject("WScript.Shell").Run "cmd /c """ & cmd & "|clip""", 0, True 'output>clipbrd
With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") 'latebound clipbrd obj
.GetFromClipboard 'get cmdline output from clipboard
getCmdlineOutput = .GetText(1) 'return clipboard contents
End With
End Function
@danton721
danton721 / convert.sh
Last active February 14, 2021 05:27
Decode base64 from a CSV with header "ID, Base64" to ./exports/id.png
#!/bin/bash
# Purpose: Read Comma Separated CSV File w/ id,base64 ecoded PNG and convert to PNG file
# Author: Vivek Gite under GPL v2.0+ (CSV parser) and Base64 changes by Danton Heuer under GPL v2.0+
# Usage: $ sh ./convert.sh filename.csv
echo "Converting Base64 to PNG from CSV file '$1' to ./exports folder"
mkdir -p exports
INPUT="$1"