This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.8.2. 更新日志转发自定义资源
OpenShift Container Platform Log Forward API 已从 OpenShift Container Platform 4.6 中的技术预览提升为正式发布。GA 发行版本包含一些改进和增强,需要您更改 ClusterLogging
自定义资源(CR),并将 LogForwarding
自定义资源(CR)替换为 ClusterLogForwarder
CR。
OpenShift Container Platform 4.6 中的 ClusterLogForwarder
实例示例
apiVersion: logging.openshift.io/v1 kind: ClusterLogForwarder metadata: name: instance namespace: openshift-logging .... spec: outputs: - url: http://remote.elasticsearch.com:9200 name: elasticsearch type: elasticsearch - url: tls://fluentdserver.example.com:24224 name: fluentd type: fluentdForward secret: name: fluentdserver pipelines: - inputRefs: - infrastructure - application name: mylogs outputRefs: - elasticsearch - inputRefs: - audit name: auditlogs outputRefs: - fluentd - default ...
apiVersion: logging.openshift.io/v1
kind: ClusterLogForwarder
metadata:
name: instance
namespace: openshift-logging
....
spec:
outputs:
- url: http://remote.elasticsearch.com:9200
name: elasticsearch
type: elasticsearch
- url: tls://fluentdserver.example.com:24224
name: fluentd
type: fluentdForward
secret:
name: fluentdserver
pipelines:
- inputRefs:
- infrastructure
- application
name: mylogs
outputRefs:
- elasticsearch
- inputRefs:
- audit
name: auditlogs
outputRefs:
- fluentd
- default
...
OpenShift Container Platform 4.5 中的 ClusterLogForwarder
CR 示例
apiVersion: logging.openshift.io/v1alpha1 kind: LogForwarding metadata: name: instance namespace: openshift-logging spec: disableDefaultForwarding: true outputs: - name: elasticsearch type: elasticsearch endpoint: remote.elasticsearch.com:9200 - name: fluentd type: forward endpoint: fluentdserver.example.com:24224 secret: name: fluentdserver pipelines: - inputSource: logs.infra name: infra-logs outputRefs: - elasticearch - inputSource: logs.app name: app-logs outputRefs: - elasticearch - inputSource: logs.audit name: audit-logs outputRefs: - fluentd
apiVersion: logging.openshift.io/v1alpha1
kind: LogForwarding
metadata:
name: instance
namespace: openshift-logging
spec:
disableDefaultForwarding: true
outputs:
- name: elasticsearch
type: elasticsearch
endpoint: remote.elasticsearch.com:9200
- name: fluentd
type: forward
endpoint: fluentdserver.example.com:24224
secret:
name: fluentdserver
pipelines:
- inputSource: logs.infra
name: infra-logs
outputRefs:
- elasticearch
- inputSource: logs.app
name: app-logs
outputRefs:
- elasticearch
- inputSource: logs.audit
name: audit-logs
outputRefs:
- fluentd
以下操作过程显示了您必须更改的每个参数。
流程
要将 4.5 中的 ClusterLogForwarder
CR 更新至 ClusterLogForwarding
CR 4.6,请进行以下修改:
编辑
ClusterLogging
自定义资源(CR)以删除logforwardingtechpreview
注解:ClusterLogging
CR 示例apiVersion: "logging.openshift.io/v1" kind: "ClusterLogging" metadata: annotations: clusterlogging.openshift.io/logforwardingtechpreview: enabled name: "instance" namespace: "openshift-logging" ....
apiVersion: "logging.openshift.io/v1" kind: "ClusterLogging" metadata: annotations: clusterlogging.openshift.io/logforwardingtechpreview: enabled
1 name: "instance" namespace: "openshift-logging" ....
Copy to Clipboard Copied! - 1
- 删除
logforwardingtechpreview
注解。
导出
ClusterLogForwarder
CR,为ClusterLogForwarder
实例创建一个 YAML 文件:oc get LogForwarding instance -n openshift-logging -o yaml| tee ClusterLogForwarder.yaml
$ oc get LogForwarding instance -n openshift-logging -o yaml| tee ClusterLogForwarder.yaml
Copy to Clipboard Copied! 编辑 YAML 文件进行以下修改:
OpenShift Container Platform 4.6 中的
ClusterLogForwarder
实例示例apiVersion: logging.openshift.io/v1 kind: ClusterLogForwarder metadata: name: instance namespace: openshift-logging .... spec: outputs: - url: http://remote.elasticsearch.com:9200 name: elasticsearch type: elasticsearch - url: tls://fluentdserver.example.com:24224 name: fluentd type: fluentdForward secret: name: fluentdserver pipelines: - inputRefs: - infrastructure - application name: mylogs outputRefs: - elasticsearch - inputRefs: - audit name: auditlogs outputRefs: - fluentd - default ...
apiVersion: logging.openshift.io/v1
1 kind: ClusterLogForwarder
2 metadata: name: instance namespace: openshift-logging .... spec:
3 outputs: - url: http://remote.elasticsearch.com:9200
4 name: elasticsearch type: elasticsearch - url: tls://fluentdserver.example.com:24224 name: fluentd type: fluentdForward
5 secret: name: fluentdserver pipelines: - inputRefs:
6 - infrastructure - application name: mylogs outputRefs: - elasticsearch - inputRefs: - audit name: auditlogs outputRefs: - fluentd - default
7 ...
Copy to Clipboard Copied! - 1
- 将
apiVersion
从"logging.openshift.io/v1alpha1"
改为"logging.openshift.io/v1"
。 - 2
- 将对象类型从
kind: "LogForwarding"
改为kind: "ClusterLogForwarder"
。 - 3
- 删除
disableDefaultForwarding: true
参数。 - 4
- 将 output 参数从
spec.outputs.endpoint
改为spec.outputs.url
。如果 URL 没有前缀,请在 URL 中添加前缀,如https://
、tcp://
等。 - 5
- 对于 Fluentd 输出,请将
type
从forward
改为fluentdForward
。 - 6
- 更改管道:
-
将
spec.pipelines.inputSource
更改为spec.pipelines.inputRefs
-
将
logs.infra
改为infrastructure
-
将
logs.app
改为application
-
将
logs.audit
改为audit
-
将
- 7
- 可选:添加一个
default
管道来将日志发送到内部 Elasticsearch 实例。您不需要配置default
输出。注意如果您只希望将日志转发到内部 OpenShift Container Platform Elasticsearch 实例,请不要配置 Log Forwarding API。
创建 CR 对象。
oc create -f ClusterLogForwarder.yaml
$ oc create -f ClusterLogForwarder.yaml
Copy to Clipboard Copied!
有关 Log Forwarding API 新功能的信息,请参阅将日志转发到第三方系统。