【问题标题】:Deploy a windows service in azure kubernetes cluster在 Azure Kubernetes 集群中部署 Windows 服务
【发布时间】:2020-06-15 21:26:44
【问题描述】:

我想在 Azure 集群中部署一个 Windows 服务。我已经创建了部署服务的 yaml 文件,但是当我运行 kubectr get pods 时,我得到以下信息,

NAME                                    READY   STATUS             RESTARTS   AGE
windowsservice-deploy-5994764596-jfghj   0/1     ImagePullBackOff   0          39m

我的yaml文件如下,

apiVersion: apps/v1
kind: Deployment
metadata:
  name: windowsservice-deploy
  labels:
    app: windowsservice
spec:
  replicas: 1
  template:
    metadata:
      name: windowsservice
      labels:
        app: windowsservice
    spec:
      containers:
      - name: windowsservice
        image: windowskube.azurecr.io/windowsimage:v1
        imagePullPolicy: IfNotPresent
      restartPolicy: Always
  selector:
    matchLabels:
      app: windowsservice


---

apiVersion: v1
kind: Service
metadata:
  name: windows-service
spec:
  selector:
    app: windowsservice
  ports:
    - port: 80
  type: LoadBalancer

这里是输出 kubectl describe pod windowsservice-deploy-5994764596-jfghj

Name:           windowsservice-deploy-5994764596-jfghj
Namespace:      default
Priority:       0
Node:           aks-nodepool1-41533414-vmss000000/10.240.0.4
Start Time:     Mon, 15 Jun 2020 11:24:18 +0100
Labels:         app=windowsservice
                pod-template-hash=5994764596
Annotations:    <none>
Status:         Pending
IP:             10.244.0.8
IPs:            <none>
Controlled By:  ReplicaSet/windowsservice-deploy-5994764596
Containers:
  workerservice:
    Container ID:
    Image:          windowskube.azurecr.io/windowsimage:v1
    Image ID:
    Port:           <none>
    Host Port:      <none>
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-zvwh8 (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-zvwh8:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-zvwh8
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason   Age                    From                                        Message
  ----     ------   ----                   ----                                        -------
  Warning  Failed   18m (x330 over 93m)    kubelet, aks-nodepool1-41533414-vmss000000  Error: ImagePullBackOff
  Normal   BackOff  3m11s (x395 over 93m)  kubelet, aks-nodepool1-41533414-vmss000000  Back-off pulling image "windowskube.azurecr.io/windowsimage:v1"

这是一个 Windows 服务,我之前没有部署过,我错过了什么吗?

谢谢

【问题讨论】:

  • 分享 kubectl describe pod windowsservice-deploy-5994764596-jfghj 和 kubectl get events 的输出
  • 您使用的是 azure AKS 还是您在 azure 上部署的 kubernetes 集群? Kubernetes 的版本是多少?
  • 谢谢我分享了上面的输出
  • Windows 服务或 linux 图像的这个特定问题是否也会出现同样的错误?您是否关注过任何文档?
  • 这是一个仅适用于 Windows 服务的问题,因为 webapi 或 weapps 工作正常

标签: azure kubernetes windows-services


【解决方案1】:

鉴于 windowskube.azurecr.io/windowsimage:v1 似乎是您的私有 Azure 容器注册表,我认为缺少的部分是为 kubernetes 提供私有注册表的登录凭据。

见:https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/

如前所述,通过执行kubectl describe pod windowsservice-deploy-5994764596-jfghj 并向下滚动到底部以查看Events,您将收到更好的错误消息,描述图像提取失败的原因。

【讨论】:

  • 谢谢我分享了上面的输出
【解决方案2】:

默认情况下,使用可以运行 Linux 容器的节点池创建 AKS 群集。使用az aks nodepool add 命令添加一个额外的节点池,可以在 Linux 节点池旁边运行 Windows Server 容器。

az aks nodepool add \
    --resource-group myResourceGroup \
    --cluster-name myAKSCluster \
    --os-type Windows \
    --name npwin \
    --node-count 1 \
    --kubernetes-version 1.16.9

按照此完整指南here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-15
    • 2019-06-04
    • 2018-06-02
    • 1970-01-01
    • 1970-01-01
    • 2017-03-29
    相关资源
    最近更新 更多