在Kubernetes集群中搭建Istio微服务网格
        【摘要】 
                    
                        
                    
                    在Kubernetes集群中搭建Istio微服务网格 
 文章目录
 在Kubernetes集群中搭建Istio微服务网格1.使用sealos部署快速部署K8S集群1.1.基本环境配置1.2.部署K8...
    
    
    
    在Kubernetes集群中搭建Istio微服务网格
1.使用sealos部署快速部署K8S集群
1.1.基本环境配置
1.设置主机名
hostnamectl set-hostname k8s-master
hostnamectl set-hostname k8s-node1
hostnamectl set-hostname k8s-node2
2.关闭selinux及防火墙
setenforce 0
sed -ri '/^SELINUX=/c SELINUX=disabled' /etc/sysconfig/selinux 
sed -ri '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config 
systemctl stop firewalld
systemctl disable firewalld
  
 - 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
1.2.部署K8S集群
1.sealos官网获取软件包
[root@k8s-master1 ~]# ll
总用量 507472
-rw-r--r-- 1 root root  552591411 8月   5 2021 kube1.19.16.tar.gz
-rw-r--r-- 1 root root  44322816  4月  29 13:47 sealos
2.将kube1.19.16.tar.gz文件上传到所有k8s节点
3.安装sealos
[root@k8s-master1 ~/soft]# chmod +x sealos && mv sealos /usr/bin
[root@k8s-master1 ~/soft]# sealos version
Version: 3.3.9-rc.3
Last Commit: 4db4953
Build Date: 2021-04-10T11:25:04Z
4.部署K8S1.19.16版本
[root@k8s-master ~]# sealos init --passwd 'teacher' --master 192.168.20.10  --node 192.168.20.11  --node 192.168.20.12 --pkg-url /root/kube1.19.16.tar.gz --version v1.19.16
  
 - 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17

2.在K8S集群中部署Istio网格服务
2.1.下载Istio安装包
[root@k8s-master ~]# curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.8.2 TARGET_ARCH=x86_64 sh -
  
 - 1
下载完成后会自动解压成目录。

2.2.查看Istio可用的配置列表
1.准备istio命令
[root@k8s-master ~]# cp istio-1.8.2/bin/istioctl /usr/bin/
2.查看可用的配置列表
[root@k8s-master ~]# istioctl profile list
Istio configuration profiles:
    default					#默认配置档,功能丰富,建议生产使用
    demo					#快速入门使用,适中配置,不适合性能测试
    empty
    minimal					#功能最少的组件集配置
    openshift
    preview
    remote					#用于配置共享控制平面的多集群服务网格
3.指定安装的配置档
$ istioctl install --set profile=demo -y
  
 - 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
常用配置档对安装组件的区别
| 组件名称 | default | demo | minmal | remote | 
|---|---|---|---|---|
| istio-citadel | √ | √ | √ | |
| istio-ingressgateway | √ | √ | ||
| istio-galley | √ | √ | ||
| istio-egressgateway | √ | |||
| istio-nodeagent | ||||
| istio-pilot | √ | √ | √ | |
| istio-policy | √ | √ | ||
| istio-sidecar-injector | √ | √ | √ | |
| istio-telemetry | √ | √ | ||
| grafana | √ | |||
| istio-tracing | √ | |||
| kiali | √ | |||
| prometheus | √ | √ | 
2.3.部署Istio网格服务
我们采用default配置档部署istio网格,istioctl install命令不指定任何配置档默认就是呀default配置档。
1.安装istio
[root@k8s-master ~]# istioctl install -y
Detected that your cluster does not support third party JWT authentication. Falling back to less secure first party JWT. See https://istio.io/v1.8/docs/ops/best-practices/security/#configure-third-party-service-account-tokens for details.
✔ Istio core installed
✔ Istiod installed                              
✔ Ingress gateways installed                              
✔ Installation complete        
2.查看istio在K8S集群创建的资源
[root@k8s-master ~]# kubectl get all -n istio-system
NAME                                        READY   STATUS    RESTARTS   AGE
pod/istio-ingressgateway-559f565fcd-jxn5b   1/1     Running   0          7m46s
pod/istiod-545bb98448-vqf84                 1/1     Running   0          12m
NAME                           TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                                      AGE
service/istio-ingressgateway   LoadBalancer   10.107.107.206   <pending>     15021:32381/TCP,80:31105/TCP,443:30793/TCP,15012:32259/TCP,15443:31377/TCP   7m45s
service/istiod                 ClusterIP      10.109.130.252   <none>        15010/TCP,15012/TCP,443/TCP,15014/TCP                                        12m
NAME                                   READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/istio-ingressgateway   1/1     1            1           7m46s
deployment.apps/istiod                 1/1     1            1           12m
NAME                                              DESIRED   CURRENT   READY   AGE
replicaset.apps/istio-ingressgateway-559f565fcd   1         1         1       7m46s
replicaset.apps/istiod-545bb98448                 1         1         1       12m
NAME                                                       REFERENCE                         TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
horizontalpodautoscaler.autoscaling/istio-ingressgateway   Deployment/istio-ingressgateway   <unknown>/80%   1         5         1          7m45s
horizontalpodautoscaler.autoscaling/istiod                 Deployment/istiod                 <unknown>/80%   1         5         1          12m
#程序部署了2个,分别是istiod以及istio-ingressgateway
#istio-ingressgateway的service资源通过loadblancer暴露了一组端口,我们可以通过这些端口访问到istio中的应用程序,loadblancer需要依靠公有云的负载均衡器,我们没有因此处于pending状态,但是该service资源也是可用的,loadblancer不存在公有云负载均衡器默认就会使用nodeport类型进行端口映射
  
 - 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32

2.4.展示Istio配置档的配置信息
可以展示出Istio的配置内容。
[root@k8s-master ~]# istioctl profile dump default
  
 - 1
2.5.查看Istio在k8s集群部署使用的YAML文件内容
#显示istio在k8s集群中部署使用的yaml编排文件内容
[root@k8s-master istio-1.8.2]# istioctl manifest generate 
#将编排文件内容导入到文件中
[root@k8s-master istio-1.8.2]# istioctl manifest generate > istio-generate.yaml
#后期不使用istio时,可以通过这个文件直接卸载istio
$ kubectl delete -f istio-generate.yaml
  
 - 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8

文章来源: jiangxl.blog.csdn.net,作者:Jiangxl~,版权归原作者所有,如需转载,请联系作者。
原文链接:jiangxl.blog.csdn.net/article/details/124707680
        【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
            cloudbbs@huaweicloud.com
        
        
        
        
        
        
        - 点赞
- 收藏
- 关注作者
 
             
           
评论(0)