首页 > 解决方案 > Windows 和 linux Kubernetes 集群上的 Windows 容器

问题描述

我对 Kubernetes 世界有点陌生。在我的项目中,我们计划短期使用 windows 容器(.net 完整框架),长期使用 linux 容器(.net 核心)。

我们有一个由基础设施团队提供的 K8 集群,该集群混合了 Linux 和 Windows 节点。我只是想知道我的 windows 容器将如何只部署到 K8 集群中的 windows 节点。它是由 K8 处理还是我需要其他任何东西?

标签: kuberneteswindows-containerkubernetes-cluster

解决方案


以下是Kubernetes Windows 文档中的详细信息。

由于您的集群同时具有 Linux 和 Windows 节点,因此您必须显式设置 nodeSelector 约束才能将 pod 调度到 Windows 节点。您必须将带有标签 beta.kubernetes.io/os 的 nodeSelector 设置为值 windows;请参见以下示例:

apiVersion: v1
kind: Pod
metadata:
  name: iis
labels:
  name: iis
spec:
  containers:
    - name: iis
      image: microsoft/iis:windowsservercore-1709
      ports:
        - containerPort: 80
  nodeSelector:
    "beta.kubernetes.io/os": windows

推荐阅读