如何在Azure Kubernetes服务上为Windows Server容器的主机节点指定Windows版本?

时间:2019-06-03 05:59:45

标签: azure-aks windows-container windows-server-container

我正在遵循有关如何在Azure Kubernetes服务上创建Windows Server容器的指南。 Link

我拉了本指南中演示的示例图像(mcr.microsoft.com/dotnet/framework/samples:aspnetapp),对其进行了标记,并将其上传到Azure容器注册表。 在将应用程序部署到Kubernetes时,吊舱无法从容器注册表中提取映像。我还尝试过使用来自Docker集线器的原始映像,从而导致同样的问题。

下面是kubectl describe命令在其中一个Pod上的输出

Name:               hello-world-56c76d8549-7248k
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               aksnpwin000000/10.240.0.35
Start Time:         Sat, 01 Jun 2019 19:33:21 +0530
Labels:             app=hello-world
                    pod-template-hash=56c76d8549
Annotations:        <none>
Status:             Pending
IP:                 10.240.0.47
Controlled By:      ReplicaSet/hello-world-56c76d8549
Containers:
  hello-world:
    Container ID:
    Image:          pocaspnetcoreweb.azurecr.io/pocaspnetcoreweb:v1
    Image ID:
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Limits:
      cpu:     1
      memory:  800m
    Requests:
      cpu:        100m
      memory:     300m
    Environment:  <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-m647n (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-m647n:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-m647n
    Optional:    false
QoS Class:       Burstable
Node-Selectors:  beta.kubernetes.io/os=windows
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason          Age                   From                     Message
  ----     ------          ----                  ----                     -------
  Normal   Scheduled       18m                   default-scheduler        Successfully assigned default/hello-world-56c76d8549-7248k to aksnpwin000000
  Normal   SandboxChanged  17m                   kubelet, aksnpwin000000  Pod sandbox changed, it will be killed and re-created.
  Warning  Failed          17m (x3 over 17m)     kubelet, aksnpwin000000  Failed to pull image "pocaspnetcoreweb.azurecr.io/pocaspnetcoreweb:v1": [rpc error: code = Unknown desc = a Windows version 10.0.18362-based image is incompatible with a 10.0.17763 host, rpc error: code = Unknown desc = Error response from daemon: Get https://pocaspnetcoreweb.azurecr.io/v2/pocaspnetcoreweb/manifests/v1: unauthorized: authentication required]
  Normal   Pulling         16m (x4 over 17m)     kubelet, aksnpwin000000  Pulling image "pocaspnetcoreweb.azurecr.io/pocaspnetcoreweb:v1"
  Warning  Failed          2m55s (x65 over 17m)  kubelet, aksnpwin000000  Error: ImagePullBackOff

“事件”部分有一个带有消息的事件

Warning  Failed          17m (x3 over 17m)     kubelet, aksnpwin000000  Failed to pull image "pocaspnetcoreweb.azurecr.io/pocaspnetcoreweb:v1": [rpc error: code = Unknown desc = a Windows version 10.0.18362-based image is incompatible with a 10.0.17763 host, rpc error: code = Unknown desc = Error response from daemon: Get https://pocaspnetcoreweb.azurecr.io/v2/pocaspnetcoreweb/manifests/v1: unauthorized: authentication required]

该消息对我来说似乎很清楚,因为它抱怨容器和主机之间的Windows版本不匹配。

我的kubernetes部署文件

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-world
  labels:
    app: hello-world
spec:
  replicas: 1
  template:
    metadata:
      name: hello-world
      labels:
        app: hello-world
    spec:
      nodeSelector:
        "beta.kubernetes.io/os": windows
      containers:
      - name: hello-world
        image: pocaspnetcoreweb.azurecr.io/pocaspnetcoreweb:v1
        resources:
          limits:
            cpu: 1
            memory: 800m
          requests:
            cpu: .1
            memory: 300m
        ports:
          - containerPort: 80
      imagePullSecrets:
      - name: acr-auth
  selector:
    matchLabels:
      app: hello-world
---
apiVersion: v1
kind: Service
metadata:
  name: hello-world
spec:
  type: LoadBalancer
  ports:
  - protocol: TCP
    port: 80
  selector:
    app: sample

如何确保容器和主机之间的Windows版本匹配?有什么方法可以指定将在主机上使用的Windows版本?

1 个答案:

答案 0 :(得分:1)

不,您不能这样做(如果您考虑了-没有意义,如何动态更改主机上的Windows版本?)。相反,必须找到具有适当基本主机Windows版本的映像(或构建映像)。

https://hub.docker.com/_/microsoft-dotnet-framework-samples/