1. Istion 快速入门
1.1. Istion 安装
- 在Github上下载对应的发布包github
$ cd /usr/local/src
$ wget https://github.com/istio/istio/releases/download/1.24.2/istio-1.24.2-linux-amd64.tar.gz
$ tar zxf istio-1.24.2-linux-amd64.tar.gz
$ cd istio-1.24.2
$ ls -l
total 40
drwxr-x--- 2 root root 4096 Dec 15 00:18 bin
-rw-r--r-- 1 root root 11357 Dec 15 00:18 LICENSE
drwxr-xr-x 4 root root 4096 Dec 15 00:18 manifests
-rw-r----- 1 root root 924 Dec 15 00:18 manifest.yaml
-rw-r--r-- 1 root root 6927 Dec 15 00:18 README.md
drwxr-xr-x 27 root root 4096 Dec 15 00:18 samples
drwxr-xr-x 3 root root 4096 Dec 15 00:18 tools
- 安装目录介绍
安装目录包含如下内容:
- bin/ 目录下,包含 istioctl 的客户端文件。istioctl 工具用于手动注入 Envoy sidecar 代理
- samples/ 目录下,有示例应用程序
tools/目录下,存放了一些脚本工具
移动到部署路径下添加环境变量
$ mv istio-1.24.2 /usr/local/
$ ln -s /usr/local/istio-1.24.2/ /usr/local/istio
$ vim ~/.bash_rc
PATH=$PATH:$HOME/bin:/usr/local/istio/bin
$ source ~/.bash_rc
1.1.1. 安装istio
- 安装istio并使用demo配置
$ istioctl install --set profile=demo --set hub=docker.m.daocloud.io/istio
- 创建Kubernetes Gateway API CRD
$ wget https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/standard-install.yaml
$ kubectl create -f standard-install.yaml
# 可以看到当前系统有istion的CRD和Gateway的CRD
$ kubectl get crd
- 部署Bookinfo示例应用
给命名空间添加标签,指示 Istio在部署应用的时候,自动注入 Envoy Sidecar 代理:
# 创建namespace并添加标签
$ kubectl create ns bookinfo
$ kubectl label namespace bookinfo istio-injection=enabled
namespace/nginx labeled
# 部署Bookinfo应用(修改为国内Docker镜像源)
$ cd /usr/local/istio/samples/bookinfo/platform/kube/
$ sed -i 's/docker.io/docker.m.daocloud.io/g' bookinfo.yaml
$ kubectl create -f bookinfo.yaml -n bookinfo
# 验证bookinfo案例是否正常启动
kubectl exec "$(kubectl get pod -n bookinfo -l app=ratings -o jsonpath='{.items[0].metadata.name}')" -n bookinfo -c ratings -- curl -sS productpage:9080/productpage | grep -o "<title>.*</title>"
- 访问bookinfo应用
Istio 支持 Kubernetes Gateway API, 并计划将其作为未来流量管理的默认 API。建议新用户直接学习Gateway API。
$ kubectl apply -f samples/bookinfo/gateway-api/bookinfo-gateway.yaml