Absolom
Absolom

Reputation: 1389

Select image based on OS in yaml

Context: 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.

Question: Is there a way to express this in a Kubernetes yaml files: "if this label exist on the pod you are deploying, then use this image. Otherwise, use this other image.".

Other options considered:

Upvotes: 1

Views: 575

Answers (1)

Jonas
Jonas

Reputation: 128925

The proper way to do this is to build "multi-arch" images, e.g. so that your container image contains binaries for multiple architectures. See e.g. Building Windows Server multi-arch images and Docker: Multi-arch build and images, the simple way - but it still seem to be an "experimental feature". 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.

Alternatively, you need to use a separate Deployment for each architecture and use different Taints and Tolerations on the nodes and the pods.

You can keep this relatively clean by using kubectl kustomize and only override a small part of the manifests.

Upvotes: 2

Related Questions