全栈工程师开发手册 (作者:栾鹏)
架构系列文章


Istio简介

Istio 官方推荐使用 Helm 来安装,Istio 中的很多组件都可以选择安装或开启,因此 Helm chart 也是组合式的,下载 Istio 安装包后解压可以看到 install/kubernetes/helm/istio 目录下的 Helm chart 配置文件,参考 使用 Helm 进行安装。

Istio 的安装文件中包括如下几个子 chart。

ingress
ingressgateway
egressgateway
sidecarInjectorWebhook
galley
mixer
pilot
security(citadel)
grafana
prometheus
servicegraph
tracing(jaeger)
kiali
所有的这些子 Chart 都可以通过 YAML 配置中的 enabled 标志选择性的开启,具体配置方法请参考安装包解压后的 install/kubernetes/helm/istio/README.md 文件。

istio 下载

Istio 会被安装到自己的 istio-system 命名空间,并且能够对所有其他命名空间的服务进行管理。

进入 Istio release 页面,下载对应目标操作系统的安装文件。在 macOS 或者 Linux 系统中,还可以运行下面的命令,进行下载和自动解压缩:

$ curl -L https://git.io/getLatestIstio | sh -

进入 Istio 包目录。假设这个包是 istio-1.0.4:

$ cd istio-1.0.4

安装目录中包含:

  • 在 install/ 目录中包含了 Kubernetes 安装所需的 .yaml 文件
  • samples/ 目录中是示例应用
  • istioctl 客户端文件保存在 bin/ 目录之中。istioctl 的功能是手工进行 Envoy Sidecar 的注入,以及对路由规则、策略的管理
  • istio.VERSION 配置文件

将 istioctl 客户端二进制文件加到 PATH 中。 例如,在 macOS 或 Linux 系统上执行下面的命令:

$ export PATH=$PWD/bin:$PATH

istio 安装

官网: https://istio.io/docs/setup/install/helm/

选项1:通过 Helm 的 helm template 安装 Istio

将 Istio 的核心组件呈现为名为 istio.yaml 的 Kubernetes 清单文件:

$ helm template install/kubernetes/helm/istio --name istio --namespace istio-system > ./istio.yaml

通过清单文件安装组件

$ kubectl create namespace istio-system
$ kubectl create -f ./istio.yaml

由于istio组件中自定义了资源类型,而形成 istio.yaml文件的时候,并不是先定义再使用资源类型的顺序,所以你可以执行两遍kubectl create -f ./istio.yaml 来实现正确安装

卸载

$ kubectl delete -f ./istio.yaml

选项2:通过 Helm 和 Tiller 的 helm install 安装 Istio

此选项允许 Helm 和 Tiller 管理 Istio 的生命周期。

Warning 使用 Helm 升级 Istio 还没有进行全面的测试。

如果还没有为 Tiller 配置 service account,请配置一个:

$ kubectl create -f install/kubernetes/helm/helm-service-account.yaml

使用 service account 在您的集群中安装 Tiller:

$ helm init --service-account tiller --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.9.1 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

安装 Istio:

$ helm install install/kubernetes/helm/istio --name istio --namespace istio-system

卸载

$ helm delete --purge istio

如果您的 Helm 版本低于 2.9.0,那么在重新部署新版 Istio chart 之前,您需要手动清理额外的 job 资源:

$ kubectl -n istio-system delete job --all

这里写了个sh脚本

install_type="templates"
#helm tiller安装
if [ install_type -eq "tiller" ]; then
kubectl create -f install/kubernetes/helm/helm-service-account.yaml
helm init --service-account tiller --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.9.1 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
helm version
helm install install/kubernetes/helm/istio --name istio --namespace istio-system
fi
#helm  templates安装  
if [ install_type -eq "templates" ]; then
docker pull docker.io/istio/proxy_init:1.0.4
docker pull docker.io/istio/proxyv2:1.0.4
docker pull quay.io/coreos/hyperkube:v1.7.6_coreos.0
docker pull docker.io/istio/galley:1.0.4
docker pull docker.io/istio/mixer:1.0.4
docker pull docker.io/istio/pilot:1.0.4
docker pull docker.io/prom/prometheus:v2.3.1
docker pull docker.io/istio/citadel:1.0.4
docker pull docker.io/istio/sidecar_injector:1.0.4
helm template install/kubernetes/helm/istio --name istio --namespace istio-system > ./istio.yaml
kubectl create namespace istio-system
kubectl create -f ./istio.yaml    # 运行两次,因为自定义资源  并且使用顺序错了
kubectl create -f ./istio.yaml
fi
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐