Istio 安装

官网:https://istio.io/


控制中心做了进一步的细分,分成了 Pilot、Mixer 和 Citadel,它们的各自功能如下:

  • Pilot:为 Envoy 提供了服务发现,流量管理和智能路由(AB 测试、金丝雀发布等),以及错误处理(超时、重试、熔断)功能。 用户通过 Pilot 的 API 管理网络相关的资源对象,Pilot 会根据用户的配置和服务的信息把网络流量管理变成 Envoy 能识别的格式分发到各个 Sidecar 代理中。
  • Mixer:为整个集群执行访问控制(哪些用户可以访问哪些服务)和 Policy 管理(Rate Limit,Quota 等),并且收集代理观察到的服务之间的流量统计数据。
  • Citadel:为服务之间提供认证和证书管理,可以让服务自动升级成 TLS 协议。

下载 Istio

下载内容将包含:安装文件、示例和 istioctl 命令行工具。

curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.6.12 TARGET_ARCH=x86_64 sh -

cd istio-1.6.12/

# 将 istioctl 客户端路径增加到 path 环境变量中
export PATH=$PWD/bin:$PATH

# 安装 demo 配置
istioctl install --set profile=demo

# 设置启用自动注入 istio sidecar 的命名空间,当使用 kubectl apply 来部署应用时,如果 pod 启动在标有 istio-injection=enabled 的命名空间中,那么,Istio sidecar 注入器将自动注入 Envoy 容器到应用的 pod 中:
kubectl label namespace default istio-injection=enabled

创建一个例子应用

kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml 

# 确认应用已经正确启动
kubectl get svc
kubectl get pod

kubectl exec "$(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}')" -c ratings -- curl -s productpage:9080/productpage | grep -o "<title>.*</title>"

# 创建一个 Istio Ingress Gateway 接入外部流量
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml

# 检查
istioctl analyze

# 确定 ingress 的IP和端口,下面有两种情况
# 情况一:EXTERNAL-IP 存在
kubectl get svc istio-ingressgateway -n istio-system

# 情况二:EXTERNAL-IP 不存在,使用 nodePort 
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 INGRESS_HOST=$(kubectl get po -l istio=ingressgateway -n istio-system -o jsonpath='{.items[0].status.hostIP}')
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT

echo "$GATEWAY_URL"
echo "http://$GATEWAY_URL/productpage"

# 使用浏览器访问上面的IP,确定可以正常访问

创建 dashboard

kubectl apply -f samples/addons
while ! kubectl wait --for=condition=available --timeout=600s deployment/kiali -n istio-system; do sleep 1; done
kubectl get deployment --all-namespaces

# 启动 web UI
istioctl dashboard kiali --address=0.0.0.0
原文地址:https://www.cnblogs.com/klvchen/p/13892527.html