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 等类似资源即可。

猜你喜欢

转载自www.cnblogs.com/netonline/p/12099816.html