1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Oracle Cloud] OKE の Audit Log を確認してみた

Last updated at Posted at 2020-07-18

はじめに

OKE では、最近のアップデートで、Kubernetes API Service の Log が Audit に表示されるようになりました。リリースノートはこちら。
https://docs.cloud.oracle.com/en-us/iaas/releasenotes/changes/a89a7913-bba7-4622-80fd-c493b1a35b65/

どんな感じのログが表示されるか確認してみましょう。

Audit のパラメータ

Audit の画面で、検索 KEYWORDS を入力できます。次の物を入力すると、絞り込みが出来ることがわかりました。

  • OKE に関するイベント : OKE API Server Admin Access
  • Deployment の作成削除などに関するイベント : apps.v1.deployments

1595038560631.png

なお、時間の指定にも若干コツが必要です。選択肢は30分ごとになっており、端数は提供されていません。

1595039533255.png

細かな端数を入力することも可能ですが、操作にコツが必要です。普通にキーボード上で入力するのとはちょっと違います。まず、変更したい文字を1文字マウスで選択して

1595039633005.png

入力したい文字を入力すれば、変更できます

1595039665271.png

Deoloyment Delete

Deployment を削除したときの、Event Name は apps.v1.deployments.delete として見えてきます。

1595036349408.png

詳細な内容を見ていきましょう。次のものが確認できます。

  • eventTime : イベントが発生した時間
  • data.resourceId : OKE クラスタの OCID
  • data.identity.principalName : User の OCID
  • data.identity.userAgent : kubectl 上の操作なのか、プログラム上での操作なのか、というのがざっくりわかる
  • data.request.path : Request の対象
  • data.request.action : Request の操作タイプ
  • data.request.status : Request した結果の Status
{
  "eventType": "apps.v1.deployments.delete",
  "cloudEventsVersion": "0.1",
  "eventTypeVersion": "2.0",
  "source": "OKE API Server Admin Access",
  "eventId": "684ea840-9746-4d9b-94b4-99b9e60640c2",
  "eventTime": "2020-07-18T01:30:14.028Z",
  "contentType": "application/json",
  "data": {
    "eventGroupingId": "684ea840-9746-4d9b-94b4-99b9e60640c2",
    "eventName": "apps.v1.deployments.delete",
    "compartmentId": "ocid1.compartment.oc1..aaaaaaaalxxd67fpsduvby7s3cj2ykm3bbl4myg37atkky27ipvfxv5iepda",
    "compartmentName": "testcompartment01",
    "resourceName": "",
    "resourceId": "ocid1.cluster.oc1.ap-tokyo-1.aaaaaaaaae2gkzjuguytqyrwhbtggnbzmm3geyjwhaytinlehc3tmzdggizt",
    "availabilityDomain": null,
    "freeformTags": null,
    "definedTags": null,
    "identity": {
      "principalName": "ocid1.user.oc1..aaaaaaaadrqej7fxvbzbw7h6i7eddjxqgqn5jlaxwelgk7kmwo2gj4lmxxua",
      "principalId": null,
      "authType": "Native",
      "callerName": null,
      "callerId": null,
      "tenantId": "ocid1.tenancy.oc1..aaaaaaaasurxdp6xanscptpkod7jmfe6wyi7hiwo5idollgw7lyjn6bixyzq",
      "ipAddress": null,
      "credentials": "",
      "userAgent": "kubectl/v1.18.5 (linux/amd64) kubernetes/e6503f8",
      "consoleSessionId": null
    },
    "request": {
      "id": "684ea840-9746-4d9b-94b4-99b9e60640c2",
      "path": "/apis/apps/v1/namespaces/default/deployments/cowweb",
      "action": "DELETE",
      "parameters": null,
      "headers": null
    },
    "response": {
      "status": "200",
      "responseTime": "2020-07-18T01:30:14.036Z",
      "headers": null,
      "payload": null,
      "message": ""
    },
    "stateChange": null,
    "additionalDetails": null
  }
}

Deployment Create

Deployment を作成したときの、Event Name は apps.v1.deployments.create として見えてきます。

1595038089107.png

詳細な内容を見ていきましょう。次のものが確認できます。

  • eventTime : イベントが発生した時間
  • data.resourceId : OKE クラスタの OCID
  • data.identity.principalName : User の OCID
  • data.identity.userAgent : kubectl 上の操作なのか、プログラム上での操作なのか、というのがざっくりわかる
  • data.request.path : Request の対象
  • data.request.action : Request の操作タイプ
  • data.request.status : Request した結果の Status
{
  "eventType": "apps.v1.deployments.create",
  "cloudEventsVersion": "0.1",
  "eventTypeVersion": "2.0",
  "source": "OKE API Server Admin Access",
  "eventId": "8d4ad06a-35b2-45b3-a1ff-6a4fba9904b4",
  "eventTime": "2020-07-18T02:04:30.278Z",
  "contentType": "application/json",
  "data": {
    "eventGroupingId": "8d4ad06a-35b2-45b3-a1ff-6a4fba9904b4",
    "eventName": "apps.v1.deployments.create",
    "compartmentId": "ocid1.compartment.oc1..aaaaaaaalxxd67fpsduvby7s3cj2ykm3bbl4myg37atkky27ipvfxv5iepda",
    "compartmentName": "testcompartment01",
    "resourceName": "",
    "resourceId": "ocid1.cluster.oc1.ap-tokyo-1.aaaaaaaaae2gkzjuguytqyrwhbtggnbzmm3geyjwhaytinlehc3tmzdggizt",
    "availabilityDomain": null,
    "freeformTags": null,
    "definedTags": null,
    "identity": {
      "principalName": "ocid1.user.oc1..aaaaaaaadrqej7fxvbzbw7h6i7eddjxqgqn5jlaxwelgk7kmwo2gj4lmxxua",
      "principalId": null,
      "authType": "Native",
      "callerName": null,
      "callerId": null,
      "tenantId": "ocid1.tenancy.oc1..aaaaaaaasurxdp6xanscptpkod7jmfe6wyi7hiwo5idollgw7lyjn6bixyzq",
      "ipAddress": null,
      "credentials": "",
      "userAgent": "kubectl/v1.18.5 (linux/amd64) kubernetes/e6503f8",
      "consoleSessionId": null
    },
    "request": {
      "id": "8d4ad06a-35b2-45b3-a1ff-6a4fba9904b4",
      "path": "/apis/apps/v1/namespaces/default/deployments",
      "action": "POST",
      "parameters": null,
      "headers": null
    },
    "response": {
      "status": "201",
      "responseTime": "2020-07-18T02:04:30.284Z",
      "headers": null,
      "payload": null,
      "message": ""
    },
    "stateChange": {
      "previous": {
        "requestObject": null
      },
      "current": {
        "responseObject": null
      }
    },
    "additionalDetails": null
  }
}

参考URL

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?