Last active
April 19, 2024 18:57
-
-
Save jsturtevant/d1f91840442bcc7862955160ca6da630 to your computer and use it in GitHub Desktop.
cri pod specs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "busybox" | |
}, | |
"image":{ | |
"image": "mcr.microsoft.com/windows/nanoserver:1809" | |
}, | |
"command": [ | |
"ping", | |
"-t", | |
"127.0.0.1" | |
], | |
"annotations": { | |
"microsoft.com/hostprocess-inherit-user": "true", | |
"microsoft.com/hostprocess-container": "true" | |
}, | |
"windows": { | |
"security_context": { | |
"host_process": true | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "pause" | |
}, | |
"image":{ | |
"image": "docker.io/jsturtevant/qs-wasm-slight:latest" | |
}, | |
"command": [], | |
"args": [], | |
"log_path": "demo.log" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "busybox" | |
}, | |
"image":{ | |
//"image": "mcr.microsoft.com/dotnet/framework/samples:aspnetapp" | |
"image": "registry.k8s.io/pause:3.6" | |
}, | |
"command": [], | |
"args": [] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS C:\Users\azureuser> ./crictl exec $CONTAINER_ID powershell.exe -command Invoke-WebRequest www.bing.com -OutFile C:\\bing.config | |
time="2021-04-28T23:16:57Z" level=fatal msg="execing command in container: Internal error occurred: error executing command in container: failed to exec in container: failed to create exec \"53e2be000297672d84f8f74474e6c655f60e49aa98e1e06ab186c851622deba0\": exec: '' in task: '1df9504c56e8e978241dd3ed7a38c2f0495f88c2ede1e9a5a07ebd9deaa52c63' must be running to create ad | |
ditional execs: failed precondition" | |
PS C:\Users\azureuser> ./crictl ps | |
CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID | |
1df9504c56e8e mcr.microsoft.com/dotnet/framework/samples:aspnetapp 32 seconds ago Running busybox 0 11e619b772440 | |
PS C:\Users\azureuser> ./crictl exec $CONTAINER_ID powershell.exe -command Invoke-WebRequest www.bing.com -OutFile C:\\bing.config | |
time="2021-04-28T23:17:30Z" level=fatal msg="execing command in container: rpc error: code = Unknown desc = container is in CONTAINER_EXITED state" | |
PS C:\Users\azureuser> ./crictl ps | |
CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID | |
PS C:\Users\azureuser> ./crictl stop $CONTAINER_ID | |
1df9504c56e8e978241dd3ed7a38c2f0495f88c2ede1e9a5a07ebd9deaa52c63 | |
PS C:\Users\azureuser> ./crictl rm 1df9504c56e8e978241dd3ed7a38c2f0495f88c2ede1e9a5a07ebd9deaa52c63 | |
1df9504c56e8e978241dd3ed7a38c2f0495f88c2ede1e9a5a07ebd9deaa52c63 | |
PS C:\Users\azureuser> $CONTAINER_ID=(./crictl create $POD_ID .\container.json .\pod.json) | |
PS C:\Users\azureuser> ./crictl start $CONTAINER_ID | |
95987dbe2ba739de704152efebcb188303f0d64792a177da39b87798c3fe5791 | |
PS C:\Users\azureuser> ./crictl exec $CONTAINER_ID powershell.exe -command Invoke-WebRequest www.bing.com -OutFile C:\\bing.config | |
PS C:\Users\azureuser> ./crictl ps | |
CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID | |
95987dbe2ba73 mcr.microsoft.com/dotnet/framework/samples:aspnetapp 29 seconds ago Running busybox 0 11e619b772440 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "sandbox-hp", | |
"namespace": "default", | |
"attempt": 1, | |
"uid": "alskasdfasdf" | |
}, | |
"log_directory": "c:/tmp" | |
"annotations": { | |
"microsoft.com/hostprocess-inherit-user": "true", | |
"microsoft.com/hostprocess-container": "true" | |
}, | |
"windows": { | |
"security_context": { | |
"host_process": true | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "sandbox", | |
"namespace": "default", | |
"attempt": 1, | |
"uid": "alskdjfwn213kljsd" | |
}, | |
"log_directory": "c:/tmp" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# update to latest version | |
curl.exe -LO https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.25.0/crictl-v1.25.0-windows-amd64.tar.gz | |
tar xvf crictl-v1.25.0-windows-amd64.tar.gz | |
@" | |
runtime-endpoint: npipe://./pipe/containerd-containerd | |
image-endpoint: npipe://./pipe/containerd-containerd | |
timeout: 10 | |
#debug: true | |
"@ | Set-Content "crictl.yaml" -Force | |
# pull the image | |
./crictl pull mcr.microsoft.com/dotnet/framework/samples:aspnetapp | |
# double check these are the latest pod jsons files | |
curl.exe -LO https://gist.githubusercontent.com/jsturtevant/d1f91840442bcc7862955160ca6da630/raw/e4cb9cb9693612ac96dbd892fa80000a56be0d4b/pod.json | |
curl.exe -LO https://gist.githubusercontent.com/jsturtevant/d1f91840442bcc7862955160ca6da630/raw/e4cb9cb9693612ac96dbd892fa80000a56be0d4b/container.json | |
$POD_ID=(./crictl runp .\pod.json) | |
$CONTAINER_ID=(./crictl create $POD_ID .\container.json .\pod.json) | |
./crictl start $CONTAINER_ID | |
./crictl exec $CONTAINER_ID powershell.exe -command Invoke-WebRequest www.bing.com -OutFile C:\\bing.config | |
# list all containers and pods (doesn't show sandbox container) | |
.\crictl.exe ps -a | |
.\crictl.exe pods | |
# remove pod (use -a to remove all pods) | |
.\crictl.exe rmp $POD_ID | |
#linux | |
curl -LO https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.25.0/crictl-v1.25.0-linux-amd64.tar.gz | |
tar xvf crictl-v1.25.0-linux-amd64.tar.gz | |
# hostprocess pod | |
$POD_ID=(./crictl runp .\pod-hp.json) | |
$CONTAINER_ID=(./crictl create $POD_ID .\container-hp.json .\pod-hp.json) | |
./crictl start $CONTAINER_ID | |
if you want to run hostprocess containers you need to run it as a service: | |
.\containerd.exe -l debug --log-file c:\ctnd.log --register-service -c C:\Users\jstur\projects\containerd\bin\config.toml | |
Get-Content .\ctnd.log -Tail 10 -Wait | |
can also use https://github.com/kubernetes-sigs/sig-windows-tools/tree/master/hostprocess/eventflow-logger | |
by running the program `dotnet run -- eventFlowConfig.json` | |
you can uninstall it via: | |
.\containerd.exe --unregister-service | |
debug the service using | |
``` | |
get-process containerd | |
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName | |
193 15 32204 35660 0.44 16572 0 containerd | |
dlv attach 16572 --headless --listen=127.0.0.1:56196 --api-version=2 --accept-multiclient | |
``` | |
#### wasm | |
crictl.exe runp -r slight .\pod.json | |
crictl.exe create 3a7 .\container-wasm.json .\pod.json | |
/crictl start 91 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment