Kubernetes 使用Istio操作员和EKS上的地形安装Istio

Kubernetes 使用Istio操作员和EKS上的地形安装Istio,kubernetes,terraform,istio,amazon-eks,servicemesh,Kubernetes,Terraform,Istio,Amazon Eks,Servicemesh,我不熟悉地形。我需要在AWS EKS群集上设置Istio。我想到了使用Istio操作符和Terraform来做同样的事情 下面是使用Istio操作符在EKS上安装Istio的shell脚本: 安装-istio.sh # Download and install the Istio istioctl client binary # Specify the Istio version that will be leveraged throughout these instructions ISTI

我不熟悉地形。我需要在AWS EKS群集上设置Istio。我想到了使用Istio操作符和Terraform来做同样的事情

下面是使用Istio操作符在EKS上安装Istio的shell脚本:

安装-istio.sh

# Download and install the Istio istioctl client binary

# Specify the Istio version that will be leveraged throughout these instructions
ISTIO_VERSION=1.7.3

curl -sL "https://github.com/istio/istio/releases/download/$ISTIO_VERSION/istioctl-$ISTIO_VERSION-linux-amd64.tar.gz" | tar xz

sudo mv ./istioctl /usr/local/bin/istioctl
sudo chmod +x /usr/local/bin/istioctl

# Install the Istio Operator on EKS
istioctl operator init

# The Istio Operator is installed into the istio-operator namespace. Query the namespace.
kubectl get all -n istio-operator

# Install Istio components
istioctl profile dump default

# Create the istio-system namespace and deploy the Istio Operator Spec to that namespace.
kubectl create ns istio-system
kubectl apply -f istio-operator.yaml

# Validate the Istio installation
kubectl get all -n istio-system

apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
  namespace: istio-system
  name: istio-control-plane
spec:
  # Use the default profile as the base
  # More details at: https://istio.io/docs/setup/additional-setup/config-profiles/
  profile: default
  # Enable the addons that we will want to use
  addonComponents:
    grafana:
      enabled: true
    prometheus:
      enabled: true
    tracing:
      enabled: true
    kiali:
      enabled: true
  values:
    global:
      # Ensure that the Istio pods are only scheduled to run on Linux nodes
      defaultNodeSelector:
        beta.kubernetes.io/os: linux
    kiali:
      dashboard:
        auth:
          strategy: anonymous
下面是install-istio.sh使用的istio-operator.yaml文件

# Download and install the Istio istioctl client binary

# Specify the Istio version that will be leveraged throughout these instructions
ISTIO_VERSION=1.7.3

curl -sL "https://github.com/istio/istio/releases/download/$ISTIO_VERSION/istioctl-$ISTIO_VERSION-linux-amd64.tar.gz" | tar xz

sudo mv ./istioctl /usr/local/bin/istioctl
sudo chmod +x /usr/local/bin/istioctl

# Install the Istio Operator on EKS
istioctl operator init

# The Istio Operator is installed into the istio-operator namespace. Query the namespace.
kubectl get all -n istio-operator

# Install Istio components
istioctl profile dump default

# Create the istio-system namespace and deploy the Istio Operator Spec to that namespace.
kubectl create ns istio-system
kubectl apply -f istio-operator.yaml

# Validate the Istio installation
kubectl get all -n istio-system

apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
  namespace: istio-system
  name: istio-control-plane
spec:
  # Use the default profile as the base
  # More details at: https://istio.io/docs/setup/additional-setup/config-profiles/
  profile: default
  # Enable the addons that we will want to use
  addonComponents:
    grafana:
      enabled: true
    prometheus:
      enabled: true
    tracing:
      enabled: true
    kiali:
      enabled: true
  values:
    global:
      # Ensure that the Istio pods are only scheduled to run on Linux nodes
      defaultNodeSelector:
        beta.kubernetes.io/os: linux
    kiali:
      dashboard:
        auth:
          strategy: anonymous
下面是执行脚本的main.tf文件

resource "null_resource" "install_istio" {

 provisioner "local-exec" {

    command = "/bin/bash install-istio.sh"
  }
}

我请求您帮我解答几个问题:

  • 如何利用上述脚本和Terraform在EKS集群上安装Istio。我需要在上面的脚本中包括什么地形部分
  • 剧本中有没有遗漏的部分。使用上述脚本更新Istio是否会遇到任何问题
  • 为了让脚本能够在EKS集群上安装Istio,我还需要包括哪些其他参数
  • 如何使用上述脚本创建Terraform模块

  • 非常感谢您抽出时间。谢谢你的帮助

    我相信,如果使用这样的本地exec provisioner,您将遇到问题

    Terraform不能很好地利用它无法协调的资源。尤其是在CRD方面。此外,每次运行
    terraformapply
    ,您都会反复运行
    istioctl init
    ,这可能不是您想要的

    你能做的就是

  • 使用以下命令将istio运算符转换为标准kubernetes清单
  • 使用创建一个
    istio操作符/kustomization.yaml
    文件
  • 安装terraform
    kustomization
    提供程序
  • 使用terraform
    kustomization
    提供程序安装
    istio操作员
  • istio/manifest.yaml
  • 使用创建一个
    istio/kustomization.yaml
  • 使用terraform使用第二个
    kustomization
    资源安装
    istioperator
  • 我建议将整个内容放在一个单独的文件夹中,例如

    /home
      /project
        /terraform
          /istio
            terraform.tf
            istio_operator.tf
            istio.tf
            /istio
              kustomization.yaml
              manifest.yaml
            /istio-operator
              kustomization.yaml
              manifest.yaml
    
          
    

    不,这不能解决问题,因为terraform不知道如何删除
    null\u资源。反复运行
    terraformapply
    会起作用,但会浪费宝贵的时间。您也可以使用
    istioctl
    手动安装istio。
    kubernetes alpha
    terraform提供程序最终将不再是实验性的,也许它将使将来使用terraform安装kubernetes资源变得更容易。感谢Ludovic回答和分享知识。欢迎您。如果您遇到“鸡或蛋”错误(在安装istio CRD之前无法安装IstioOperator),则只需使用两个不同的terraform模块即可
    terraform分别应用
    。一个用于istio操作符,另一个用于
    istio控制平面
    。您也可以这样做。我不喜欢使用Helm,因为我更喜欢手动配置清单。使用helm很困难,如果您打印出完整的清单(使用
    istioctl dump
    helm模板
    ),就容易多了。这就是我为所有企业项目所做的。
    # istio-operator.tf
    
    data "kustomization" "istio_operator" {
      path     = "./istio-operator"
    }
    
    resource "kustomization_resource" "istio_operator" {
      for_each = data.kustomization.istio_operator.ids
      manifest = data.kustomization.istio_operator.manifests[each.value]
    }
    
    
    
    # istio/manifest.yaml
    
    apiVersion: install.istio.io/v1alpha1
    kind: IstioOperator
    metadata:
      name: istio-control-plane
    ...
    
    # istio/kustomization.yaml
    
    resources:
    - manifest.yaml
    
    # istio.tf
    
    data "kustomization" "istio" {
      path     = "./istio"
    }
    
    resource "kustomization_resource" "istio" {
      for_each = data.kustomization.istio.ids
      manifest = data.kustomization.istio.manifests[each.value]
      depends_on = [kustomization_resource.istio_operator]
    }
    
    
    
    /home
      /project
        /terraform
          /istio
            terraform.tf
            istio_operator.tf
            istio.tf
            /istio
              kustomization.yaml
              manifest.yaml
            /istio-operator
              kustomization.yaml
              manifest.yaml