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
PatrickLang / README.md
Last active Feb 6, 2020
Kubelet debugging snippets
View README.md

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 Jul 10, 2019
Bugs in unit parsing
View bugreport.md

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 Jun 25, 2019
WSL2 for Kubernetes developers
View README.md

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 Nov 22, 2019
Minikube & Flannel
View README.md

Steps

  1. Setup Hyper-V and create an external switch
  2. Install Minikube for Windows
@PatrickLang
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)_logs.zip";
$paths = get-childitem c:\k\*.log -Exclude $lockedFiles;
$paths += get-childitem c:\k\azure-vnet.log.*;
@PatrickLang
PatrickLang / README.md
Last active Apr 10, 2019
Making jumpbox to AKS
View README.md
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 Mar 28, 2019
Running portainer to view containers running on a Windows Kubernetes node
View README.md

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 Feb 21, 2019
Time spent in failed Kubernetes test cases
View README.md
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
@PatrickLang
PatrickLang / README.md
Last active Feb 8, 2019
Investigating pod startup time
View README.md

Investigations for https://github.com/kubernetes/kubernetes/issues/72722

$ 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
PatrickLang / README.md
Last active Feb 5, 2019
SIG-Windows Standup & Triage
View README.md
You can’t perform that action at this time.