8.2. ログ転送カスタムリソースの更新
OpenShift Container Platform 4.6 では、OpenShift Container Platform ログ転送 API はテクノロジープレビューから一般利用が可能となりました。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 ...
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
以下の手順では、変更が必要な各パラメーターを示しています。
手順
4.5 の ClusterLogForwarder
CR を 4.6 の ClusterLogForwarding
に更新するには、以下の変更を行います。
ClusterLogging
カスタムリソース (CR) を編集してlogforwardingtechpreview
アノテーションを削除します。ClusterLogging
CR の例apiVersion: "logging.openshift.io/v1" kind: "ClusterLogging" metadata: annotations: clusterlogging.openshift.io/logforwardingtechpreview: enabled 1 name: "instance" namespace: "openshift-logging" ....
- 1
logforwardingtechpreview
アノテーションを削除します。
ClusterLogForwarder
CR をエクスポートし、ClusterLogForwarder
インスタンスの YAML ファイルを作成します。$ oc get LogForwarding instance -n openshift-logging -o yaml| tee ClusterLogForwarder.yaml
YAML ファイルを編集して以下の変更を加えます。
OpenShift Container Platform 4.6 の
ClusterLogForwarder
インスタンスのサンプル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 ...
- 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
に変更します。接頭辞がない場合は、https://
やtcp://
など、URL に接頭辞を追加します。 - 5
- Fluentd 出力の場合は、
type
をforward
からfluentdForward
に変更します。 - 6
- Pipeline を変更します。
-
spec.pipelines.inputSource
をspec.pipelines.inputRefs
に変更します。 -
logs.infra
をinfrastructure
に変更します。 -
logs.app
をapplication
に変更します。 -
logs.audit
をaudit
に変更します。
-
- 7
- オプション: ログを内部 Elasticsearch インスタンスに送信するために
default
のパイプラインを追加します。default
の出力を設定する必要はありません。注記ログを内部の OpenShift Container Platform Elasticsearch インスタンスのみに転送する必要がある場合は、ログ転送 API を設定しないようにしてください。
CR オブジェクトを作成します。
$ oc create -f ClusterLogForwarder.yaml
ログ転送 API の新機能の詳細は、ログのサードパーティーシステムへの転送 を参照してください。