istio部署-istio dashboard


參考

1. istio 配置變更示例

Helm 的 --set 參數可以變更默認配置,如:

cd istio-1.1.7
helm template install/kubernetes/helm/istio \
--name istio --namespace istio-system \
--set sidecarInjectorWebhook.enabled=false
  • istio 的 Sidecar 自動注入功能是通過 Kubernetes 的 mutating 控制器完成;
  • 如果啟用了自動生效的 istio 安裝清單,就會生成1個名為 istio-sidecar-injectormutatingwebhookconfiguration 對象,其中保存的就是自動注入的配置;
  • 根據 Helm 與 Kubernetes 的工作原理,重復執行 kubectl apply 命令不會執行刪除操作,因此通過上面操作生成的清單如果被提交,后果就是 mutating 控制器繼續使用 istio-sidecar-injector 的配置進行工作;
  • 所以此方式只針對新增或修改操作生效,對於刪除操作無效

2. 使用 istio dashboard

2.1 啟用 Grafana

# istion 默認沒有啟用 grafana
helm template install/kubernetes/helm/istio \
--name istio \
--namespace istio-system \
--set grafana.enabled=true > default-grafana.yaml

# 應用
kubectl apply -f default-grafana.yaml

2.2 訪問 Grafana

2.2.1 訪問 Grafana

# option1:本地 localhost 端口轉發
kubectl -n istio-system port-forward \
$(kubectl -n istio-system get pod -l app=grafana -o jsonpath='{.items[0].metadata.name}') \
3000:3000 &

# option2:kube-proxy 端口轉發
kubectl proxy --address='10.64.198.131' --port=3000 --accept-hosts='^*$'
URL:http://10.64.198.131:3000/api/v1/namespaces/istio-system/services/http:grafana:3000/proxy
子URL(樣例):http://10.64.198.131:3000/api/v1/namespaces/istio-system/services/http:grafana:3000/proxy/d/yuRIKZnWk/istio-mesh-dashboard

2.2.2 構建流量

# 創建工作負載
kubectl label namespaces default istio-injection=enabled
kubectl apply -f sleep.istio.yaml
kubectl apply -f flask.istio.yaml

# 構建流量
kubectl exec -it -c sleep $(kubectl get pod -l app=sleep,version=v1 -o jsonpath={.items[0].metadata.name}) /bin/bash
bash-4.4# for i in `seq 100` ; do http --body http://flaskapp/fetch?url=http://flaskapp/env/version >> /dev/null ; done

# 查看 Istio Mesh Dashboard
URL:http://10.64.198.131:3000/api/v1/namespaces/istio-system/services/http:grafana:3000/proxy/d/yuRIKZnWk/istio-mesh-dashboard

2.3 Grafana Ingress

編輯 Grafana 的 values.yaml 文件可以將服務類型修改為 LoadBalance 或創建 Ingress 對象,以后者為例:

# 針對 "ingress" 字段修改;
# 另如果需要通過賬號訪問,可設置 "security.enabled: true",並設置用戶名與密碼
vim install/kubernetes/helm/istio/charts/grafana/values.yaml
ingress:
  # 啟用 "ingress"
  enabled: true
  ## Used to create an Ingress record.
  hosts:
    # 修改 "domain"
    - grafana.istio
  annotations:
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  # 
  tls:
    # Secrets must be manually created in the namespace.
    # - secretName: grafana-tls
    #   hosts:
    #     - grafana.local

# "ingress" 資源的 "spec.rules.host.http.paths.path" 字段,即 "subpath"
contextPath: /

注意

  • 定制 values.yaml 文件后,需要利用 helm template 重新生成部署清單,如上述 2.1 節;
  • 重新生成的部署清單默認含有 Ingress 資源,只需要提前准備 Ingress ControllerTraefik 等類似資源即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM