Skip to content

Instantly share code, notes, and snippets.

@christian-korneck
Forked from jsturtevant/container-hp.json
Created August 21, 2021 23:56
Show Gist options
  • Save christian-korneck/c5191b4bdba9e871b1b4824e57c2b050 to your computer and use it in GitHub Desktop.
Save christian-korneck/c5191b4bdba9e871b1b4824e57c2b050 to your computer and use it in GitHub Desktop.
cri pod specs
{
"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"
}
}
{
"metadata": {
"name": "busybox"
},
"image":{
"image": "mcr.microsoft.com/dotnet/framework/samples:aspnetapp"
},
"command": [],
"args": []
}
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
{
"metadata": {
"name": "sandbox-hp",
"namespace": "default",
"attempt": 1
},
"logDirectory": "/tmp",
"annotations": {
"microsoft.com/hostprocess-inherit-user": "true",
"microsoft.com/hostprocess-container": "true"
},
"windows": {
"security_context": {
"host_process": true
}
}
}
{
"metadata": {
"name": "sandbox",
"namespace": "default",
"attempt": 1
},
"logDirectory": "/tmp"
}
curl.exe -LO https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.21.0/crictl-v1.21.0-windows-amd64.tar.gz
tar xvf crictl-v1.21.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
./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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment