使用Helm圖表部署記載代理程式的模板
您可以使用 Helm 圖表來部署 記載代理程式,從 Red Hat OpenShift on IBM Cloud (OpenShift) 群集或 Kubernetes 群集收集基礎結構和應用程式日誌,並將其路由至 IBM Cloud Logs 實例。
在 Openshift 叢集上使用Helm圖表部署記載代理程式的模板
metadata:
name: "logs-agent"
image:
version: "1.3.0" # required
clusterName: "" # Enter the name of your cluster. This information is used to improve the metadata and help with your filtering.
env:
# ingestionHost is a required field. For example:
# ingestionHost: "<logs instance>.ingress.us-east.logs.cloud.ibm.com"
ingestionHost: "" # required
# If you are using private CSE proxy, then use port number "3443"
# If you are using private VPE Gateway, then use port number "443"
# If you are using the public endpoint, then use port number "443"
ingestionPort: "" # required
iamMode: "TrustedProfile"
# trustedProfileID - trusted profile id - required if iamMode is set to "TrustedProfile"
trustedProfileID: ""
# Configure this parameter to control the IAM endpoint used by the agent to exchange the tokens.
# If omitted, the default value is "Production".
# Valid values are :
# "Production" to use the iam.cloud.ibm.com default endpoint
# "PrivateProduction" to use the private.iam.cloud.ibm.com endpoint
# "Custom" to use a custom provided IAM endpoint
iamEnvironment: "Production"
# iamHost - custom IAM endpoint (for example: private.eu-de.iam.cloud.ibm.com) - required if iamEnvironment is set to "Custom"
iamHost: ""
scc:
# true enables creation of Security Context Constraints in Openshift clusters
create: true
defaultMetadata:
# Configure to override the default subsystemName and applicationName that are used in the environment.
subsystemName: "" # The default value is set to the namespace that generated the log
applicationName: "" # The default value is set to the container name that generated the log
resources:
# Configure this section to change the resources that are assigned to the agent container.
limits:
cpu: 500m
ephemeral_storage: 10Gi
memory: 3Gi
requests:
cpu: 100m
ephemeral_storage: 2Gi
memory: 1Gi
# Configure these parameters to include, exclude or restrict the set of logs that are processed by the agent
# By default, the agent will collect the logs from `/var/log/containers/*.log`.
# Each field is set as comma separated list, for example “/var/log/abc/*.log,/var/log/xyz/*.log”
additionalLogSourcePaths: "" # adds locations to the default set of logs that will be processed.
excludeLogSourcePaths: "" # ignores logs in the specified locations.
selectedLogSourcePaths: "" # overrides the default path `/var/log/containers/*.log` and ignores the `additionalLogSourcePaths` configurations
# Configure this parameter to change the setting for the Kubernetes filter to include the annotations from Kubernetes with the log records.
# The default value for this setting is `false`.
includeAnnotations: true
# Configure this parameter to control the number of times the agent will retry sending data if an error occurs that is considered to be retryable.
# The default is `False`.
# For more information, see the [Fluentbit documentation about retries](https://docs.fluentbit.io/manual/administration/scheduling-and-retries) to understand the implications of setting this value.
retryLimit: False
# Configure additional tags as key/value pair tags that can be added as metadata to every log line.
additionalMetadata:
# region: ca-tor
# env: production
# Configure the level of logging
# Default value is info
# Valid values are: debug, info, or error
loggingLevel: info
在Kubernetes叢集上使用Helm圖表部署記載代理程式的模板
metadata:
name: "logs-agent"
image:
version: "1.3.0" # required
clusterName: "" # Enter the name of your cluster. This information is used to improve the metadata and help with your filtering.
env:
# ingestionHost is a required field. For example:
# ingestionHost: "<logs instance>.ingress.us-east.logs.cloud.ibm.com"
ingestionHost: "" # required
# If you are using private CSE proxy, then use port number "3443"
# If you are using private VPE Gateway, then use port number "443"
# If you are using the public endpoint, then use port number "443"
ingestionPort: "" # required
iamMode: "TrustedProfile"
# trustedProfileID - trusted profile id - required for iam trusted profile mode
trustedProfileID: "" # required if iamMode is set to TrustedProfile
# Configure this parameter to control the IAM endpoint used by the agent to exchange the tokens.
# If omitted, the default value is "Production".
# Valid values are :
# "Production" to use the iam.cloud.ibm.com default endpoint
# "PrivateProduction" to use the private.iam.cloud.ibm.com endpoint
# "Custom" to use a custom provided IAM endpoint
iamEnvironment: "Production"
# iamHost - custom IAM endpoint (for example: private.eu-de.iam.cloud.ibm.com) - required if iamEnvironment is set to "Custom"
iamHost: ""
scc:
# true enables creation of Security Context Constraints in Openshift clusters
# set to false for Kubernetes clusters
create: false
defaultMetadata:
# Configure to override the default subsystemName and applicationName that are used in the environment.
subsystemName: "" # The default value is set to the namespace that generated the log
applicationName: "" # The default value is set to the container name that generated the log
resources:
# Configure this section to change the resources that are assigned to the agent container.
limits:
cpu: 500m
ephemeral_storage: 10Gi
memory: 3Gi
requests:
cpu: 100m
ephemeral_storage: 2Gi
memory: 1Gi
# Configure these parameters to include, exclude or restrict the set of logs that are processed by the agent
# By default, the agent will collect the logs from `/var/log/containers/*.log`.
# Each field is set as comma separated list, for example “/var/log/abc/*.log,/var/log/xyz/*.log”
additionalLogSourcePaths: "" # adds locations to the default set of logs that will be processed.
excludeLogSourcePaths: "" # ignores logs in the specified locations.
selectedLogSourcePaths: "" # overrides the default path `/var/log/containers/*.log` and ignores the `additionalLogSourcePaths` configurations
# Configure this parameter to change the setting for the Kubernetes filter to include the annotations from Kubernetes with the log records.
# The default value for this setting is `false`.
includeAnnotations: true
# Configure this parameter to control the number of times the agent will retry sending data if an error occurs that is considered to be retryable.
# The default is `False`.
# For more information, see the [Fluentbit documentation about retries](https://docs.fluentbit.io/manual/administration/scheduling-and-retries) to understand the implications of setting this value.
retryLimit: False
# Configure additional tags as key/value pair tags that can be added as metadata to every log line.
additionalMetadata:
# region: ca-tor
# env: production
# Configure the level of logging
# Default value is info
# Valid values are: debug, info, or error
loggingLevel: info
Helm 圖表設定選項
下表包含您可以在 logs-values.yaml 檔案中設定以調整記載代理程式配置的參數清單:
| 參數 | 說明 | 狀態 | 預設值 |
|---|---|---|---|
metadata.name |
用於所有Kubernetes資源的代理程式的名稱 | 必要 | logs-agent |
image.version |
代理容器映像的版本(即1.3.0 ) | 必要 | 沒有預設值 |
env.ingestionHost |
將日誌傳送到的IBM Cloud Logs主機 | 必要 | 沒有預設值 |
env.ingestionPort |
將日誌傳送到的IBM Cloud Logs端口 | 必要 | 沒有預設值 |
env.iamMode |
指示使用的 IAM 驗證機制。 有效值為:TrustedProfile 或 IAMAPIKey |
必要 | TrustedProfile |
env.trustedProfileID |
受信任的設定檔 ID。 | 當 iamMode=TrustedProfile 時需要此參數 |
沒有預設值 |
env.iamEnvironment |
控制代理用於交換令牌的 IAM 終端節點。 有關更多信息,請參閱 iamEnvironment。 |
必要 | Production |
env.iamHost |
用於自訂 IAM 環境的主機名稱。 | 如果 iamEnviroment 設定為 Custom,則必須使用。 |
沒有預設值 |
secret.iamAPIKey |
API 金鑰 ID。 您應該僅透過 CLI 提供此值。 如需相關資訊,請參閱 env.iamMode。 |
當 iamMode=IAMAPIKey 時需要此參數 |
沒有預設值 |
clusterName |
kubernetes 群集的名稱 | 選用 | 沒有預設值 |
scc.create |
指示何時在 Openshift 中建立安全上下文約束 | 僅 Openshift 叢集部署需要。 | false |
defaultMetadata.subsystemName |
用於覆寫IBM Cloud Logs中的subsystemName的靜態字串 | 選用 | 預設值設定為生成日誌的命名空間 |
defaultMetadata.applicationName |
用於覆寫IBM Cloud Logs中的applicationName的靜態字串 | 選用 | 預設值設定為產生日誌的容器名稱 |
resources |
覆蓋分配給logs-agent的kubernetes資源 | 選用 | 請參閱 資源 以查看預設值 |
additionalLogSourcePaths |
預設之外的附加日誌的路徑。/var/log/containers/*.log 有關詳細信息,請參閱 日誌來源路徑配置。 |
選用 | 沒有預設值 |
excludeLogSourcePaths |
代理不應收集的其他日誌的路徑。 有關更多信息,請參閱 日誌來源路徑配置。 |
選用 | 沒有預設值 |
selectedLogSourcePaths |
代理程式收集的日誌的路徑,不包括預設路徑和additionalLogSourcePaths中配置的任何檔案。有關更多信息,請參閱 日誌來源路徑配置。 |
選用 | 沒有預設值 |
includeAnnotations |
指示 kubernetes 插件將容器註釋包含在日誌訊息 中(有關更多信息,請參閱[includeAnnotations] #agent-helm-template-clusters-chart-options-include-annotations)。 |
必要 | false |
retryLimit |
限制將嘗試的重試次數 有關詳細信息,請參閱 retryLimit |
必要 | 否 |
loggingLevel |
代理本身應報告的日誌類型。 有效值為:debug、info 或 error。 |
必要 | info |
additionalMetadata |
可以作為元資料新增至每個日誌行的鍵/值對標籤清單。 有關更多信息,請參閱 additionalMetadata。 |
選用 | 沒有預設值 |
env.iamMode
設定此參數以選擇代理程式在將日誌傳送至IBM Cloud Logs實例時所使用的驗證方法。
- 您可以選擇 IAM APIKey 或可信任設定檔配置。
- 有效值為:
TrustedProfile或IAMAPIKey - 預設值是受信任的設定檔配置。
logs-values.yaml 文件中的條目如下所示:
env:
iamMode: IAMAPIKey
設定此參數時請考慮以下資訊:
-
如果設定了
env.iamMode: "TrustedProfile",則也必須提供env.trustedProfileID變數。 -
如果設定了
env.iamMode: "IAMAPIKey",則設定需要定義一個包含具有權限的 IAM Apikey 的金鑰。如果在 helm 指令中提供了
secret.iamAPIKey變數 (例如--set secret.iamAPIKey=<your iamAPIKey>),則 helm 圖表將建立 Kubernetes secret。或者,您可以使用以下命令提前建立金鑰:(確保您已連接到叢集。)
kubectl create secret generic <helm install-name> -n ibm-observe --from-literal=IAM_API_KEY=<apikey>
defaultMetadata
此部分允許使用者覆蓋環境中使用的預設subsystemName和applicationName。 預設情況下,未設定這些值,輸出外掛程式將動態地將這些值設為:
- subsystemName:產生日誌的Kubernetes命名空間
- applicationName:產生日誌的容器名稱
logs-values.yaml 文件中的條目如下所示:
defaultMetadata:
subsystemName: ""
applicationName: ""
資源
此部分允許使用者變更指派給記載代理程式容器的資源。
logs-values.yaml 文件中的條目如下所示並設定以下預設值:
resources:
limits:
cpu: 500m
ephemeral_storage: 10Gi
memory: 3Gi
requests:
cpu: 100m
ephemeral_storage: 2Gi
memory: 1Gi
如果您需要更新任何值,即使您不更新所有值,也必須提供整個配置。
日誌來源路徑配置
預設情況下,代理將從 /var/log/containers/*.log 收集日誌。
可以提供以下附加變數來包含、排除或限制要處理的日誌集:
additionalLogSourcePaths將位置新增至將處理的預設日誌集中。excludeLogSourcePaths忽略指定位置的日誌。selectedLogSourcePaths覆蓋預設路徑/var/log/containers/*.log並忽略additionalLogSourcePaths配置。 代理僅收集透過此參數設定的檔案。
您可以使用逗號分隔清單來定義多個路徑,例如「/var/log/abc/.log,/var/log/xyz/.log」。
logs-values.yaml 文件中的條目如下所示:
# comma separated list, for example “/var/log/abc/*.log,/var/log/xyz/*.log”
additionalLogSourcePaths: ""
excludeLogSourcePaths: ""
selectedLogSourcePaths: ""
env.iamEnvironment
此配置控制代理用於交換令牌的 IAM 終端節點。
預設值為 Production。
有效值為:
- 設定
Production使用iam.cloud.ibm.com預設端點 - 設定
PrivateProduction使用private.iam.cloud.ibm.com端點 - 設定
Custom為使用自訂 IAM 端點 (例如 private.eu-de.iam.cloud.ibm.com )
logs-values.yaml 文件中的條目如下所示:
env:
iamEnvironment: "Production"
對於 Custom iamEnvironment 設定,必須同時提供 iamHost。
env:
iamEnvironment: "Custom"
iamHost: "private.eu-de.iam.cloud.ibm.com"
includeAnnotations
此配置變更Kubernetes過濾器的設置,以將來自Kubernetes的註解包含在日誌記錄中。
此設定的預設值為 false。
logs-values.yaml 文件中的條目如下所示:
includeAnnotations: true
retryLimit
如果發生可重試的錯誤,此配置會限制代理重試傳送資料的次數。
預設值為 False。
有關更多信息,請參閱 有關重試的 Fluentbit 文檔, 以了解設定此值的含義。
在某些情況下,此設定可能會導致日誌資料因無法傳送而被代理丟棄。
logs-values.yaml 文件中的條目如下所示:
retryLimit: 8
additionalMetadata
這是將添加到 meta 物件下以允許附加標籤的鍵/值對列表。
logs-values.yaml 文件中的條目如下所示:
additionalMetadata:
region: ca-tor
env: production
上面的範例將導致以下附加欄位新增至IBM Cloud Logs中的每個日誌行:
{
"meta": {
"region": "ca-tor",
"env": "production"
}
}