Istio安装与实践

前提

安装Istio

1
wget https://github.com/istio/istio/releases/download/1.4.0/istio-1.4.0-linux.tar.gz
1
tar -zxf istio-1.4.0-linux.tar.gz
1
2
3
4
5
6
7
8
9
10
[root@dggphicprc11349 ]# cd istio-1.4.0/
[root@dggphicprc11349 istio-1.4.0]# ll
total 40
drwxr-x--- 2 root root 4096 11 14 07:13 bin
drwxr-xr-x 6 root root 4096 11 14 07:13 install
-rw-r--r-- 1 root root 11348 11 14 07:13 LICENSE
-rw-r----- 1 root root 675 11 14 07:13 manifest.yaml
-rw-r--r-- 1 root root 6080 11 14 07:13 README.md
drwxr-xr-x 19 root root 4096 11 14 07:13 samples
drwxr-x--- 3 root root 4096 11 14 07:13 tools

安装istio方式:

  • 使用Istioctl安装(推荐)

  • 使用install/kubernetes/文件夹中的istio-demo.yaml进行安装

  • 使用Helm和Tiller进行安装(Helm 的安装方法已被弃用。 请改用 使用 istioctl 安装

  • 使用Helm template渲染出Istio的YAML安装文件进行安装

Istio 1.1起默认的安装配置禁用了部分功能,如果使用Helm安装的话,建议对install/kubernetes/helm/istio/values.yaml中部分参数做修改,启用相关配置

参数 描述
grafana.enabled true 安装Grafana插件
tracing.enabled true 安装Jaeger插件
kiali.enabled true 安装Kiali插件
global.disablePolicyChecks false 启用策略检查
global.proxy.accessLogFile “/dev/stdout” 获取Envoy的访问日志

使用Istioctl安装方式安装步骤:

  1. 将istioctl放到系统PATH目录下

    1
    mv bin/istioctl /usr/local/bin
  2. 使用Istio demo配置文件安装

    1
    istioctl manifest apply --set profile=demo

应用实例

以天气应用为例

1
git clone https://github.com/cloudnativebooks/cloud-native-istio.git
  1. 创建weather这个namespace并且给此namespace打上istio-injection=enabled

    1
    2
    kubectl create ns weather
    kubectl label namespace weather istio-injection=enabled

    当 Kubernetes 调用 webhook 时,admissionregistration 配置被应用。默认配置将 sidecar 注入到所有拥有 istio-injection=enabled 标签的 namespace 下的 pod 中。 istio-sidecar-injector 配置字典指定了注入 sidecar 的配置。如需更改指定哪些 namespace 被注入,你可以使用以下命令编辑 MutatingWebhookConfiguration

    1
    $ kubectl edit mutatingwebhookconfiguration istio-sidecar-injector

    修改 MutatingWebhookConfiguration 之后,您应该重启 sidecar 注入器的 pod

  2. 创建应用

    1
    kubectl apply -f install/weather-v1.yaml -n weather
  3. 确认所有服务和pod均已创建并启动成功

    1
    2
    3
    4
    5
    [root@dggphicprc11349 cloud-native-istio]# kubectl get service -n weather
    NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    advertisement ClusterIP 10.99.241.73 <none> 3003/TCP 2m12s
    forecast ClusterIP 10.100.154.32 <none> 3002/TCP 2m12s
    frontend ClusterIP 10.109.157.96 <none> 3000/TCP 2m12s
    1
    2
    3
    4
    5
    [root@dggphicprc11349 cloud-native-istio]# kubectl get pod -n weather
    NAME READY STATUS RESTARTS AGE
    advertisement-v1-6d69d9cff8-fgfnt 2/2 Running 0 2m59s
    forecast-v1-ff98f99f7-5rk5c 2/2 Running 0 2m59s
    frontend-v1-68d57cf9d8-kmlnp 2/2 Running 0 2m59s
  4. 配置Gateway和frontend服务的VirtualService,使应用可以被外部请求访问

    1
    kubectl apply -f install/weather-gateway.yaml
  5. 通过浏览器访问外部地址

    http://xx.xx.xx.xx


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!