Skip to content

Instantly share code, notes, and snippets.

View PatrickLang's full-sized avatar

Patrick Lang PatrickLang

  • Washington, USA
View GitHub Profile
@PatrickLang
PatrickLang / README.md
Created May 4, 2020 05:15
Alcor Micro USB 2.0 Card Reader code 14

I recently bought a Cooler Master Silencio S400 case which has a built-in SD card reader. The driver installed via Windows Update didn't work, and showed a code 14. After reboot the problem still persisted.

My old Lenovo X250 happens to have the same card reader chipset, so I tried it's driver from https://support.lenovo.com/us/en/downloads/ds102036.

Run it and choose "extract only". Now go to the "Alcor Micro USB 2.0 Card Reader" with the ! on it in Device Manager, pick "Update Driver", then browse to C:\drivers\WIN\smartcard. Windows will find the driver there, and it works.

@PatrickLang
PatrickLang / README.md
Last active August 14, 2020 11:32
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
PatrickLang / bugreport.md
Last active July 10, 2019 00:41
Bugs in unit parsing

Background

https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/

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

Bug

@PatrickLang
PatrickLang / README.md
Last active June 25, 2019 14:55
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 https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewadvanced . 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
PatrickLang / README.md
Last active August 14, 2020 16:46
Minikube & Flannel

Steps

  1. Setup Hyper-V and create an external switch
  2. Install Minikube for Windows
@PatrickLang
PatrickLang / gatherlogs.ps1
Last active April 29, 2019 22:39
Gathering Kubernetes logs with Azure Portal
# 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)_logs.zip";
$paths = get-childitem c:\k\*.log -Exclude $lockedFiles;
$paths += get-childitem c:\k\azure-vnet.log.*;
@PatrickLang
PatrickLang / README.md
Last active April 10, 2019 16:24
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

  nodeSelector:
    "beta.kubernetes.io/os": linux
@PatrickLang
PatrickLang / README.md
Last active March 28, 2019 20:43
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
PatrickLang / README.md
Created February 21, 2019 23:40
Time spent in failed Kubernetes test cases
curl.exe https://storage.googleapis.com/kubernetes-jenkins/logs/ci-kubernetes-e2e-aks-engine-azure-master-windows/2/build-log.txt -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"

Returns

237.2573