ubuntu与k8s环境安装istio.md

下载istio

1
2
3
4
5
6
7
8
9
10
11
12
curl -L https://istio.io/downloadIstio | sh -

# 进入 Istio 目录
cd istio-*

# 将 istioctl 添加到 PATH
export PATH=$PWD/bin:$PATH

# 永久添加到 PATH(可选)
echo 'export PATH=$PATH:'$PWD/bin >> ~/.bashrc
source ~/.bashrc

验证

1
istioctl version --remote=false

安装

1
2
3
4
5
# 安装 Istio 基础组件
istioctl install --set profile=default -y

# 验证安装
kubectl get pods -n istio-system

检查状态

1
2
3
4
5
6
7
8
9
10
11
# 检查 Pods
kubectl get pods -n istio-system

# 检查 Services
kubectl get svc -n istio-system

# 检查 Istio 自定义资源
kubectl get crd | grep istio

# 验证控制平面
istioctl verify-install

部署Bookinfo示例应用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 创建命名空间并启用注入
kubectl create namespace bookinfo
kubectl label namespace bookinfo istio-injection=enabled

# 部署应用
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml -n bookinfo

# 检查应用状态
kubectl get pods -n bookinfo
kubectl get services -n bookinfo

# 创建 Gateway 和 VirtualService
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml -n bookinfo

# 获取 Gateway 地址
export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT

echo "访问地址: http://$GATEWAY_URL/productpage"

安装 Kiali 仪表板

1
2
3
4
5
6
7
8
# 安装 Kiali 和其他可观测性组件
kubectl apply -f samples/addons

# 检查安装状态
kubectl rollout status deployment/kiali -n istio-system

# 端口转发访问 Kiali
kubectl port-forward -n istio-system svc/kiali 20001:20001