From 94e021ccf639c379b602c40a4d1e497a7d08e1a5 Mon Sep 17 00:00:00 2001 From: Qiming Teng Date: Thu, 18 Feb 2021 15:58:36 +0800 Subject: [PATCH] Add reference for audit API group This is a reference for audit.k8s.io/v1 API group generated from kubernetes-sigs/reference-docs/genref tool. More specifically, it is generated using the following command: ```shell ./genref -include apiserver-audit ``` --- content/en/docs/reference/_index.md | 18 +- .../config-api/apiserver-audit.v1.md | 620 ++++++++++++++++++ .../tasks/debug-application-cluster/audit.md | 17 +- 3 files changed, 641 insertions(+), 14 deletions(-) create mode 100644 content/en/docs/reference/config-api/apiserver-audit.v1.md diff --git a/content/en/docs/reference/_index.md b/content/en/docs/reference/_index.md index 29dfca82b7..7315d27fbb 100644 --- a/content/en/docs/reference/_index.md +++ b/content/en/docs/reference/_index.md @@ -52,7 +52,9 @@ client libraries: * [kubelet](/docs/reference/command-line-tools-reference/kubelet/) - The primary agent that runs on each node. The kubelet takes a set of PodSpecs and ensures that the described containers are running and healthy. -* [kube-apiserver](/docs/reference/command-line-tools-reference/kube-apiserver/) - REST API that validates and configures data for API objects such as pods, services, replication controllers. +* [kube-apiserver](/docs/reference/command-line-tools-reference/kube-apiserver/) - + REST API that validates and configures data for API objects such as pods, + services, replication controllers. * [kube-controller-manager](/docs/reference/command-line-tools-reference/kube-controller-manager/) - Daemon that embeds the core control loops shipped with Kubernetes. * [kube-proxy](/docs/reference/command-line-tools-reference/kube-proxy/) - Can do simple TCP/UDP stream forwarding or round-robin TCP/UDP forwarding across @@ -64,13 +66,15 @@ client libraries: ## Config APIs +This section hosts the documentation for "unpublished" APIs which are used to +configure kubernetes components or tools. Most of these APIs are not exposed +by the API server in a RESTful way though they are essential for a user or an +operator to use or manage a cluster. + +* [kubelet configuration (v1beta1)](/docs/reference/config-api/kubelet-config.v1beta1/) +* [kube-scheduler configuration (v1beta1)](/docs/reference/config-api/kube-scheduler-config.v1beta1/) * [kube-proxy configuration (v1alpha1)](/docs/reference/config-api/kube-proxy-config.v1alpha1/) -* [kube-scheduler config (v1beta1)](/docs/reference/config-api/kube-scheduler-config.v1beta1/) - - -## Config APIs - -* [kubelet config (v1beta1)](/docs/reference/config-api/kubelet-config.v1beta1/) +* [`audit.k8s.io/v1` API](/docs/reference/config-api/apiserver-audit.v1/) ## Design Docs diff --git a/content/en/docs/reference/config-api/apiserver-audit.v1.md b/content/en/docs/reference/config-api/apiserver-audit.v1.md new file mode 100644 index 0000000000..f0f36c2344 --- /dev/null +++ b/content/en/docs/reference/config-api/apiserver-audit.v1.md @@ -0,0 +1,620 @@ +--- +title: kube-apiserver Audit Configuration (v1) +content_type: tool-reference +package: audit.k8s.io/v1 +auto_generated: true +--- + + +## Resource Types + + +- [Event](#audit-k8s-io-v1-Event) +- [EventList](#audit-k8s-io-v1-EventList) +- [Policy](#audit-k8s-io-v1-Policy) +- [PolicyList](#audit-k8s-io-v1-PolicyList) + + + + +## `Event` {#audit-k8s-io-v1-Event} + + + + +**Appears in:** + +- [EventList](#audit-k8s-io-v1-EventList) + + +Event captures all the information that can be included in an API audit log. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
apiVersion
string
audit.k8s.io/v1
kind
string
Event
level [Required]
+Level +
+ AuditLevel at which event was generated
auditID [Required]
+k8s.io/apimachinery/pkg/types.UID +
+ Unique audit ID, generated for each request.
stage [Required]
+Stage +
+ Stage of the request handling when this event instance was generated.
requestURI [Required]
+string +
+ RequestURI is the request URI as sent by the client to a server.
verb [Required]
+string +
+ Verb is the kubernetes verb associated with the request. +For non-resource requests, this is the lower-cased HTTP method.
user [Required]
+authentication/v1.UserInfo +
+ Authenticated user information.
impersonatedUser
+authentication/v1.UserInfo +
+ Impersonated user information.
sourceIPs
+[]string +
+ Source IPs, from where the request originated and intermediate proxies.
userAgent
+string +
+ UserAgent records the user agent string reported by the client. +Note that the UserAgent is provided by the client, and must not be trusted.
objectRef
+ObjectReference +
+ Object reference this request is targeted at. +Does not apply for List-type requests, or non-resource requests.
responseStatus
+meta/v1.Status +
+ The response status, populated even when the ResponseObject is not a Status type. +For successful responses, this will only include the Code and StatusSuccess. +For non-status type error responses, this will be auto-populated with the error Message.
requestObject
+k8s.io/apimachinery/pkg/runtime.Unknown +
+ API object from the request, in JSON format. The RequestObject is recorded as-is in the request +(possibly re-encoded as JSON), prior to version conversion, defaulting, admission or +merging. It is an external versioned object type, and may not be a valid object on its own. +Omitted for non-resource requests. Only logged at Request Level and higher.
responseObject
+k8s.io/apimachinery/pkg/runtime.Unknown +
+ API object returned in the response, in JSON. The ResponseObject is recorded after conversion +to the external type, and serialized as JSON. Omitted for non-resource requests. Only logged +at Response Level.
requestReceivedTimestamp
+meta/v1.MicroTime +
+ Time the request reached the apiserver.
stageTimestamp
+meta/v1.MicroTime +
+ Time the request reached current audit stage.
annotations
+map[string]string +
+ Annotations is an unstructured key value map stored with an audit event that may be set by +plugins invoked in the request serving chain, including authentication, authorization and +admission plugins. Note that these annotations are for the audit event, and do not correspond +to the metadata.annotations of the submitted object. Keys should uniquely identify the informing +component to avoid name collisions (e.g. podsecuritypolicy.admission.k8s.io/policy). Values +should be short. Annotations are included in the Metadata level.
+ + + +## `EventList` {#audit-k8s-io-v1-EventList} + + + + + +EventList is a list of audit Events. + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
apiVersion
string
audit.k8s.io/v1
kind
string
EventList
metadata
+meta/v1.ListMeta +
+ No description provided. +
items [Required]
+[]Event +
+ No description provided. +
+ + + +## `Policy` {#audit-k8s-io-v1-Policy} + + + + +**Appears in:** + +- [PolicyList](#audit-k8s-io-v1-PolicyList) + + +Policy defines the configuration of audit logging, and the rules for how different request +categories are logged. + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
apiVersion
string
audit.k8s.io/v1
kind
string
Policy
metadata
+meta/v1.ObjectMeta +
+ ObjectMeta is included for interoperability with API infrastructure.Refer to the Kubernetes API documentation for the fields of the metadata field.
rules [Required]
+[]PolicyRule +
+ Rules specify the audit Level a request should be recorded at. +A request may match multiple rules, in which case the FIRST matching rule is used. +The default audit level is None, but can be overridden by a catch-all rule at the end of the list. +PolicyRules are strictly ordered.
omitStages
+[]Stage +
+ OmitStages is a list of stages for which no events are created. Note that this can also +be specified per rule in which case the union of both are omitted.
+ + + +## `PolicyList` {#audit-k8s-io-v1-PolicyList} + + + + + +PolicyList is a list of audit Policies. + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
apiVersion
string
audit.k8s.io/v1
kind
string
PolicyList
metadata
+meta/v1.ListMeta +
+ No description provided. +
items [Required]
+[]Policy +
+ No description provided. +
+ + + +## `GroupResources` {#audit-k8s-io-v1-GroupResources} + + + + +**Appears in:** + +- [PolicyRule](#audit-k8s-io-v1-PolicyRule) + + +GroupResources represents resource kinds in an API group. + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
group
+string +
+ Group is the name of the API group that contains the resources. +The empty string represents the core API group.
resources
+[]string +
+ Resources is a list of resources this rule applies to. + +For example: +'pods' matches pods. +'pods/log' matches the log subresource of pods. +'∗' matches all resources and their subresources. +'pods/∗' matches all subresources of pods. +'∗/scale' matches all scale subresources. + +If wildcard is present, the validation rule will ensure resources do not +overlap with each other. + +An empty list implies all resources and subresources in this API groups apply.
resourceNames
+[]string +
+ ResourceNames is a list of resource instance names that the policy matches. +Using this field requires Resources to be specified. +An empty list implies that every instance of the resource is matched.
+ + + +## `Level` {#audit-k8s-io-v1-Level} + +(Alias of `string`) + + +**Appears in:** + +- [Event](#audit-k8s-io-v1-Event) + +- [PolicyRule](#audit-k8s-io-v1-PolicyRule) + + +Level defines the amount of information logged during auditing + + + + + +## `ObjectReference` {#audit-k8s-io-v1-ObjectReference} + + + + +**Appears in:** + +- [Event](#audit-k8s-io-v1-Event) + + +ObjectReference contains enough information to let you inspect or modify the referred object. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
resource
+string +
+ No description provided. +
namespace
+string +
+ No description provided. +
name
+string +
+ No description provided. +
uid
+k8s.io/apimachinery/pkg/types.UID +
+ No description provided. +
apiGroup
+string +
+ APIGroup is the name of the API group that contains the referred object. +The empty string represents the core API group.
apiVersion
+string +
+ APIVersion is the version of the API group that contains the referred object.
resourceVersion
+string +
+ No description provided. +
subresource
+string +
+ No description provided. +
+ + + +## `PolicyRule` {#audit-k8s-io-v1-PolicyRule} + + + + +**Appears in:** + +- [Policy](#audit-k8s-io-v1-Policy) + + +PolicyRule maps requests based off metadata to an audit Level. +Requests must match the rules of every field (an intersection of rules). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
level [Required]
+Level +
+ The Level that requests matching this rule are recorded at.
users
+[]string +
+ The users (by authenticated user name) this rule applies to. +An empty list implies every user.
userGroups
+[]string +
+ The user groups this rule applies to. A user is considered matching +if it is a member of any of the UserGroups. +An empty list implies every user group.
verbs
+[]string +
+ The verbs that match this rule. +An empty list implies every verb.
resources
+[]GroupResources +
+ Resources that this rule matches. An empty list implies all kinds in all API groups.
namespaces
+[]string +
+ Namespaces that this rule matches. +The empty string "" matches non-namespaced resources. +An empty list implies every namespace.
nonResourceURLs
+[]string +
+ NonResourceURLs is a set of URL paths that should be audited. +∗s are allowed, but only as the full, final step in the path. +Examples: + "/metrics" - Log requests for apiserver metrics + "/healthz∗" - Log all health checks
omitStages
+[]Stage +
+ OmitStages is a list of stages for which no events are created. Note that this can also +be specified policy wide in which case the union of both are omitted. +An empty list means no restrictions will apply.
+ + + +## `Stage` {#audit-k8s-io-v1-Stage} + +(Alias of `string`) + + +**Appears in:** + +- [Event](#audit-k8s-io-v1-Event) + +- [Policy](#audit-k8s-io-v1-Policy) + +- [PolicyRule](#audit-k8s-io-v1-PolicyRule) + + +Stage defines the stages in request handling that audit events may be generated. + + + + diff --git a/content/en/docs/tasks/debug-application-cluster/audit.md b/content/en/docs/tasks/debug-application-cluster/audit.md index ab4c0c75f7..2f8e1c9875 100644 --- a/content/en/docs/tasks/debug-application-cluster/audit.md +++ b/content/en/docs/tasks/debug-application-cluster/audit.md @@ -46,7 +46,9 @@ Each request can be recorded with an associated _stage_. The defined stages are: - `Panic` - Events generated when a panic occurred. {{< note >}} -Audit events are different from the +The configuration of an +[Audit Event configuration](/docs/reference/config-api/apiserver-audit.v1/#audit-k8s-io-v1-Event) +is different from the [Event](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#event-v1-core) API object. {{< /note >}} @@ -59,7 +61,7 @@ Memory consumption depends on the audit logging configuration. Audit policy defines rules about what events should be recorded and what data they should include. The audit policy object structure is defined in the -[`audit.k8s.io` API group](https://github.com/kubernetes/kubernetes/blob/{{< param "githubbranch" >}}/staging/src/k8s.io/apiserver/pkg/apis/audit/v1/types.go). +[`audit.k8s.io` API group](/docs/reference/config-api/apiserver-audit.v1/#audit-k8s-io-v1-Policy). When an event is processed, it's compared against the list of rules in order. The first matching rule sets the _audit level_ of the event. The defined audit levels are: @@ -95,6 +97,9 @@ If you're crafting your own audit profile, you can use the audit profile for Goo [configure-helper.sh](https://github.com/kubernetes/kubernetes/blob/{{< param "githubbranch" >}}/cluster/gce/gci/configure-helper.sh) script, which generates an audit policy file. You can see most of the audit policy file by looking directly at the script. +You can also refer to the [`Policy` configuration reference](/docs/reference/config-api/apiserver-audit.v1/#audit-k8s-io-v1-Policy) +for details about the fields defined. + ## Audit backends Audit backends persist audit events to an external storage. @@ -104,9 +109,7 @@ Out of the box, the kube-apiserver provides two backends: - Webhook backend, which sends events to an external HTTP API In all cases, audit events follow a structure defined by the Kubernetes API in the -`audit.k8s.io` API group. For Kubernetes {{< param "fullversion" >}}, that -API is at version -[`v1`](https://github.com/kubernetes/kubernetes/blob/{{< param "githubbranch" >}}/staging/src/k8s.io/apiserver/pkg/apis/audit/v1/types.go). +[`audit.k8s.io` API group](/docs/reference/config-api/apiserver-audit.v1/#audit-k8s-io-v1-Event). {{< note >}} In case of patches, request body is a JSON array with patch operations, not a JSON object @@ -174,8 +177,6 @@ and finally configure the `hostPath`: ``` - - ### Webhook backend The webhook audit backend sends audit events to a remote web API, which is assumed to @@ -250,3 +251,5 @@ By default truncate is disabled in both `webhook` and `log`, a cluster administr ## {{% heading "whatsnext" %}} * Learn about [Mutating webhook auditing annotations](/docs/reference/access-authn-authz/extensible-admission-controllers/#mutating-webhook-auditing-annotations). +* Read the [reference for `audit.k8s.io` API group](/docs/reference/config-api/apiserver-audit.v1/). +