gpt4 book ai didi

kubernetes - 带有 Helm chart 的蓝绿色部署

转载 作者:行者123 更新时间:2023-12-02 11:28:33 25 4
gpt4 key购买 nike

我们可以使用“ Helm 图表”来部署应用程序

helm install --name the-release  helm/the-service-helm --namespace myns

然后,我们使用以下方式对部署进行“滚动升级”:
helm upgrade --recreate-pods the-release helm/the-service-helm --namespace myns

有没有一种方法可以使用“ Helm 图”来实现 和“蓝色/绿色” 部署?

最佳答案

让我们从定义开始
由于存在many deployment strategies,我们从定义开始。
根据Martin Flower:

The blue-green deployment approach does this by ensuring you have two production environments, as identical as possible. At any time one of them, let's say blue for the example, is live. As you prepare a new release of your software you do your final stage of testing in the green environment. Once the software is working in the green environment, you switch the router so that all incoming requests go to the green environment - the blue one is now idle.


不建议在Helm中使用 Blue/Green。但是有解决方法
  • 根据helm issue #3518,建议不要将Helm用于blue/greencanary部署。
  • 至少有3种基于Helm的解决方案,请参见下文
  • 但是,有一种针对这种情况的Helm图表。

  • Helm 本身(TL; DR:不推荐)
    Helm 本身不适合这种情况。看到他们的解释:

    direct support for blue / green deployment pattern in helm · Issue #3518 · helm/helm


    Helm works more in the sense of a traditional package manager, upgrading charts from one version to the next in a graceful manner (thanks to pod liveness/readiness probes and deployment update strategies), much like how one expects something like apt upgrade to work. Blue/green deployments are a very different beast compared to the package manager style of upgrade workflows; blue/green sits at a level higher in the toolchain because the use cases around these deployments require step-in/step-out policies, gradual traffic migrations and rollbacks. Because of that, we decided that blue/green deployments are something out of scope for Helm, though a tool that utilizes Helm under the covers (or something parallel like istio) could more than likely be able to handle that use case.


    其他基于 Helm的解决方案
    至少有三种基于 Helm的解决方案,描述和比较了 here:
  • Shipper
  • Istio
  • Flagger

  • Booking.com的 Shipper
    bookingcom/shipper:使用Helm的Kubernetes本地多集群金丝雀或蓝绿色卷展栏

    It does this by relying on Helm, and using Helm Charts as the unit of configuration deployment. Shipper's Application object provides an interface for specifying values to a Chart just like the helm command line tool.Shipper consumes Charts directly from a Chart repository like ChartMuseum, and installs objects into clusters itself. This has the nice property that regular Kubernetes authentication and RBAC controls can be used to manage access to Shipper APIs.


    使用Helm的Kubernetes原生多集群金丝雀或蓝绿色产品
    Istio
    您可以尝试一些 like this:
    kubectl create -f <(istioctl kube-inject -f cowsay-v1.yaml) # deploy v1
    kubectl create -f <(istioctl kube-inject -f cowsay-v2.yaml) # deploy v1
    Flagger
    Flagger小组撰写了指南: Blue/Green Deployments - Flagger
    本指南向您展示如何使用Flagger和Kubernetes自动执行蓝色/绿色部署
    您可以尝试 Helm
    另外,按照 Kamol Hasan的建议,您可以尝试以下图表: puneetsaraswat/HelmCharts/blue-green
    blue.yml sample
    {{ if .Values.blue.enabled }}
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
    name: {{ template "blue-green.fullname" . }}-blue
    labels:
    release: {{ .Release.Name }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    app: {{ template "blue-green.name" . }}
    spec:
    replicas: {{ .Values.replicaCount }}
    template:
    metadata:
    labels:
    app: {{ template "blue-green.name" . }}
    release: {{ .Release.Name }}
    slot: blue
    spec:
    containers:
    - name: {{ template "blue-green.name" . }}-blue
    image: nginx:stable
    imagePullPolicy: IfNotPresent
    ports:
    - name: http
    containerPort: 80
    protocol: TCP
    # This (and the volumes section below) mount the config map as a volume.
    volumeMounts:
    - mountPath: /usr/share/nginx/html
    name: wwwdata-volume
    volumes:
    - name: wwwdata-volume
    configMap:
    name: {{ template "blue-green.fullname" . }}
    {{ end }}
    中等博客文章: Blue/Green Deployments using Helm Charts

    关于kubernetes - 带有 Helm chart 的蓝绿色部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57863647/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com