How to deploy a Windows container on Google Kubernetes Engine
source link: https://chinagdg.org/2019/09/how-to-deploy-a-windows-container-on-google-kubernetes-engine/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to deploy a Windows container on Google Kubernetes Engine
Source: How to deploy a Windows container on Google Kubernetes Engine from Google Cloud
Many people who run Windows containers want to use a container management platform like Kubernetes for resiliency and scalability. In a previous post, we showed you how to run an IIS site inside a Windows container deployed to Windows Server 2019 running on Compute Engine. That’s a good start, but you can now also run Windows containers on Google Kubernetes Engine (GKE).
Support for Windows containers in Kubernetes was announced earlier in the year with version 1.14, followed by GKE announcement on the same. You can sign up for early access and start testing out Windows containers on GKE.
In this blog post, let’s look at how to deploy that same Windows container to GKE.
1. Push your container image to Container Registry
In the previous post, we created a container image locally. The first step is to push that image to Container Registry, so that you can later use it in your Kubernetes deployment.
To push images from a Windows VM to Container Registry, you need to:
- Ensure that the Container Registry API is enabled in your project.
- Configure Docker to point to Container Registry. This is explained in more detail here but it is usually done via the gcloud auth configure-docker command.
- Make sure that the VM has storage read/write access scope (storage-rw), as explained here.
Once you have the right setup, it’s just a regular Docker push:
2. Create a Kubernetes cluster with Windows nodes
Creating a Kubernetes cluster in GKE with Windows nodes happens in two steps:
-
Create a GKE cluster with version 1.14 or higher, with IP alias enabled and one Linux node.
-
Add a Windows node pool to the GKE cluster.
Here’s the command to create a GKE cluster with one Linux node and IP aliasing:
Once you have the basic GKE cluster, you can go ahead and add a Windows pool for Windows nodes to it:
Windows containers are resource intensive, so we chose n1-standard-2 as machine type. We’re also disabling automatic node upgrades. Windows container versions need to be compatible with the node OS version. To avoid unexpected workload disruption, it is recommended that you disable node auto-upgrade for Windows node pools.
For Windows Server containers in GKE, you’re already licensed for underlying Windows host VMs—containers need no additional licensing.
Now, your GKE cluster is ready and contains one Linux node and three Windows nodes:
3. Run your Windows container as a pod on GKE
Now you’re ready to run your Windows container as a pod on GKE. Create an iis-site-windows.yaml
file to describe your Kubernetes deployment:
Note that you’re creating two pods with the image you pushed earlier to Container Registry. You’re also making sure that the pods are scheduled onto Windows nodes with the nodeSelector tag.
Create the deployment:
After a few minutes, you should see that the deployment was created and any running pods:
4. Create a Kubernetes service
To make pods accessible to the outside world, you need to create a Kubernetes service of type “LoadBalancer”:
In a few minutes, you should see a new service with an external IP:
And if you go to that external IP, you will see your app:
This is very similar to the previous deployment to Compute Engine, with the big difference that Kubernetes is now managing the pods. If something goes wrong with the pod or one of its nodes, Kubernetes recreates and reschedules the pod for you—great for resiliency.
Similarly, scaling pods is a single command in Kubernetes:
If you want to try out these steps on your own, there’s also a codelab on this topic:
And there you have it—how to run Windows containers on GKE. If you want to try out Windows Containers on GKE, sign up to get early access.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK