Skip to content

Instantly share code, notes, and snippets.

View jsturtevant's full-sized avatar
💻
right clicking and viewing the source

James Sturtevant jsturtevant

💻
right clicking and viewing the source
View GitHub Profile
@jsturtevant
jsturtevant / list images
Created May 11, 2018 19:51
Windows Server images avaliable in azure
az vm image list-skus -l eastus -p MicrosoftWindowsServer -f WindowsServerSemiAnnual
@jsturtevant
jsturtevant / windows-containers-logging.md
Last active December 31, 2023 17:50
Windows Containers Logging

Windows Containers Logging

With Windows Containers, as with any application, you will need to consider your logging strategy. In the containers world it is generally accepted to log to STDOUT/STDERR (standard out and standard error). As you scale up your services you will need to aggregate and store these logs for analysis and debugging later on. There exist many back end systems to aggregate logs and help with analysis, in Azure you have Log Analytics and Application Insights.

There are two general strategies for configuring your containers to send logs to a backend logging system containers:

  • In container logging - Your application is responsible for sending the logs directly to the backend system. This can also be [configured via sidecar].
  • Host level logging - You application is configured for sending logs to a log collection agent on the system. The logging agent will
@jsturtevant
jsturtevant / deploy.yaml
Last active May 6, 2020 13:35
adapter-with-app-insights
---
apiVersion: v1
kind: Namespace
metadata:
name: custom-metrics
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: custom-metrics-azure-apiserver
@jsturtevant
jsturtevant / deploy.yaml
Created August 23, 2018 04:21
adapter-with-sp
---
apiVersion: v1
kind: Namespace
metadata:
name: custom-metrics
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: custom-metrics-azure-apiserver
@jsturtevant
jsturtevant / run-windows-pod-k8s
Last active August 29, 2018 19:51
run-windows-pod-k8s
# windowsservercore
kubectl run windows-1803 -it --rm -n default --image microsoft/windowsservercore:1803 --image-pull-policy=IfNotPresent --restart=Never --overrides '{ "spec": {"nodeSelector":{"beta.kubernetes.io/os":"windows"}}}' --command -- cmd
# nanoserver
kubectl run windows-1803-nano -it --rm -n default --image microsoft/nanoserver:1803 --image-pull-policy=IfNotPresent --restart=Never --overrides '{ "spec": {"nodeSelector":{"beta.kubernetes.io/os":"windows"}}}' --command -- cmd
@jsturtevant
jsturtevant / launch.json
Created September 5, 2018 22:51
VSCode golang setup
#https://github.com/Microsoft/vscode-go/issues/1555#issuecomment-393366905
"useApiV1": false,
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen":300,
"maxArrayValues": 64,
"maxStructFields": -1
}
@jsturtevant
jsturtevant / proxy
Created January 3, 2019 17:33
Connect to windows machine through SSH
ssh -i $KEY_FILE -o ProxyCommand="ssh -i $KEY_FILE -W %h:%p user@<public-ip>" user@<internal-ip>
@jsturtevant
jsturtevant / jq-error.sh
Last active January 3, 2019 20:29
k8s windows kernalversion bug repo
winnode="$(kubectl get nodes -l "beta.kubernetes.io/os=windows" -o json | jq -rc '.items | map({nodeInfo: .status.nodeInfo})[0]')"
echo $winnode
#output
{"nodeInfo":{"architecture":"amd64","bootID":"","containerRuntimeVersion":"containerd://Unknown","kernelVersion":"10.0.17763.194
","kubeProxyVersion":"v1.13.0-alpha.2","kubeletVersion":"v1.13.0-alpha.2","machineID":"3472k8s000","operatingSystem":"windows","osImage":"Windows Server Datacenter","systemUUID":""}}
echo "$winnode" | jq .
#output
parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 2, column 1
@jsturtevant
jsturtevant / get-windows-k8s-logs.ps1
Created January 9, 2019 00:27
Collects windows K8s containers logs on a machine and zips them up
$lockedFiles = "kubelet.err.log", "kubelet.log", "kubeproxy.log", "kubeproxy.err.log", "containerd.err.log", "containerd.log"
$netDebugFiles = "network.txt", "endpoint.txt", "policy.txt", "ip.txt", "ports.txt", "routes.txt", "vfpOutput.txt"
$timeStamp = get-date -format 'yyyyMMdd-hhmmss'
$zipName = "$env:computername-$($timeStamp)_logs.zip"
$paths = get-childitem c:\k\*.log -Exclude $lockedFiles
$paths += $lockedFiles | Foreach-Object { Copy-Item "c:\k\$_" . -Passthru }
$scm = Get-WinEvent -FilterHashtable @{logname='System';ProviderName='Service Control Manager'} | Where-Object { $_.Message -Like "*docker*" -or $_.Message -Like "*kub*" } | Select-Object -Property TimeCreated, Id, LevelDisplayName, Message
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness
name: dns-liveness-windows
spec:
containers:
- name: dns-liveness
image: mcr.microsoft.com/windows/servercore:1809