<p><strong>Context:</strong>
I am using Linux and Windows nodes in a Kubernetes cluster. Depending on the OS where a pod is deployed, I need to use a specific image.</p>
<p><strong>Question:</strong>
Is there a way to express this in a Kubernetes yaml files: &quot;if this label exist on the pod you are deploying, then use this image. Otherwise, use this other image.&quot;.</p>
<p><strong>Other options considered:</strong></p>
<ul>
<li>Have two copies of the same yaml but each configured with a OS-specific image with a nodeSelector in each yaml targeting either Linux or Windows nodes. This is not ideal as we need to keep both yaml files in sync if we need to change something in one.</li>
<li>Helm charts. I guess that would solve the issue of having to maintain two similar yaml files by using templates. But still, it seems overkill for what I need if there is an easy way to do it in yaml.</li>
</ul>

<p>The proper way to do this is to build &quot;multi-arch&quot; images, e.g. so that your container image contains binaries for multiple architectures. See e.g. <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/building-windows-multi-arch-images" rel="nofollow noreferrer">Building Windows Server multi-arch images</a> and <a href="https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/" rel="nofollow noreferrer">Docker: Multi-arch build and images, the simple way</a> - but it still seem to be an &quot;experimental feature&quot;. A drawback with this is that the images will end up to be bigger, this is not so welcome if you want good elasticity (e.g. be able to quickly scale up with more pods) - this is especially true for windows images.</p>
<p>Alternatively, you need to use a separate <code>Deployment</code> for each architecture and use different <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/" rel="nofollow noreferrer">Taints and Tolerations</a> on the nodes and the pods.</p>
<p>You can keep this relatively clean by using <a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/" rel="nofollow noreferrer">kubectl kustomize</a> and only override a small part of the manifests.</p>
