Istio 检查安装了什么

Istio checking what is installed

istio 文档 here 具有以下信息:

The istioctl command saves the IstioOperator CR that was used to install Istio in a copy of the CR named installed-state. You can inspect this CR if you lose track of what is installed in a cluster.

The installed-state CR is also used to perform checks in some istioctl commands and should therefore not be removed.

现在,我想知道什么是“CR”以及如何检查这个“CR”?

简答

这将为您提供所有命名空间中属于 Istio CR 的所有已部署对象:

kubectl api-resources | grep -i istio | awk '{print }' | while read cr; do
    kubectl get $(echo $cr | tr '[:upper:]' '[:lower:]') --all-namespaces
done

详情:

CR 是一个通用的 k8s 术语,意思是 Custom Resource。 它的定义被命名为 CRD : Custom Resource Definition.

所以我们有两类资源:

  • 内置资源:Pod、Service、Deployment、Ingress、ReplicaSet、StatefulSet,...

  • 自定义资源(CR):取决于您对集群的自定义。

    • 例如,如果您安装 Istio,您将获得如下 CR:IstioOperator,...
    • 如果您安装 Prometheus-Operator,您将获得如下 CR:Alertmanager、PrometheusRule、...

现在获取资源列表,无论是内置的还是自定义的 (CR),运行:

kubectl api-resources | awk '{print }'

将它们过滤到属于 Istio 的资源

kubectl api-resources | grep -i istio | awk '{print }'

现在因为 IstioOperator(例如)是一个资源,您可以 运行 以下内容:

kubectl get istiooperator

检查对象在所有命名空间中是否属于此 CR

kubectl get istiooperator --all-namespaces

以上所有命令将帮助您基于现有资源构建YAML 对象。实际上,它会在kind: ???领域

帮助你

如果您还想获得合适的 apiVersion: ???,请选中 kubectl api-versions