Run Windows Containers on VMware Enterprise PKS

September 4, 2019 Xiao Gao

The adoption of containers is exploding because their lightweight and portable nature enables more reliable software delivery and accelerated software development and testing. Windows applications in containers have not enjoyed the same explosive growth as Linux applications, mainly because of lack of production ready Windows container orchestrator and management. Analysts estimate that 85 percent of enterprise line of business applications are based on .NET and Java. A significant percentage of that 85 percent are workloads that are executing on soon End of Support Windows Server 2008 and Windows Server 2008 R2.

Kubernetes 1.14 changed everything. Starting with the 1.14 release, Kubernetes now includes official support for Windows containers. Windows developers and platform operators— you can now develop Windows applications in containers for portability and then centralize management alongside Linux-based applications in Kubernetes.

VMware Enterprise PKS 1.5 includes Windows container support as a beta feature, providing a turnkey solution to easily provision Windows-based workers in a Kubernetes cluster. In this blog, we will use blogengine, a popular open-source project based on the ASP.NET, to demonstrate how you can modernize a traditional Windows application in Windows containers. How you can then use VMware Enterprise PKS 1.5 to manage the life cycle of the newly containerized app using Kubernetes. Details of this app can be found here:  

Windows Containers

Microsoft has been working since 2014 in making containerizing Windows apps relatively straightforward. Artifacts to build and generate Docker images are often integrated into common Integrated Development Environments (IDE) from Microsoft. Visual Studio, for example, has built-in support for Docker container automation. In order to containerize the application using Visual Studio, all you have to do is right-click the project and select Add->Container Orchestrator Support.  

Visual Studio then adds the Dockerfile, compose files, and a Docker project to the solution. It also inspects the project to determine the proper base image to use for your project.

Here is the Dockerfile generated by Visual Studio for our sample app:

ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish}

With Dockerfile in place, you can use Visual Studio to build the Docker image locally on your Windows 2019 development server and test for functionality. Visual Studio automatically links the .NET debugger and leverages docker-compose to set the environment setting for Internet Information Services (IIS). Once the sample app works on a local development environment, you need to merge the actions defined in docker compose to a single Dockerfile:

ARG source
LABEL maintainer=""
SHELL ["powershell", "-command"]
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .
RUN "c:/Windows/System32/inetsrv/appcmd.exe set config -section:system.webServer/security/authentication/anonymousAuthentication /userName: /commit:apphost"
RUN c:\windows\system32\inetsrv\appcmd.exe set AppPool DefaultAppPool '-processModel.identityType:LocalSystem' /commit:apphost
ENTRYPOINT [ "cmd", "/c", "C:\\ServiceMonitor.exe w3svc" ]

You can then push the final image to the Harbor container registry to trigger additional automated CI pipeline events for testing.

Kubernetes Cluster

To set up the Windows-based Kubernetes cluster, check out the beta documentation. At a high level, you start by building a Windows stemcell for VMware vSphere and upload to the stemcell library. Windows 2019 Server is the only currently supported operating system from the upstream kubernetes community.

Windows Server Container (WSC) mode is the Windows implementation of the shared kernel container runtime. For container applications to run in WSC mode, the kernel of the Windows container operating system must match the Windows container host operating system. Windows container applications share the common operating system kernel provided by the host; isolation is provided using namespace.

The Windows beta program is designed to allow Windows platform operators and developers to plan out how an application should behave when refactored or lifted and shifted to Kubernetes. VMware does not recommend adding Windows nodes to an existing VMware Enterprise PKS deployment; a dedicated instance of the Ops Manager is required for the beta. Once you deploy the new Ops Manager, you configure deployment plans for enabling windows worker node; up to 3 plans are supported for the beta. Within each plan, you can have up to 5 Kubernetes Linux-based master nodes, 1 Linux-based worker node, and the remaining nodes can be Windows Server 2019. All nodes will use flannel for container networking. VMware Enterprise PKS will fully manage the entire Kubernetes cluster IP subnet allocation.

Deploy to Kubernetes

After your Docker image is built and validated through your CI pipeline, you are ready to deploy your app using Kubernetes. Here is a sample Kubernetes YAML file referencing the latest blog engine image pushed to the Harbor image registry.

apiVersion: apps/v1
kind: Deployment
  name: blog-2019
	app: blog-2019
  replicas: 1
  	name: blog-2019
    	  app: blog-2019
	- name: blog
        	       cpu: 1
        	       memory: 800m
        	        cpu: .1
        	        memory: 300m
      	   - containerPort: 80
    	"": windows
  	app: blog-2019
apiVersion: v1
kind: Service
  name: blog
  type: ClusterIP
  - protocol: TCP
	port: 80
	app: blog-2019
apiVersion: extensions/v1beta1
kind: Ingress
  annotations: nginx
  name: example
  namespace: default
    - host:
      	- backend:
          	      serviceName: blog
      servicePort: 80
        	   path: /

If you want to create a blog engine deployment with one replica at the outset, you can run the following:

Kubectl apply -f blog-2019.yaml

Once the app is deployed, you can scale up or down based on the application SLA.

Kubectl scale deployment blog-2019 --replicas==x

If you have a newer version of the blog engine app, you can leverage Kubernetes to perform and upgrade or rollback.  

Call to Action

You can now develop Windows applications in containers for portability and then centralize their management alongside Linux-based applications in Kubernetes. Instead of handcrafting each Windows app, you can take advantage of Kubernetes to scale up and down, perform upgrades and rollback. The journey to cloud native for a Windows app has never been simpler with VMware Enterprise PKS 1.5. I encourage everyone to sign up for the beta program today (

About the Author

Xiao Hu Gao is a Technical Marketing Manager at VMware CNABU. He enjoys speaking to customers and partners about the benefits of running Kubernetes on top of VMware technologies. Xiao has a background in DevOps, Data Center Design, and Software Defined Networking. Xiao is CCIE (Emeritus) and holds few patents in the areas of Security and Cloud.

More Content by Xiao Gao
Customizing Plug-in PodSpecs in Sonobuoy
Customizing Plug-in PodSpecs in Sonobuoy

With the release of Sonobuoy 0.15.2, we’ve introduced a new option that allows you to customize the Kuberne...

Introducing Kubernetes Academy Brought to You by VMware—A Free Cloud Native Education Platform
Introducing Kubernetes Academy Brought to You by VMware—A Free Cloud Native Education Platform

Kubernetes Academy provides an accessible learning path to advance your skill set, regardless of where you ...

SpringOne. All online. All free. Sept 2-3.