在k8s集群中使用istioctl安装istio

在k8s集群中使用istioctl安装istio

版本对照

Istio版本K8s版本
1.151.22, 1.23, 1.24, 1.25
1.141.21, 1.22, 1.23, 1.24
1.131.20, 1.21, 1.22, 1.23

我是用的版本是(istio 1.15.4 k8s 1.23.0)

1 安装istioctl

前置条件 docker、k8s安装正常

k8s的安装可以参考:

https://blog.csdn.net/m0_49952522/article/details/127883644?spm=1001.2014.3001.5502

官方给出了很多安装的方式,推荐istioctl。operator的方式比较简单,但是官方不在优先支持。

在这里插入图片描述

官网采用的命令大概率会超时。

$ curl -L https://istio.io/downloadIstio | sh -

# 指定具体版本
$ curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.15.4 sh -

这里直接去github上下载压缩文件

https://github.com/istio/istio/releases/tag/1.15.4

直接选istio,不要选istioctl。
在这里插入图片描述
下载完成后在linux上解压。

tar -xvf istio-1.15.4-linux-amd64.tar.gz

在这里插入图片描述
进入istio-1.15.4文件夹,将bin临时添加到环境变量。

按变量的生存周期来划分,Linux变量可分为两类:

1.永久的:需要修改配置文件,变量永久生效

2.临时的:使用export命令声明即可,变量在关闭shell时失效

export PATH=$PWD/bin:$PATH

测试istioctl是否正常运行。

istioctl version

在这里插入图片描述

2 安装istio(多节点集群)

通过 -f 传递配置文件

新建yaml文件或通过vi创建。

vi my-demo-config.yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
  profile: demo

在这里插入图片描述

apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
  profile: demo
istioctl install -f istio-deploy.yaml

在这里插入图片描述

kubectl get pod -nistio-system

在这里插入图片描述

3 单节点k8s集群(仅有一个master)

安装istio时出错,Istiod encountered an error: failed to wait for resource: resources not ready after 5m0s: timed out waiting for the condition

这里的timeout除了网络问题,在单节点k8s集群还有可能是因为:
  1. 这个timeout是假的,其实是机器内存要16G以上试下
  2. 如果k8s是只有master节点的话要开启允许master节点调度
3.1 允许master调度pod
查看节点调度

可以看到master节点存在污点(也有的安装后master没有污点就应该可以正常安装)。

kubectl describe node|grep -E "Name:|Taints:"

在这里插入图片描述

删除污点
kubectl taint node master node-role.kubernetes.io/master-
设置为尽量不调度
kc taint node master node-role.kubernetes.io/master=:PreferNoSchedule

在这里插入图片描述

重新执行
istioctl install -f istio-deploy.yaml

在这里插入图片描述

4 启用 Istio,注入sidecar

注入前,每个pod里面只有一个镜像

在这里插入图片描述

Istio 默认自动注入 Sidecar. 为命名空间打上标签 istio-injection=enabled
kubectl label namespace ctt istio-injection=enabled
# 覆盖
# kubectl label namespace default istio-injection=enabled --overwrite

在这里插入图片描述

删除pod(会重新启动达到deployment中定义的数量)或重新apply deployment。
kubectl delete pod -n ctt eureka-client-7c84cb577c-h8mng eureka-server-74ffd79d64-7768x service-provider-v1-b4bcc65fc-jdn6k service-provider-v2-95fd56fcf-z54jd
变成2/2说明sidecar注入成功。

在这里插入图片描述

5 卸载

可选的 --purge 参数将移除所有 Istio 资源,包括可能被其他 Istio 控制平面共享的、集群范围的资源。

#删除所有资源
istioctl uninstall --purge

参考

https://blog.csdn.net/qq_41854911/article/details/119300127?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522167150460116782425620022%2522%252C%2522scm%2522%253A%252220140713.130102334…%2522%257D&request_id=167150460116782425620022&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2alltop_click~default-2-119300127-null-null.142v68pc_new_rank,201v4add_ask,213v2t3_esquery_v3&utm_term=linux%20export&spm=1018.2226.3001.4187

https://blog.csdn.net/qq_44823950/article/details/125589202?ops_request_misc=&request_id=&biz_id=102&utm_term=k8s%20master%E5%BC%80%E5%90%AF%E8%B0%83%E5%BA%A6&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-5-125589202.142v68pc_new_rank,201v4add_ask,213v2t3_esquery_v3&spm=1018.2226.3001.4187

https://zhuanlan.zhihu.com/p/506007550

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值