卸载 Anthos Service Mesh
本页面介绍如何卸载 Anthos Service Mesh。
卸载 Anthos Service Mesh
使用以下命令卸载所有 Anthos Service Mesh 组件。这些命令还会删除 istio-system
命名空间和所有自定义资源定义 (CRD),包括您应用的所有 CRD。
为防止应用流量中断,请执行以下操作:
- 将任何 STRICT mTLS 政策降级为 PERMISSIVE。
- 移除任何可能阻止流量的 AuthorizationPolicy。
对此集群停用自动管理(无论您是直接应用还是使用舰队默认配置):
gcloud container fleet mesh update --management manual
在您的命名空间中停用 Sidecar 自动注入功能(如果已启用)。运行以下命令以显示命名空间标签:
kubectl get namespace YOUR_NAMESPACE --show-labels
输出类似于以下内容:
NAME STATUS AGE LABELS demo Active 4d17h istio.io/rev=asm-181-5
如果您在
LABELS
列下方的输出中看到istio.io/rev=
,请将其移除:kubectl label namespace YOUR_NAMESPACE istio.io/rev-
如果您在
LABELS
列下方的输出中看到istio-injection
,请将其移除:kubectl label namespace YOUR_NAMESPACE istio-injection-
如果没有看到
istio.io/rev
或istio-injection
标签,则表示命名空间未启用自动注入功能。重启已注入 Sidecar 的工作负载以移除代理。
如果您使用的是代管式 Anthos Service Mesh,请移除集群中的所有
controlplanerevision
资源:kubectl delete controlplanerevision RELEASE_CHANNEL -n istio-system
其中,RELEASE_CHANNEL 是您预配的发布渠道,例如
asm-managed
、asm-managed-rapid
或asm-managed-stable
。从集群中删除网络钩子(如果存在)。
集群内 Anthos Service Mesh
删除
validatingwebhooksconfiguration
和mutatingwebhookconfiguration
。kubectl delete validatingwebhookconfiguration,mutatingwebhookconfiguration -l operator.istio.io/component=Pilot
代管式 Anthos Service Mesh
A.删除
validatingwebhooksconfiguration
。kubectl delete validatingwebhookconfiguration istiod-istio-system-mcp
B.删除
mutatingwebhookconfiguration
。kubectl delete mutatingwebhookconfiguration istiod-RELEASE_CHANNEL
当所有工作负载启动且未观察到代理时,您便可以安全地删除集群内控制层面以停止计费。如果您部署了代管式控制层面,则系统会在上一步中自动删除该控制层面。
如需移除集群内控制层面,请运行以下命令:
istioctl x uninstall --purge
如果没有其他控制层面,则您可以删除
istio-system
命名空间以移除所有 Anthos Service Mesh 资源。否则,请删除与 Anthos Service Mesh 修订版本相对应的服务。这样可以避免删除 CRD 等共享资源。删除
istio-system
和asm-system
命名空间:kubectl delete namespace istio-system asm-system --ignore-not-found=true
检查删除操作是否成功:
kubectl get ns
输出应指示
Terminating
状态并返回所示内容,否则您可能需要手动删除命名空间中的其余资源并重试。NAME STATUS AGE istio-system Terminating 71m asm-system Terminating 71m
- 如果您要删除集群,或者已经删除集群,请确保每个集群均已从舰队中取消注册。
如果您已启用代管式 Anthos Service Mesh 舰队默认配置,并希望为将来的集群停用该配置,请停用该配置。如果您只从单个集群卸载,则可以跳过此步骤。
gcloud container hub mesh disable --fleet-default-member-config --project FLEET_PROJECT_ID
其中,FLEET_PROJECT_ID 是舰队宿主项目的 ID。
如果您使用的是代管式 Anthos Service Mesh,请删除
mdp-controller
部署:kubectl delete deployment mdp-controller -n kube-system
检查
istio-cni-plugin-config
ConfigMap 是否存在:kubectl get configmap istio-cni-plugin-config -n kube-system
如果存在
istio-cni-plugin-config
ConfigMap,请删除:kubectl delete configmap istio-cni-plugin-config -n kube-system
删除
istio-cni-node
DaemonSet:kubectl delete daemonset istio-cni-node -n kube-system
完成这些步骤后,系统会从集群中系统地移除所有 Anthos Service Mesh 组件,包括代理、集群内证书授权机构以及 RBAC 角色和绑定。在安装过程中,系统会向 Google 自有的服务帐号授予必要的权限,以在集群中建立服务网格资源。这些卸载说明不会撤消这些权限,因此将来可以无缝重新激活 Anthos Service Mesh。