istio 服务网格(部署)

1.1 istio安装

版本选择:
https://istio.io/latest/docs/releases/supported-releases/#support-status-of-istio-releases
1.1.1使用Operator 部署Istio
首先下载 Istio 的安装包:
# wget https://github.com/istio/istio/releases/download/1.15.7/istio-1.13.0-linux-amd64.tar.gz

解压后,将 Istio 的客户端工具 istioctl,移动到/usr/local/bin 目录下:
# tar xf istio-1.15.7-linux-amd64.tar.gz
# cd istio-1.13.0
# mv bin/istioctl /usr/local/bin/
# istioctl version
no running Istio pods in "istio-system"
1.15.7
接下来安装 Istio 的 Operator,可以使用 istioctl 一键
# istioctl operator init
Installing operator controller in namespace: istio-operator using image: 
istio/operator:1.13.0
Operator controller will watch namespaces: istio-system
✔ Istio operator installed 
✔ Installation complete
## 如果卡着不动了 可以使用kubectl describe 查看详情
出现 Installation complete 后,查看 Pod 是否正常:
# kubectl get po -n istio-operator
NAME READY STATUS RESTARTS AGE
istio-operator-7f546b959b-cq4c9 1/1 Running 0 116
之后通过定义 IstioOperator 资源,在 Kubernetes 中安装 Istio:
# cat istio-operator.yaml 
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
 namespace: istio-system
 name: example-istiocontrolplane
spec:
 profile: default
 components: # 自定义组件配置
   ingressGateways: # 自定义 ingressGateway 配置
    - name: istio-ingressgateway 
      enabled: true # 开启 ingressGateway
      k8s: # 自定义 ingressGateway 的 Kubernetes 配置
        service: #将 Service 类型改成 NodePort
          type: NodePort
          ports:
           - port: 15020
             nodePort: 30520
             name: status-port
           - port: 80 # 流量入口 80 端口映射到 NodePort 的 30080,之后通过节点IP+30080 即可访问 Istio 服务
             nodePort: 30080
             name: http2
             targetPort: 8080
           - port: 443
             nodePort: 30443
             name: https
             targetPort: 8443

安装ist:
# istioctl manifest apply -f istio-operator.yaml 
This will install the Istio 1.13.0 default profile with ["Istio core" 
"Istiod" "Ingress gateways"] components into the cluster. Proceed? (y/N) y
✔ Istio core installed 
✔ Istiod installed 
✔ Ingress gateways installed 
✔ Installation complete 
Thank you for installing Istio 1.11. Please take a few minutes to tell 
us about your install/upgrade experience! 
https://forms.gle/kWULBRjUv7hHci7T6
查看创建的 Service 和 Pod:
# kubectl get svc,po -n istio-system
NAME TYPE CLUSTER-IP EXTERNAL-IP 
PORT(S) AGE
service/istio-ingressgateway NodePort 192.168.99.93 <none> 
15020:30020/TCP,80:30080/TCP,443:30443/TCP 83s
service/istiod ClusterIP 192.168.117.146 <none> 
15010/TCP,15012/TCP,443/TCP,15014/TCP 5m42s
NAME READY STATUS RESTARTS AGE
pod/istio-ingressgateway-5684974946-vmw6v 1/1 Running 0 
6m4s
pod/istiod-7859559dd-gwp6p 1/1 Running 0 6m42s
1.1.3 可视化工具 Kiali
Kiali 为 Istio 提供了可视化的界面,可以在 Kiali 上进行观测流量的走向、调用链,同时还可
以使用 Kiali 进行配置管理,给用户带来了很好的体验。
接下来在 Kubernetes 中安装 Kiali 工具,首先进入到 Istio 的安装包目录:
# kubectl create -f samples/addons/kiali.yaml 
serviceaccount/kiali created
configmap/kiali created
clusterrole.rbac.authorization.k8s.io/kiali-viewer created
clusterrole.rbac.authorization.k8s.io/kiali created
clusterrolebinding.rbac.authorization.k8s.io/kiali created
role.rbac.authorization.k8s.io/kiali-controlplane created
rolebinding.rbac.authorization.k8s.io/kiali-controlplane created
service/kiali created
deployment.apps/kiali created
查看部署状态:
# kubectl get po,svc -n istio-system -l app=kiali
NAME READY STATUS RESTARTS AGE
pod/kiali-fd9f88575-zbphq 1/1 Running 0 9m39s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) 
AGE
service/kiali ClusterIP 192.168.55.181 <none> 
20001/TCP,9090/TCP 8m40

#之后可以将svc类型改为nodeport或者配置ingress访问
1.1.4 Prometheus 和 Grafana
Istio 默认暴露了很多监控指标,比如请求数量统计、请求持续时间以及 Service 和工作
负载的指标,这些指标可以使用 Prometheus 进行收集,Grafana 进行展示。
Istio 内置了 Prometheus 和 Grafana 的安装文件,直接安装即可(也可以使用外置的Prometheus 和 Grafana):
# kubectl create -f samples/addons/prometheus.yaml -f 
samples/addons/grafana.yaml 
serviceaccount/prometheus created
configmap/prometheus created
clusterrole.rbac.authorization.k8s.io/prometheus created
clusterrolebinding.rbac.authorization.k8s.io/prometheus created
service/prometheus created
deployment.apps/prometheus created
serviceaccount/grafana created
configmap/grafana created
service/grafana created
deployment.apps/grafana created
configmap/istio-grafana-dashboards createdconfigmap/istio-services-grafana-dashboards created
查看创建的 Pod 和 Service:
# kubectl get svc,pod -n istio-system

同样的方式,将 Grafana 的 Service 改成 NodePort 或者添加 Ingress,之后访问即可

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值