二 Istio:在Kubernetes(k8s)集群上安裝部署istio1.14( 五 )


[root@k8scloude1 ~]# ll -h istio-1.14.3-linux-amd64.tar.gz-rw-r--r-- 1 root root 23M 9月22 11:34 istio-1.14.3-linux-amd64.tar.gz[root@k8scloude1 ~]# tar xf istio-1.14.3-linux-amd64.tar.gz [root@k8scloude1 ~]# lsistio-1.14.3-linux-amd64.tar.gzistio-1.14.3[root@k8scloude1 ~]# cd istio-1.14.3/[root@k8scloude1 istio-1.14.3]# lsbinLICENSEmanifestsmanifest.yamlREADME.mdsamplestools[root@k8scloude1 istio-1.14.3]# ls bin/istioctl為了訪問 istioctl,我們應該把它添加到 path 中 。
[root@k8scloude1 bin]# pwd/root/istio-1.14.3/bin[root@k8scloude1 bin]# lsistioctl#臨時生效[root@k8scloude1 bin]# export PATH=/root/istio-1.14.3/bin:$PATH#永久生效[root@k8scloude1 bin]# vim /etc/profile.d/istioctl.sh[root@k8scloude1 bin]# cat /etc/profile.d/istioctl.shexport ISTIOCTL_HOME="/root/istio-1.14.3"export PATH="$ISTIOCTL_HOME/bin:$PATH"[root@k8scloude1 bin]# source /etc/profile.d/istioctl.sh要檢查 istioctl 是否在 path 里,運行 istioctl version 。你應該看到這樣的輸出 。
[root@k8scloude1 bin]# istioctl versionno running Istio pods in "istio-system"1.14.36.4 安裝 IstioIstio 支持多個配置文件(profile) 。配置文件之間的區別在于所安裝的組件 。
[root@k8scloude1 bin]# istioctl profile listIstio configuration profiles:defaultdemoemptyexternalminimalopenshiftpreviewremote這些配置文件提供了對 Istio 控制平面和 Istio 數據平面 Sidecar 的定制內容 。
您可以從 Istio 內置配置文件的其中一個開始入手,然后根據您的特定需求進一步自定義配置文件 。當前提供以下幾種內置配置文件:

  1. default:根據 IstioOperator API 的默認設置啟動組件 。建議用于生產部署和 Multicluster Mesh 中的 Primary Cluster 。
    您可以運行 istioctl profile dump 命令來查看默認設置 。
  2. demo:這一配置具有適度的資源需求 , 旨在展示 Istio 的功能 。它適合運行 Bookinfo 應用程序和相關任務 。這是通過快速開始指導安裝的配置 。此配置文件啟用了高級別的追蹤和訪問日志,因此不適合進行性能測試 。
  3. minimal:與默認配置文件相同,但只安裝了控制平面組件 。它允許您使用 Separate Profile 配置控制平面和數據平面組件(例如 Gateway) 。
  4. remote:配置 Multicluster Mesh 的 Remote Cluster 。
  5. empty:不部署任何東西 ??梢宰鳛樽远x配置的基本配置文件 。
  6. preview:預覽文件包含的功能都是實驗性 。這是為了探索 Istio 的新功能 。不確保穩定性、安全性和性能(使用風險需自負) 。
標注的組件安裝在每個配置文件中:
defaultdemominimalremoteemptypreview核心組件istio-egressgatewayistio-ingressgatewayistiod推薦用于生產部署的配置文件是 default 配置文件 。
我們將安裝 demo 配置文件,因為它包含所有的核心組件,啟用了跟蹤和日志記錄,便于學習不同的 Istio 功能 。
我們也可以從 minimal 的組件開始,以后單獨安裝其他功能,如 ingress 和 egress 網關 。
因為我們將使用 Istio Operator 進行安裝,所以我們必須先部署 Operator 。關于Istio Operator 簡介可以查看https://istio.io/v1.14/zh/blog/2019/introducing-istio-operator/
要部署 Istio Operator , 請運行:
[root@k8scloude1 bin]# istioctl operator initInstalling operator controller in namespace: istio-operator using image: docker.io/istio/operator:1.14.3Operator controller will watch namespaces: istio-system Istio operator installed Installation completeinit 命令創建了 istio-operator 命名空間,并部署了 CRD、Operator Deployment 以及 operator 工作所需的其他資源 。安裝完成后,Operator 就可以使用了 。
要安裝 Istio,我們必須創建 IstioOperator 資源,并指定我們要使用的配置文件 。
創建一個名為 istio-demo-profile.yaml的文件,內容如下:
#創建目錄istioyaml,用來專門存放yaml文件[root@k8scloude1 ~]# mkdir istioyaml[root@k8scloude1 ~]# cd istioyaml/[root@k8scloude1 istioyaml]# vim istio-demo-profile.yaml#profile: demo表示使用demo配置文件安裝istio[root@k8scloude1 istioyaml]# cat istio-demo-profile.yamlapiVersion: v1kind: Namespacemetadata:name: istio-system---apiVersion: install.istio.io/v1alpha1kind: IstioOperatormetadata:namespace: istio-systemname: demo-istio-installspec:profile: demo我們還在文件中添加了命名空間資源,以創建 istio-system 命名空間 。
我們需要做的最后一件事是創建資源:
[root@k8scloude1 istioyaml]# kubectl apply -f istio-demo-profile.yamlWarning: resource namespaces/istio-system is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.namespace/istio-system configuredistiooperator.install.istio.io/demo-istio-install created#可以查看istio-system命名空間下的所有資源[root@k8scloude1 istioyaml]# kubectl get all -o wide -n istio-systemNAMEREADYSTATUSRESTARTSAGEIPNODENOMINATED NODEREADINESS GATESpod/istio-egressgateway-58949b7c84-k7v6f1/1Running03m38s10.244.112.173k8scloude2<none><none>pod/istio-ingressgateway-75bc568988-9j4wv1/1Running03m38s10.244.251.238k8scloude3<none><none>pod/istiod-84d979766b-kz5sd1/1Running04m20s10.244.112.130k8scloude2<none><none>NAMETYPECLUSTER-IPEXTERNAL-IPPORT(S)AGESELECTORservice/istio-egressgatewayClusterIP10.102.56.241<none>80/TCP,443/TCP3m35sapp=istio-egressgateway,istio=egressgatewayservice/istio-ingressgatewayLoadBalancer10.107.131.65192.168.110.19015021:30093/TCP,80:32126/TCP,443:30293/TCP,31400:30628/TCP,15443:30966/TCP3m35sapp=istio-ingressgateway,istio=ingressgatewayservice/istiodClusterIP10.103.37.59<none>15010/TCP,15012/TCP,443/TCP,15014/TCP4m21sapp=istiod,istio=pilotNAMEREADYUP-TO-DATEAVAILABLEAGECONTAINERSIMAGESSELECTORdeployment.apps/istio-egressgateway1/1113m39sistio-proxydocker.io/istio/proxyv2:1.14.3app=istio-egressgateway,istio=egressgatewaydeployment.apps/istio-ingressgateway1/1113m39sistio-proxydocker.io/istio/proxyv2:1.14.3app=istio-ingressgateway,istio=ingressgatewaydeployment.apps/istiod1/1114m21sdiscoverydocker.io/istio/pilot:1.14.3istio=pilotNAMEDESIREDCURRENTREADYAGECONTAINERSIMAGESSELECTORreplicaset.apps/istio-egressgateway-58949b7c841113m39sistio-proxydocker.io/istio/proxyv2:1.14.3app=istio-egressgateway,istio=egressgateway,pod-template-hash=58949b7c84replicaset.apps/istio-ingressgateway-75bc5689881113m39sistio-proxydocker.io/istio/proxyv2:1.14.3app=istio-ingressgateway,istio=ingressgateway,pod-template-hash=75bc568988replicaset.apps/istiod-84d979766b1114m21sdiscoverydocker.io/istio/pilot:1.14.3istio=pilot,pod-template-hash=84d979766b

推薦閱讀