【问题标题】:Setting up on ISTIO on EKS cluster using Terraform or Helm使用 Terraform 或 Helm 在 EKS 集群上设置 ISTIO
【发布时间】:2021-06-25 07:48:48
【问题描述】:

我是 Terraform 和 Helm 世界的新手!我需要在 AWS EKS 集群上设置 Istio。我能够使用 Terraform 设置 EKS 集群。我正在考虑通过编写 terraform 模块使用 Terraform 在 EKS 集群上安装 ISTIO。但是,我发现我们可以使用 helm chart 在 eks 之上设置 Istio。

谁能帮我回答我的几个问题:

  1. 我应该使用 Terraform 安装 Istio 吗?如果是,是否有任何可用的 terraform 模块或如何编写?
  2. 我应该使用 Helm Chart 安装 Istio 吗?如果是,它的优缺点是什么?
  3. 我需要编写一个管道来在 EKS 集群上安装 Istio。我应该同时使用 terraform 和 Helm 作为提供程序吗?

非常感谢您的宝贵时间。感谢您的所有帮助!

【问题讨论】:

  • 不幸的是,这个问题几乎完全基于意见,询问“为什么”要做某事。有更好的资源可以让您提出此类问题并获得好的答案。
  • 谢谢@MattSchuchard 你能否分享更好的资源,我可以得到一个好的答案。

标签: kubernetes terraform kubernetes-helm istio amazon-eks


【解决方案1】:

正如@Matt Schuchard 所提到的,这是一个基于意见的问题,这就是为什么我会根据我的理解来回答这个问题。


问题编号 1。

  1. 回答您的问题,Should I install Istio using Terraform?,是的,如果您遵循 Devops 实践,那么您应该将所有内容都写在代码中,所以我建议您这样做。

  2. 根据您问题的第二部分,If yes, Is there any Terraform module available,不,据我所知,目前没有适用于 Terraform 的 Istio 模块,只有一个 helm

  3. 至于第一个问题的最后一部分,How can I write Terraform module? 我建议从 Terraform documentation 开始。还有一个tutorial 用于创建模块。


问题编号 2。

  1. 要回答您的问题,Should I install Istio using Helm Chart?,取决于您的用例,您可以使用 helm 或 istioctl/istio 运算符来回答。
  2. 至于下面的问题,If yes, what are the pros and cons of it? 我不确定当前的 helm chart 是否已准备好生产,根据 Istio documentation, Providing the full configuration in an IstioOperator CR is considered an Istio best practice for production environments,所以据我了解,您应该使用 operator 而不是 helm .另外值得注意的是,舵图没有被多个版本使用,如果在 1.8 版中恢复了活力。

第 3 个问题。

  1. 根据最后一个问题I need to write a pipeline to install Istio on EKS cluster. Should I use a combination of both terraform and Helm as provider?,取决于它可能是 Terraform 和 Helm,但据我所知,使用 Terraform 和 Istio Operator 也可以做到这一点,有一个 example。因此,由您决定走哪条路。

我还建议看看这个 reddit thread。您可能会在此处的 prod 环境中找到一些有用的 cmets,关于使用 Terraform 安装 Istio。

【讨论】:

  • 非常感谢@Jakub 详细回答每一个问题。感谢您的所有帮助。
  • 我很想知道我们在 Terraform 中没有 Istio 提供者,对吧?
  • @SwetaSharma 乐于助人。是的,据我所知,目前没有 istio 提供者。您可以使用 helm 或 operator 使用 terraform 安装它。
  • 谢谢雅库布!感谢与我分享您的知识!
【解决方案2】:

过去几个月我一直在研究这个问题,并想将我的发现添加到@Jakob 的回答中:

首先,对于不同安装方法的优缺点有一个答案,所以我不会说什么: https://istio.io/latest/faq/setup/#install-method-selection 基本上所有这些都可以用 terraform 以某种方式完成。

  1. terraform + istioctl 与 terraform null_resource 提供程序

这基本上是istioctl install -f <file> 命令。您可以使用 null_resource 提供程序创建模板文件和 istictl install 命令。

resource "local_file" "setup_istio_config" {
  content = templatefile("${path.module}/istio-operator.tmpl", {
    enableHoldAppUntilProxyStarts = var.hold_app_until_proxy_starts
  })
  filename = "istio-operator.yaml"
}

resource "null_resource" "install_istio" {
  provisioner "local-exec" {
    command = "istioctl install -f \"istio-operator.yaml\" --kubeconfig ../${var.kubeconfig}"
  }
  depends_on = [local_file.setup_istio_config]
}

优点:

  • 设置非常简单

缺点:

  • 必须以某种方式解决如何使用istioctl upgrade -f <file 进行升级
  • 在处理具有不同 istio 版本的多个集群时,必须安装不同版本的 istioctl
  • 必须在设置时选择正确的 istioctl 版本

我猜你可以以某种方式解决升级过程,但漏洞过程还不够“基础设施即代码”。我没有进一步研究它,因为它似乎不是一个好的做法。

  1. terraform + istio 运算符,带有 terraform null_resource 提供程序和 kubectl 提供程序

类似于 istio operator setup 初始化 operator pod 并使用 istio-operator.yml 为您设置 istio。

resource "null_resource" "init_operator" {
  provisioner "local-exec" {
    command = "istioctl operator init --kubeconfig ../${var.kubeconfig}"
  }
}

resource "kubectl_manifest" "setup_istio" {
  yaml_body = <<YAML
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
    name: istio-setup
    namespace: istio-system
spec:
  profile: default
  hub: gcr.io/istio-release
  tag: 1.9.2
  components:
    ingressGateways:
      - name: istio-ingressgateway
        enabled: true
  meshConfig:
    defaultConfig:
      holdApplicationUntilProxyStarts: ${var.hold_app_until_proxy_starts}"
YAML
  depends_on = [null_resource.init_operator]
}

在初始化和应用配置之间等待几秒钟是个好主意。

这是一篇关于使用 Azure 的 aks 执行此操作的好文章: https://medium.com/@vipinagarwal18/install-istio-on-azure-kubernetes-cluster-using-terraform-214f6d3f611

优点:

  • 易于设置
  • 使用 kubectl 提供程序轻松升级 istio

只要 helm 处于 alpha 阶段,这可能是最好的方法。

  1. terraform + helm 与 terraform helm 提供程序

Istio 在下载 istioctl 时为不同的组件提供了一些图表。这些可用于通过 helm 安装它。

resource "helm_release" "istio_base" {
  name       = "istio-base"
  chart      = "./manifests/charts/base"
  namespace  = "istio-system"
}

缺点:

  • 尚未准备好投入生产

奖金

  1. istio manifest + helm

前段时间,我从istioctl manifest generate 读到一篇关于如何使用 istio manifest 结合 helm 来安装和管理 istio 的文章。这种方法需要一些自定义代码,但也可以使用 terraform 和 helm 提供程序来完成。

请阅读:https://karlstoney.com/2021/03/04/ci-for-istio-mesh/index.html

结论

使用 terraform 安装 istio 是可行的,但目前接缝有点脏。一旦 helm 设置稳定,我想这将是最好的方法。使用 helm 提供程序,它可以与其他资源的 terraform 创建组合在一起。 Terraform 肯定会错过一个 istio 提供者,但我认为他们不会在可预见的未来创建一个。

【讨论】:

  • 感谢 Christoph 与我分享您的发现!很有帮助!
  • 我很想知道如何在 AWS 上的 EKS 集群上集成安装 Istio(terraform + helm 和 terraform helm 提供程序)。能否请你帮忙。谢谢
  • 我的意思是除了使用 helm_release 作为您共享的资源之外,在 EKS 集群端我还需要做些什么吗?
【解决方案3】:

扩展@Chris terraform + helm 提供者的第三个选项,

至于 istio 的 1.12.0+ 版本,他们正式拥有一个可用的 helm repo:

istio helm install

还有 terraform 的 helm 提供程序 Terraform helm provider 允许仅由 terraform 配置的简单设置:

provider "helm" {
  kubernetes {
    // enter the relevant authentication
  }
}

locals {
  istio_charts_url = "https://istio-release.storage.googleapis.com/charts"
}

resource "helm_release" "istio-base" {
  repository       = local.istio_charts_url
  chart            = "base"
  name             = "istio-base"
  namespace        = var.istio-namespace
  version          = "1.12.1"
  create_namespace = true
}

resource "helm_release" "istiod" {
  repository       = local.istio_charts_url
  chart            = "istiod"
  name             = "istiod"
  namespace        = var.istio-namespace
  create_namespace = true
  version          = "1.12.1"
  depends_on       = [helm_release.istio-base]
}

resource "kubernetes_namespace" "istio-ingress" {
  metadata {
    labels = {
      istio-injection = "enabled"
    }

    name = "istio-ingress"
  }
}

resource "helm_release" "istio-ingress" {
  repository = local.istio_charts_url
  chart      = "gateway"
  name       = "istio-ingress"
  namespace  = kubernetes_namespace.istio-ingress-label.id
  version    = "1.12.1"
  depends_on = [helm_release.istiod]
}

这是为制作做好准备所缺少的最后一步

不再需要在本地保存带有 null_resource 的 helm 图表

如果你想覆盖默认的 helm 值,这里很好地显示了它: Artifact hub,选择相关图表并查看数值

【讨论】:

  • 干得好,感谢发帖!
猜你喜欢
  • 2021-07-07
  • 2021-07-09
  • 2020-06-16
  • 2019-07-08
  • 2021-08-01
  • 2021-07-23
  • 2021-01-27
  • 2021-10-22
  • 2021-12-24
相关资源
最近更新 更多