本文章按照一下步骤
下载安装istio部署样本应用程序打开应用程序以及阻止外部访问查看仪表板官网下载
curl -L https://istio.io/downloadIstio | sh -百度云盘
链接:https://pan.baidu.com/s/1-4P4Ici42uxg2_gWYtljSg 提取码:4uq7 复制这段内容后打开百度网盘手机App,操作更方便哦指定版本
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.6.8 TARGET_ARCH=x86_64 sh -进入到istio软件包目录
cd istio-1.7.3安装目录包含:
中的示例应用程序 samples/目录中的客户端二进制 文件。istioctlbin/设置环境变量
export PATH=$PWD/bin:$PATH安装istio 指定位置
istioctl install --set profile=demo ✔ Istio core installed ✔ Istiod installed ✔ Egress gateways installed ✔ Ingress gateways installed ✔ Installation complete添加名称空间标签,以指示Istio在以后部署应用程序时自动注入Envoy sidecar代理
kubectl label namespace default istio-injection=enabled namespace/default labeled检查样本程序
kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE details ClusterIP 10.0.0.212 <none> 9080/TCP 29s kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 25m productpage ClusterIP 10.0.0.57 <none> 9080/TCP 28s ratings ClusterIP 10.0.0.33 <none> 9080/TCP 29s reviews ClusterIP 10.0.0.28 <none> 9080/TCP 29s kubectl get pods NAME READY STATUS RESTARTS AGE details-v1-558b8b4b76-2llld 2/2 Running 0 2m41s productpage-v1-6987489c74-lpkgl 2/2 Running 0 2m40s ratings-v1-7dc98c7588-vzftc 2/2 Running 0 2m41s reviews-v1-7f99cc4496-gdxfn 2/2 Running 0 2m41s reviews-v2-7d79d5bd5d-8zzqd 2/2 Running 0 2m41s reviews-v3-7dbcdcbc56-m8dph 2/2 Running 0 2m41s 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
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml gateway.networking.istio.io/bookinfo-gateway created virtualservice.networking.istio.io/bookinfo created检查(正确配置,无异常)
istioctl analyze ✔ No validation issues found when analyzing namespace: default.Istio 默认自动注入 Sidecar
kubectl label namespace default istio-injection=enabled设置访问网关的 INGRESS_HOST 和 INGRESS_PORT 变量,例如node port模式。即当前环境未使用外部负载均衡器,需要通过 node port 访问。执行如下命令
$ 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=127.0.0.1设置 GATEWAY_URL
$ export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT确认可以用浏览器打开网址http://$GATEWAY_URL/productpage,来浏览应用的 Web 页面。如果刷新几次应用的页面,就会看到 productpage 页面中会随机展示 reviews 服务的不同版本的效果(红色、黑色的星形或者没有显示)。reviews 服务出现这种情况是因为默认情况下的配置会随机访问三个版本,如果想设置个性化配置则可以用 Istio 来控制版本的路由。
安装部署
kubectl apply -f samples/addons while ! kubectl wait --for=condition=available --timeout=600s deployment/kiali -n istio-system; do sleep 1; done访问Kiali仪表板
istioctl dashboard kiali (这条命令是模拟浏览器访问,最小化安装centos7,所以会报错,但是不影响)修改 EXTERNAL-IP
kubectl edit service kiali -n istio-system访问地址 http://10.1.1.100:20001/kiali