Kubernetes Linux Pod中,当通过kubectl删除一个Pod或rolling update一个Pod时, 每Terminating的Pod中的每个Container中PID为1的进程会收到SIGTERM信号, 通知进程进行资源回收并准备退出. 如果在Pod spec.terminationGracePeriodSeconds指定的时间周期内进程没有退出, 则Kubernetes接着会发出SIGKILL信号KILL这个进程。 通过 kubectl delete –force –grace-period=0 … 的效果等同于直接发SIGKILL信号. 但SIGTERM和SIGKILL方式在Windows Container中并不工作, 目前Windows Container的表现是接收到Terminating指令5秒后直接终止。。。 参见:https://v1-18.docs.kubernetes.io/docs/setup/production-environment/windows/intro-windows-in-kubernetes/#v1-pod V1.Pod.terminationGracePeriodSeconds – this is not fully implemented in Docker on Windows, see: reference. The behavior today is that the ENTRYPOINT process is sent CTRL_SHUTDOWN_EVENT, then Windows waits 5 seconds by default, and finally shuts down …
Tag: container
Add File Extension to Windows IIS Container during image build
Let’s say: we need to add json file extension to the containerized IIS. Dockerfile: FROM {imageRegistry}/mcr.microsoft.com/dotnet/framework/aspnet:4.8-20200114-windowsservercore-ltsc2019 COPY . /inetpub/wwwroot WORKDIR /inetpub/wwwroot RUN C:\windows\system32\inetsrv\appcmd.exe set config "Default Web Site" -section:system.webServer/security/requestFiltering /+"fileExtensions.[fileExtension='json',allowed='True']" ENV ASPNETCORE_URLS http://+:80 EXPOSE 80/tcp An error occurs during build docker image: Step 1/6 : FROM repo.q1lan.k8s:9999/mcr.microsoft.com/dotnet/framework/aspnet:4.8-20200114-windowsservercore-ltsc2019 ---> a5bc996f06b3 Step 2/6 : COPY . /inetpub/wwwroot …
Run Windows container with Hyper-V isolation mode in Kubernetes
Windows Container有两种隔离运行模式Hyper-V和Process, 参见:Isolation Modes 两种模式下的host的OS版本与containter的OS版本存在兼容性又不相同,参见:Windows container version compatibility 很明显Hyper-V模式的兼容性要比Process模式要好,向下兼容,也就是高版本的host OS可以运行低版本的container OS, 反之不行; 而Process模式下Windows Server中则要求host OS与container OS的版本完全相同, Windows 10中则不支持Process模式. 某一天,我想在Kubernetes Windows 节点中以Hyper-V模式运行Container, 于是乎发现1.17的文档中写道: Note: In this document, when we talk about Windows containers we mean Windows containers with process isolation. Windows containers with Hyper-V isolation is planned for a future release. 不甘心又google了一下,发现: 1. 有人提了bug, 已经被修复了: https://github.com/kubernetes/kubernetes/issues/58750 2. 代码也merge了: …