請按照以下指示,在使用適用於 vSphere 7.x 的 TKr 佈建的 TKG 叢集上安裝 Fluent Bit。
必要條件
安裝 Fluent Bit
安裝 Fluent Bit 以轉送記錄。
- 列出存放庫中可用的 Fluent Bit 版本。
kubectl -n tkg-system get packages | grep fluent-bit
- 建立命名空間。
kubectl create ns tanzu-system-logging
- 標示 PSA 的命名空間。
kubectl label ns fluentbit-logging pod-security.kubernetes.io/enforce=privileged
或者,也可以:apiVersion: v1 kind: Namespace metadata: name: fluentbit-logging --- apiVersion: v1 kind: Namespace metadata: name: fluentbit-logging labels: pod-security.kubernetes.io/enforce: privileged
- 準備
fluentbit.yaml
。請參閱
- 根據您的環境需求自訂
fluentbit-data-values
。如需組態參數,請參閱 Fluent Bit 套件參考。
- 安裝 Fluent Bit。
kubectl apply -f fluentbit.yaml
- 驗證 Fluent Bit 安裝。
kubectl get all -n fluentbit-logging
fluentbit.yaml
下列範例可用於 Syslog 端點。根據需要更新套件版本。
apiVersion: v1 kind: ServiceAccount metadata: name: fluentbit-sa namespace: tkg-system annotations: pod-security.kubernetes.io/enforce: "privileged" --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: fluentbit-role-binding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: fluentbit-sa namespace: tkg-system --- apiVersion: packaging.carvel.dev/v1alpha1 kind: PackageInstall metadata: name: fluentbit namespace: tkg-system spec: serviceAccountName: fluentbit-sa packageRef: refName: fluent-bit.tanzu.vmware.com versionSelection: constraints: 2.1.6+vmware.1-tkg.2 #PKG_VERSION values: - secretRef: name: fluentbit-data-values --- apiVersion: v1 kind: Secret metadata: name: fluentbit-data-values namespace: tkg-system stringData: values.yml: | --- namespace: tanzu-system-logging tkg: instance_name: "guest-cluster" #TKG_INSTANCE_NAME cluster_name: "tkgs-vc-wl" #TKG_CLUSTER_NAME fluentbit: output_plugin: "syslog" syslog: host: "10.202.27.235" #SYSLOG_HOST port: "514" #SYSLOG_PORT mode: "tcp" #SYSLOG_MODE format: "rfc5424" #SYSLOG_FORMAT