Skip to content

Instantly share code, notes, and snippets.

Patrick Lang PatrickLang

  • Microsoft
Block or report user

Report or block PatrickLang

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
PatrickLang /
Last active Feb 6, 2020
Kubelet debugging snippets

Reaching kubelet API endpoints

If you have a valid kubeconfig, then you can proxy through the apiserver to reach the kubelet's API on each node

kubectl proxy
PatrickLang /
Last active Jul 10, 2019
Bugs in unit parsing


Limits and requests for memory are measured in bytes. You can express memory as a plain integer or as a fixed-point integer using one of these suffixes: E, P, T, G, M, K. You can also use the power-of-two equivalents: Ei, Pi, Ti, Gi, Mi, Ki. For example, the following represent roughly the same value:

128974848, 129e6, 129M, 123Mi


PatrickLang /
Last active Jun 25, 2019
WSL2 for Kubernetes developers

Using WSL2

KIND can run using Windows Subsystem for Linux 2 (WSL2) on Windows 10 Insider builds. All the tools needed to build or run KIND work in WSL2, but some extra steps are needed to switch to WSL2. This page covers these steps in brief but also links to the official documentation if you would like more details.

Getting Windows 10 Insider Preview

Download latest ISO at . Choose "Windows 10 Insider Preview (FAST) - Build 18912". If there's a later build number, get that instead and then you can skip the work to upgrade to 18917.

VM Settings

PatrickLang /
Last active Nov 22, 2019
Minikube & Flannel


  1. Setup Hyper-V and create an external switch
  2. Install Minikube for Windows
PatrickLang / gatherlogs.ps1
Last active Apr 29, 2019
Gathering Kubernetes logs with Azure Portal
View gatherlogs.ps1
# Set this to a storage account with write access to the VM's managed identity. If empty, uploading will be skipped
$azStorageDestination = ""
$lockedFiles = "kubelet.err.log", "kubelet.log", "kubeproxy.log", "kubeproxy.err.log", "azure-vnet-telemetry.log";
$netDebugFiles = "network.txt", "endpoint.txt", "policy.txt", "ip.txt", "ports.txt", "routes.txt", "vfpOutput.txt";
$timeStamp = get-date -format 'yyyyMMdd-hhmmss';
$zipName = "$(hostname)-$($timeStamp)";
$paths = get-childitem c:\k\*.log -Exclude $lockedFiles;
$paths += get-childitem c:\k\azure-vnet.log.*;
PatrickLang /
Last active Apr 10, 2019
Making jumpbox to AKS
kubectl run  jumpbox --image=debian --port=22 --command "/bin/bash" -- "-c" "while true; do sleep 30; done;"

If it doesn't start, kubectl edit deploy jumpbox and add this

    "": linux
PatrickLang /
Last active Mar 28, 2019
Running portainer to view containers running on a Windows Kubernetes node

This is a terrible idea from a security standpoint, but it's fun for demos or tests.

It will run Portainer on whatever node it gets scheduled on, using the Windows named pipe back to the host for Docker management. Be careful because the service in that YAML could end up on a public IP. If someone breaks in, they can create containers at will including mounts to host paths.

docker inspect ... on the container will show that it's handled correctly as a Windows named pipe:

"Mounts": [                                                                                                                                              [88/1899]
PatrickLang /
Created Feb 21, 2019
Time spent in failed Kubernetes test cases
curl.exe -o build-log-2.txt
$lines = Select-String -Pattern "Failure \[(?<time>\d+\.\d+)"  -Path .\build-log-2.txt
($lines | %{$_.Matches[0].Groups["time"].Value} | Measure-Object -Sum).Sum / 60 ; "minutes spent in failed test cases"


PatrickLang /
Last active Feb 8, 2019
Investigating pod startup time

Investigations for

$ kubectl scale deploy iis-2019 --replicas=10
deployment.extensions/iis-2019 scaled
patrick@planglx1:~/aznet17+ssh$ kubectl get pod -o wide -w
NAME                        READY   STATUS              RESTARTS   AGE     IP             NODE         NOMINATED NODE
PatrickLang /
Last active Feb 5, 2019
SIG-Windows Standup & Triage
You can’t perform that action at this time.