下载最新版本:1.8.4

wget https://github.com/istio/istio/releases/download/1.8.4/istio-1.8.4-linux-amd64.tar.gz
tar zxvf istio-1.8.4-linux-amd64.tar.gz -C /usr/local/

设置环境变量

echo 'export ISTIO_HOME=/usr/local/istio-1.8.4' >> /etc/profile
echo 'export PATH=$PATH:$ISTIO_HOME/bin' >> /etc/profile

加载变量

source /etc/profile

查看版本

istioctl version

使用 istioctl 的安装方式

1.在学习、实验环境我们可以选择 demo 这个 profile 进行安装,生产环境建议使用 default,如下示例:
注:命令 --set meshConfig.enableEnvoyAccessLogService=true 在网格中启用Envoy访问日志服务

istioctl install --set profile=default \
               --set meshConfig.enableEnvoyAccessLogService=true\
               --set meshConfig.defaultConfig.envoyAccessLogService.address=skywalking-oap.istio-system:11800 \
               -y

2.给命名空间添加标签,指示 Istio 在部署应用的时候,自动的注入 Envoy 边车代理:

kubectl label namespace default istio-injection=enabled

3.确定入站ip和端口
将istio-ingressgateway改为NodePort方式,方便访问

kubectl patch service istio-ingressgateway -n istio-system -p '{"spec":{"type":"NodePort"}}'

为访问网关设置两个变量:INGRESS_HOST 和 INGRESS_PORT。

export INGRESS_HOST=$(kubectl get po -l istio=ingressgateway -n istio-system -o jsonpath='{.items[0].status.hostIP}')
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].nodePort}')

export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
echo "$GATEWAY_URL"

4.安装 dashboard 组件。命令如下:

kubectl apply -f /usr/local/istio-1.8.4/samples/addons -n istio-system

# 如需使用zipkin代替jaeger
# kubectl apply -f /usr/local/istio-1.8.4/samples/addons/extras -n istio-system

如果在安装插件时出错,再运行一次命令。 有一些和时间相关的问题,再运行就能解决。

5.访问安装的服务

kubectl get svc -n istio-system

默认的 svc 都是clusterIP,可以修改 addons 目录下对应的 yaml 文件,把服务改位 NodePort 访问方式。
如果安装有 ingress ,可以用

卸载

Istio 卸载程序按照层次结构逐级的从 istio-system 命令空间中删除 RBAC 权限和所有资源。对于不存在的资源报错,可以安全的忽略掉,毕竟他们已经被分层的删除了。

kubectl delete -f /usr/local/istio-1.8.4/samples/addons
istioctl manifest generate --set profile=defalut | kubectl delete --ignore-not-found=true -f -

命名空间 istio-system 默认情况下并不会被删除。 不需要的时候,使用下面命令删掉它:

kubectl delete namespace istio-system

指示 Istio 自动注入 Envoy 边车代理的标签默认也不删除。 不需要的时候,使用下面命令删掉它。

kubectl label namespace default istio-injection-