在金丝雀部署策略中,将特定用户重定向到具有新版本的 pod

In canary deployment strategy, redirecting particular user to pod which has new version

我是 kubernetes 的新手,只是在 k8s 上做很少的研发。 正在检查不同的部署策略,如滚动更新、重新创建、蓝绿和金丝雀。如果我是正确的,金丝雀部署背后的想法是向一组用户推出新版本。在这里我的问题让我的团队有开发人员和测试团队。每当测试团队尝试访问应用程序时,它应该重定向到新版本的应用程序,这可能吗?或者 Canary 仅用于同时具有 2 个版本的应用程序 运行 和一项服务?

是的,如果您将 Kubernetes 集群与 isito 一起使用,您可以管理金丝雀部署,将特定用户流量移动到特定版本。

基于粘性session您还可以管理特定用户每次获得新版本。

有很多方法可以处理这种情况,例如,您可以通过注入一些 header 来实现。

针对特定用户传递一些特定的 header 并基于该路由将流量从 isito 路由到新版本。

金丝雀部署

if am correct the idea behind canary deployment is rolling out new version to set of users. here my questions lets my team has developers and testing team.

术语金丝雀部署 没有我所知道的精确定义。但这通常意味着您部署了一个新版本的应用程序,并且只让一小部分流量访问了新版本,例如5% 或 15% - 然后使用 Canary Analyzer(例如 Kayenta)来分析新旧版本的指标 - 然后执行 自动决定将所有流量路由到新版本或回滚部署。

这样做的好处是自动化程度高 - 部署后无需人工监控指标。如果新版本中出现错误,则只有一小部分客户会受到影响。但这也具有挑战性,因为您需要一定的流量才能获得良好的统计基础。

基于用户的路由属性

whenever testing team try to access the application it should redirect to new version of application, is it possible?

你在这里想要的是根据用户的 属性 将流量路由到特定版本,例如来自身份验证令牌。

您需要一个 服务网格,例如Istio and base your authentication on JWT e.g. OpenID Connect 在 Kubernetes 中执行此操作。

Istio documentation 中,您需要为您的应用创建 RequestAuthenticationAuthorizationPolicy

apiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:
  name: httpbin
  namespace: foo
spec:
  selector:
    matchLabels:
      app: httpbin
  jwtRules:
  - issuer: "issuer-foo"
  - issuer: "issuer-bar"
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
  name: httpbin
  namespace: foo
spec:
  selector:
    matchLabels:
      app: httpbin
 rules:
 - from:
   - source:
       requestPrincipals: ["issuer-foo/*"]
   to:
     hosts: ["example.com"]
 - from:
   - source:
       requestPrincipals: ["issuer-bar/*"]
   to:
     hosts: ["another-host.com"]

文档的 JWT and list-typed claims 部分描述了如何为特定用户名 (sub) 或具有 claims 的 属性 / 用户组指定规则。例如

    when:
    - key: request.auth.claims[groups]
      values: ["test-group"]