Instana AutoTrace Webhook

Instana AutoTrace Webhook 是 Kubernetes 及 OpenShift相容 許可控制器轉換 Webhook。 它會在整個 Kubernetes 或 Red Hat OpenShift 叢集中執行的 Node.js、.NET Core、Ruby 及 Python 應用程式上自動配置 Instana 追蹤。 此外, Instana 文件還會提供指示,讓您針對在 IBM Cloud Pak for Integration中執行的 IBM MQ 及 App Connect 部署啟用 Instana 追蹤。

必要條件

在 Kubernetes 型叢集上安裝 Instana AutoTrace Webhook 之前,請確定符合下列必要條件:

  • Kubernetes 1.16+
  • Red Hat OpenShift 4.5+
  • kubectl 1.16+
  • Helm 3.2+ (部分自動化依賴於 Helm lookup 功能)

安裝 Instana AutoTrace Webhook

將下列 Script 中的 <download_key> 取代為有效的 Instana 代理程式金鑰下載金鑰,然後以叢集的管理者專用權執行 Script:

helm install --create-namespace --namespace instana-autotrace-webhook instana-autotrace-webhook \
  --repo https://agents.instana.io/helm instana-autotrace-webhook \
  --set webhook.imagePullCredentials.password=<download_key>

重要事項: 如果您要安裝在 Red Hat OpenShift上,則必須在 Script 中指定 --set openshift.enabled=true 選項。

在氣隙環境中配置

對於氣隙環境,您需要在環境中提供 instana-autotrace-webhook Helm 圖表、 instana-autotrace-webhook 容器映像檔及 instrumentation 容器映像檔。

若要將 Helm 圖表的最新版本下載至現行工作目錄,請執行下列指令:

helm pull instana-autotrace-webhook --repo https://agents.instana.io/helm instana-autotrace-webhook

附註: 若要變更此指令的目的地目錄,您可以使用選項 -d <DESTINATION_PATH> 來指定另一個目的地目錄。

若要下載最新的 instana-autotrace-webhook 映像檔,請執行下列指令:

docker pull containers.instana.io/instana/release/agent/instana-autotrace-webhook:latest

若要下載最新檢測映像檔,請執行下列指令:

docker pull icr.io/instana/instrumentation:latest

這兩個容器映像檔必須在您的容器登錄中可用。 在執行 helm install 指令的系統上,必須可以使用先前下載的 Helm Chart 保存檔。

若要安裝 Instana Autotrace WebHook,請執行下列指令:

helm upgrade --install --create-namespace \
  --namespace instana-autotrace-webhook \
  --set webhook.image=<INSTANA_AUTOTRACE_WEBHOOK_IMAGE_PATH> \
  --set autotrace.instrumentation.image=<INSTRUMENTATION_IMAGE_PATH> \
  instana-autotrace-webhook <PATH_TO_HELM_CHART_ARCHIVE>

儲存器登錄鑑別

儲存器登錄中的 instrumentation 映像檔用作所有應用程式 Pod 中的 initContainer 。 如果容器登錄需要 imagePullSecret 資源,則必須可在所有應用程式名稱空間中使用。

驗證 Webhook 運作

若要驗證 Webhook 可運作,請完成下列步驟:

  1. 若要驗證 instana-autotrace-webhook 名稱空間中的 instana-autotrace-webhook 是否如預期般執行,請執行下列指令:
kubectl get pods -n instana-autotrace-webhook

範例結果:

NAME                                         READY   STATUS    RESTARTS   AGE
instana-autotrace-webhook-7c5d5bf6df-82w7c   1/1     Running   0          12m
  1. 使用 Instana AutoTrace Webhook。 如果 Instana AutoTrace Webhook 正在執行,請部署 Node.js Pod , Instana Autotrace 會在 Node.js Pod 中自動啟用。 在 Pod 的日誌中,您可以看到一個標籤,指出「Instana 自動追蹤」已套用至 Node.js Pod:
kubectl get pod test-nodejs -n test-apps -o=jsonpath='{.metadata.labels.instana-autotrace-applied}'
true

如果您已使用 instana/agent Helm Chart 來安裝 Instana 主機代理程式,則 Node.js 程序會出現在 Instana 儀表板中。 如需相關資訊,請參閱 在 Kubernetes上安裝主機代理程式 文件。

不過,如果您沒有看到 instana-autotrace-applied 標籤出現在儲存器上,請參閱 疑難排解

更新 Instana AutoTrace WebHook 及檢測

Instana AutoTrace WebHook 沒有自動方式來更新它所安裝的設備測試。 檢測透過 icr.io/instana/instrumentation 映像檔遞送。 instana-autotrace-webhook Helm Chart 會定期更新,以使用最新的 icr.io/instana/instrumentation 映像檔。

若要更新 Instana AutoTrace WebHook 及檢測,請完成下列步驟:

  1. 使用下列指令,更新本端 Helm 安裝上的 Helm Chart 儲存庫:

    helm repo update
    
  2. 使用下列指令升級 instana-autotrace-webhook Helm Chart 部署:

    helm upgrade --namespace instana-autotrace-webhook instana-autotrace-webhook \
      --repo https://agents.instana.io/helm instana-autotrace-webhook \
      --reuse-values
    

解除安裝 Instana AutoTrace Webhook

您可以執行下列指令來解除安裝 Instana AutoTrace Webhook:

helm uninstall instana-autotrace-webhook \
  --namespace instana-autotrace-webhook \
  --no-hooks

執行 helm uninstall 指令之後,會顯示下列輸出: release "instana-autotrace-webhook" uninstalled

驗證 Instana AutoTrace Webhook 已正確解除安裝。 您可以在 Instana 使用者介面中的 Kubernetes > 叢集 中進行驗證,或執行下列指令:

 `kubectl get pods --namespace instana-autotrace-webhook` 

您不應在名稱空間中看到名稱為 instana-autotrace-webhook 的 Pod。

附註: 若要從已部署的應用程式移除 AutoTrace ,並防止 AutoTrace 併入新的應用程式中,請重新部署先前由 AutoTrace Webhook 突變的所有高階資源。 這可確保從資源規格及 Pod 範本中移除所有 AutoTrace 配置 (init-containers 及環境變數)。

Gotchas

  • Instana AutoTrace Webhook 會在新的 Kubernetes 資源上生效。 您可能需要刪除 Pod、 ReplicaSets、 StatefulStes、部署及 DeploymentConfigs ,然後重新建立它們,讓 Instana AutoTrace Webhook 完成其配置。
  • 目前僅支援 linux/amd64 Kubernetes 節點。

配置

角色型存取控制

若要將 AutoTrace Webhook 部署至由 ClusterRole 及相符 ClusterRoleBinding所保護的 ServiceAccount ,請在部署 Helm 圖表時設定 rbac.enabled=true 旗標。

除了角色型存取控制之外,如果您使用 Pod 安全原則,請將 rbac.psp.enabled=true 新增至 Helm 引數。

「Pod 安全標準」也可以透過內建 Pod 安全許可控制器來施行。 如需 Pod Security Admission 的相關資訊,請參閱 Kubernetes 文件

如果在 Helm 安裝中設定旗標 rbac.enabled=falsewebhook.pod.hostNetwork=false ,您可以執行下列指令,以使用限制性 Pod 安全標準來執行 AutoTrace Webhook:

kubectl label --overwrite ns instana-autotrace-webhook pod-security.kubernetes.io/enforce=restricted

儲存器埠

若要從 Kubernetes' apiserver 來存取,必須在主機網路上管理 AutoTrace Webhook Pod ,並且必須將部署配置為透通達到該目的。 依預設,儲存器會連結至埠 42650

如果某個處理程序已使用埠 42650,導致 AutoTrace Webhook 進入損毀迴圈,因為它找到已連結的埠,您可以使用 webhook.pod.port 內容來變更該埠。

拒絕或拒絕

AutoTrace Webhook 會指示所有 Pod 中的所有容器。 不過,您可以進一步控制哪些特性已檢測,哪些未檢測。 透過在部署 Helm 圖表時設定 autotrace.opt_in=true 值, AutoTrace Webhook 會修改 Pod、抄本集、有狀態集、常駐程式集及帶有 instana-autotrace: "true" 標籤的部署。

不論 autotrace.opt_in的值為何, AutoTrace Webhook 不會接觸帶有 instana-autotrace: "false" 標籤的 Pod。

instana-autotrace: "false" 標籤在 DaemonSets、「部署」、 DeploymentConfigs、 ReplicaSets及 StatefulSets的 meta 資料中受到尊重,例如在巢狀 Pod 範本及獨立式 Pod 中。

忽略名稱空間

透過使用 autotrace.exclude.namespaces 配置,您可以從自動檢測中排除整個名稱空間。

不論名稱空間排除與否,都會檢測具有 instana-autotrace: "true" 標籤的資源。

instana-autotrace 標籤在 DaemonSets、「部署」、 DeploymentConfigs、 ReplicaSets及 StatefulSets的 meta 資料中受到尊重,例如在巢狀 Pod 範本及獨立式 Pod 中。

忽略資源

不論其他設定為何,都會忽略具有 instana-autotrace: "false" 標籤的資源。

instana-autotrace 標籤在 DaemonSets、「部署」、 DeploymentConfigs、 ReplicaSets及 StatefulSets的 meta 資料中受到尊重,例如在巢狀 Pod 範本及獨立式 Pod 中。

NGINX 和 ingress-nginx

若要啟動 NGINX 及 ingress-nginx 自動檢測,您必須透過設定 autotrace.ingress_nginx.enabled=true來接受。 請務必稍後閱讀疑難排解區段,並確定已更新或重建相關物件。

AutoTrace Webhook 在> = 0.34.1版中支援 Ingress-nginx Kubernetes Ingress 控制器,而且它與 Helm 圖表 (版本> = 2.11.2) 相容。

IBM MQ 和 ACE

若要啟動 IBM MQ 及 ACE 自動檢測,您必須透過設定 autotrace.ibmmq.enable=trueautotrace.ace.enable=true來接受。 AutoTrace Webhook 僅支援在 IBM Cloud Pak for Integration中執行的 IBM MQ 及 ACE。 IBM Cloud Pak for Integration 在 Red Hat OpenShift 叢集上執行,您還必須設定 openshift.enabled= true。 若要使用已啟用 IBM MQ 及 ACE 自動檢測來設定 Instana AutoTrace Webhook ,請輸入下列指令:

helm install --create-namespace --namespace instana-autotrace-webhook instana-autotrace-webhook \
  --repo https://agents.instana.io/helm instana-autotrace-webhook \
  --set webhook.imagePullCredentials.password=<download_key> \
  --set openshift.enabled=true \
  --set autotrace.ibmmq.enabled=true \
  --set autotrace.ace.enabled=true

Node.js ECMAScript 模組

當 Node.js 應用程式使用 ECMAScript 模組 (ES 模組) 時,請設定 autotrace.nodejs.esm=true。 在載入應用程式碼之前,「自動追蹤」Webhook 會使用 --experimental-loaders 引數而非 --require 引數載入並起始設定 Node.js 收集器。 遵循 更新手冊 ,以確保您位於最新版本的 Autotrace Webhook。

helm install --create-namespace --namespace instana-autotrace-webhook instana-autotrace-webhook \
  --repo https://agents.instana.io/helm instana-autotrace-webhook \
  --set webhook.imagePullCredentials.password=<download_key>
  --set autotrace.nodejs.esm=true

疑難排解

如果您未看到 Instana AutoTrace Webhook 影響您的新 Kubernetes 資源,則進行疑難排解的步驟如下。

確定 Instana AutoTrace Webhook 正在接收要求

若要使用 kubectl來檢查 instana-autotrace-webhook Pod 的日誌,請執行下列指令:

kubectl logs -l app.kubernetes.io/name=instana-autotrace-webhook -n instana-autotrace-webhook

在正常運作的安裝中,您可以看到下列日誌:

14:41:37.590 INFO  |- [AdmissionReview 48556a1a-7d55-497b-aa9c-23634b089cd1] Applied transformation DefaultDeploymentTransformation to the Deployment 'test-netcore-glibc/test-apps'
14:41:37.588 INFO  |- [AdmissionReview 1d5877cf-7153-4a95-9bfb-de0af8351195] Applied transformation DefaultDeploymentTransformation to the Deployment 'test-nodejs-12/test-apps'

如果您沒有看到類似這些日誌,則可能存在 Kubernetes 設定的問題,請參閱下列小節。

檢查 kube-apiserver 日誌

kube-apiserver的日誌會報告 Instana AutoTrace Webhook 是否正在啟動,如果已啟動,則會提供執行結果的相關資訊。

一般問題

kube-apiserver 與 instana-autotrace-webhook Pod 之間沒有網路連線功能

最常見的問題是由於安全原則, kube-apiserver 無法呼叫到執行 instana-autotrace-webhook Pod 的工作者節點,這會阻止 Instana AutoTrace Webhook 運作。 在此情況下,解決方案是變更網路設定,讓 kube-apiserver 可以存取 instana-autotrace-webhook Pod。 您無法提供如何解決此案例的指引,因為完全取決於您的設定。

Kube-apiserver 及 instana-autotrace-webhook Pod 無法協議 TLS 階段作業

另一個可能發生的零星問題是當加密法限制 (特別是可以將哪些演算法用於 TLS) 阻止 kube-apiserver from negotiating a TLS session with the instana-autotrace-webhook ` Pod 時。 在此情況下,請 開立問題單 ,並通知 Instana 支援叢集支援哪些加密法演算法。