【问题标题】:Kubernetes : How to attain 0 downtimeKubernetes:如何实现 0 停机时间
【发布时间】:2021-05-29 18:08:26
【问题描述】:

每个 CPU 运行 2 个 pod:0.2 Core 和 Mi:1 Gi 我的节点限制为 0.4 Core 和 2 Gi。我无法增加节点限制。

为了实现零停机,我已经完成了以下配置 -

apiVersion: apps/v1
kind: Deployment
metadata:
  name: abc-deployment
spec:
  selector:
    matchLabels:
      app: abc
  replicas: 2
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 2
      maxUnavailable: 0
  template:
    metadata:
      labels:
        app: abc
        collect_logs_with_filebeat: "true"
      annotations:
        sidecar.istio.io/rewriteAppHTTPProbers: "false"
    spec:
      containers:
      - name: abc
        image: abc-repository:latest
        ports:
        - containerPort: 8087
        readinessProbe:
          httpGet:
            path: /healthcheck
            port: 8087
          initialDelaySeconds: 540
          timeoutSeconds: 10
          periodSeconds: 10
          failureThreshold: 20
          successThreshold: 1
        imagePullPolicy: Always
        resources:
          limits:
            cpu: 0.2
            memory: 1000Mi
          requests:
            cpu: 0.2
            memory: 1000Mi 
            

在新的构建部署中,在一个新节点上创建了两个新 pod(因为 node1 没有足够的 内存和 cpu 以容纳新的 pod)说 node2。一旦新容器处于运行状态,这些新创建的 node2 pod。旧 pod(在 node1 上运行) 被销毁,现在 node1 有一些可用空间和内存。

现在我面临的问题是,由于 node1 有空闲内存和 cpu,Kubernetes 正在销毁新创建的 pod(在 node2 上运行) 然后在 node1 上创建 pod 并在其上启动应用程序容器,这会导致停机。

所以,基本上在我的情况下,即使在使用滚动更新策略和运行状况检查点之后,我也无法实现零停机时间。

请在这里帮忙!

【问题讨论】:

    标签: kubernetes


    【解决方案1】:

    您可以查看Pod Disruption Budget 的概念,该概念主要用于实现应用程序的零停机时间。

    您还可以阅读related answer of mine,其中展示了如何使用 PDB 实现应用程序零停机时间的示例。

    【讨论】:

    • 非常感谢,克里希纳。它对我有用。
    • 太棒了,很高兴能帮上忙,@Sakshi!
    猜你喜欢
    • 2017-12-18
    • 1970-01-01
    • 1970-01-01
    • 2021-08-24
    • 2019-04-02
    • 1970-01-01
    • 1970-01-01
    • 2022-08-22
    • 2021-12-12
    相关资源
    最近更新 更多