content large_stringlengths 3 20.5k | url large_stringlengths 54 193 | branch large_stringclasses 4 values | source large_stringclasses 42 values | embeddings listlengths 384 384 | score float64 -0.21 0.65 |
|---|---|---|---|---|---|
## {{% heading "synopsis" %}} Update the taints on one or more nodes. \* A taint consists of a key, value, and effect. As an argument here, it is expressed as key=value:effect. \* The key must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 253 characters. \* Optionally, the key can begin with a DNS subdomain prefix and a single '/', like example.com/my-app. \* The value is optional. If given, it must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 63 characters. \* The effect must be NoSchedule, PreferNoSchedule or NoExecute. \* Currently taint can only apply to node. ``` kubectl taint NODE NAME KEY\_1=VAL\_1:TAINT\_EFFECT\_1 ... KEY\_N=VAL\_N:TAINT\_EFFECT\_N ``` ## {{% heading "examples" %}} ``` # Update node 'foo' with a taint with key 'dedicated' and value 'special-user' and effect 'NoSchedule' # If a taint with that key and effect already exists, its value is replaced as specified kubectl taint nodes foo dedicated=special-user:NoSchedule # Remove from node 'foo' the taint with key 'dedicated' and effect 'NoSchedule' if one exists kubectl taint nodes foo dedicated:NoSchedule- # Remove from node 'foo' all the taints with key 'dedicated' kubectl taint nodes foo dedicated- # Add a taint with key 'dedicated' on nodes having label myLabel=X kubectl taint node -l myLabel=X dedicated=foo:PreferNoSchedule # Add to node 'foo' a taint with key 'bar' and no value kubectl taint nodes foo bar:NoSchedule ``` ## {{% heading "options" %}} | --all | | | --- | --- | | | Select all nodes in the cluster | | --allow-missing-template-keys Default: true | | | | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. | | --dry-run string[="unchanged"] Default: "none" | | | | Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. | | --field-manager string Default: "kubectl-taint" | | | | Name of the manager used to track field ownership. | | -h, --help | | | | help for taint | | -o, --output string | | | | Output format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). | | --overwrite | | | | If true, allow taints to be overwritten, otherwise reject taint updates that overwrite existing taints. | | -l, --selector string | | | | Selector (label query) to filter on, supports '=', '==', '!=', 'in', 'notin'.(e.g. -l key1=value1,key2=value2,key3 in (value3)). Matching objects must satisfy all of the specified label constraints. | | --show-managed-fields | | | | If true, keep the managedFields when printing objects in JSON or YAML format. | | --template string | | | | Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. | | --validate string[="strict"] Default: "strict" | | | | Must be one of: strict (or true), warn, ignore (or false). "true" or "strict" will use a schema to validate the input and fail the request if invalid. It will perform server side validation if ServerSideFieldValidation is enabled on the api-server, but will fall back to less reliable client-side validation if not. "warn" will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as "ignore" otherwise. "false" or "ignore" will not perform any schema validation, silently dropping any | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_taint/_index.md | main | kubernetes | [
0.0003324642893858254,
0.06132996827363968,
0.08327972143888474,
-0.06422633677721024,
-0.011072027496993542,
-0.019787926226854324,
0.049502529203891754,
-0.032451216131448746,
0.07047092914581299,
-0.0010189720196649432,
-0.014243852347135544,
-0.12777350842952728,
0.03960558399558067,
-... | 0.157261 |
but will fall back to less reliable client-side validation if not. "warn" will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as "ignore" otherwise. "false" or "ignore" will not perform any schema validation, silently dropping any unknown or duplicate fields. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_taint/_index.md | main | kubernetes | [
-0.05428070202469826,
0.06635332852602005,
-0.018214641138911247,
0.02461409568786621,
-0.04197890684008598,
-0.06592199951410294,
0.07912660390138626,
-0.039452482014894485,
0.03635967895388603,
-0.031128088012337685,
0.0430346317589283,
-0.06532235443592072,
0.03652924671769142,
-0.00935... | 0.084587 |
string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl](../kubectl/) - kubectl controls the Kubernetes cluster manager | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_taint/_index.md | main | kubernetes | [
0.019985582679510117,
0.04247593879699707,
-0.04030356556177139,
0.0001503542735008523,
-0.07058674842119217,
-0.0037914272397756577,
0.004053888842463493,
0.03287937119603157,
0.04752200469374657,
-0.020615147426724434,
-0.02826469950377941,
-0.13810163736343384,
0.08736259490251541,
-0.0... | 0.098055 |
## {{% heading "synopsis" %}} Output shell completion code for the specified shell (bash, zsh, fish, or powershell). The shell code must be evaluated to provide interactive completion of kubectl commands. This can be done by sourcing it from the .bash\_profile. Detailed instructions on how to do this are available here: for macOS: https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/#enable-shell-autocompletion for linux: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#enable-shell-autocompletion for windows: https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/#enable-shell-autocompletion Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2. ``` kubectl completion SHELL ``` ## {{% heading "examples" %}} ``` # Installing bash completion on macOS using homebrew ## If running Bash 3.2 included with macOS brew install bash-completion ## or, if running Bash 4.1+ brew install bash-completion@2 ## If kubectl is installed via homebrew, this should start working immediately ## If you've installed via other means, you may need add the completion to your completion directory kubectl completion bash > $(brew --prefix)/etc/bash\_completion.d/kubectl # Installing bash completion on Linux ## If bash-completion is not installed on Linux, install the 'bash-completion' package ## via your distribution's package manager. ## Load the kubectl completion code for bash into the current shell source <(kubectl completion bash) ## Write bash completion code to a file and source it from .bash\_profile kubectl completion bash > ~/.kube/completion.bash.inc printf " # kubectl shell completion source '$HOME/.kube/completion.bash.inc' " >> $HOME/.bash\_profile source $HOME/.bash\_profile # Load the kubectl completion code for zsh[1] into the current shell source <(kubectl completion zsh) # Set the kubectl completion code for zsh[1] to autoload on startup kubectl completion zsh > "${fpath[1]}/\_kubectl" # Load the kubectl completion code for fish[2] into the current shell kubectl completion fish | source # To load completions for each session, execute once: kubectl completion fish > ~/.config/fish/completions/kubectl.fish # Load the kubectl completion code for powershell into the current shell kubectl completion powershell | Out-String | Invoke-Expression # Set kubectl completion code for powershell to run on startup ## Save completion code to a script and execute in the profile kubectl completion powershell > "$HOME\.kube\completion.ps1" Add-Content $PROFILE ". '$HOME\.kube\completion.ps1'" ## Execute completion code in the profile Add-Content $PROFILE "if (Get-Command kubectl -ErrorAction SilentlyContinue) { kubectl completion powershell | Out-String | Invoke-Expression }" ## Add completion code directly to the $PROFILE script kubectl completion powershell >> $PROFILE ``` ## {{% heading "options" %}} | -h, --help | | | --- | --- | | | help for completion | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_completion/_index.md | main | kubernetes | [
0.04816056415438652,
0.030245916917920113,
0.0436655655503273,
-0.026067955419421196,
-0.0012747274013236165,
0.04310167580842972,
0.01878371462225914,
-0.012786821462213993,
0.04299763962626457,
0.029274240136146545,
-0.06793894618749619,
-0.11359477788209915,
-0.03159566596150398,
0.0400... | 0.090121 |
Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl](../kubectl/) - kubectl controls the Kubernetes cluster manager | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_completion/_index.md | main | kubernetes | [
-0.002354454016312957,
0.049045760184526443,
-0.004259556531906128,
-0.007756264880299568,
-0.0798875093460083,
-0.014797578565776348,
-0.0314364917576313,
-0.05879361182451248,
0.0796121135354042,
-0.02352781966328621,
-0.035953089594841,
-0.09606993198394775,
0.044057320803403854,
0.0083... | 0.046781 |
## {{% heading "synopsis" %}} Roll back to a previous rollout. ``` kubectl rollout undo (TYPE NAME | TYPE/NAME) [flags] ``` ## {{% heading "examples" %}} ``` # Roll back to the previous deployment kubectl rollout undo deployment/abc # Roll back to daemonset revision 3 kubectl rollout undo daemonset/abc --to-revision=3 # Roll back to the previous deployment with dry-run kubectl rollout undo --dry-run=server deployment/abc ``` ## {{% heading "options" %}} | --allow-missing-template-keys Default: true | | | --- | --- | | | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. | | --dry-run string[="unchanged"] Default: "none" | | | | Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. | | -f, --filename strings | | | | Filename, directory, or URL to files identifying the resource to get from a server. | | -h, --help | | | | help for undo | | -k, --kustomize string | | | | Process the kustomization directory. This flag can't be used together with -f or -R. | | -o, --output string | | | | Output format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). | | -R, --recursive | | | | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. | | -l, --selector string | | | | Selector (label query) to filter on, supports '=', '==', '!=', 'in', 'notin'.(e.g. -l key1=value1,key2=value2,key3 in (value3)). Matching objects must satisfy all of the specified label constraints. | | --show-managed-fields | | | | If true, keep the managedFields when printing objects in JSON or YAML format. | | --template string | | | | Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. | | --to-revision int | | | | The revision to rollback to. Default to 0 (last revision). | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_undo.md | main | kubernetes | [
0.013650850392878056,
0.11761142313480377,
0.0651717409491539,
0.019544171169400215,
-0.01735043153166771,
0.02408193238079548,
-0.04603520408272743,
-0.029850829392671585,
0.03404790163040161,
-0.0073732356540858746,
0.029289204627275467,
-0.03602631390094757,
-0.025680480524897575,
-0.07... | 0.03364 |
the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl rollout](../) - Manage the rollout of a resource | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_undo.md | main | kubernetes | [
-0.02205285057425499,
0.0798000618815422,
0.01409888919442892,
-0.00775154959410429,
-0.045358844101428986,
-0.038300272077322006,
-0.05524992197751999,
-0.07173563539981842,
0.09072504192590714,
-0.0021939389407634735,
-0.05152592062950134,
-0.10923667252063751,
0.04424388334155083,
0.013... | 0.019955 |
## {{% heading "synopsis" %}} Resume a paused resource. Paused resources will not be reconciled by a controller. By resuming a resource, we allow it to be reconciled again. Currently only deployments support being resumed. ``` kubectl rollout resume RESOURCE ``` ## {{% heading "examples" %}} ``` # Resume an already paused deployment kubectl rollout resume deployment/nginx ``` ## {{% heading "options" %}} | --allow-missing-template-keys Default: true | | | --- | --- | | | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. | | --field-manager string Default: "kubectl-rollout" | | | | Name of the manager used to track field ownership. | | -f, --filename strings | | | | Filename, directory, or URL to files identifying the resource to get from a server. | | -h, --help | | | | help for resume | | -k, --kustomize string | | | | Process the kustomization directory. This flag can't be used together with -f or -R. | | -o, --output string | | | | Output format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). | | -R, --recursive | | | | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. | | -l, --selector string | | | | Selector (label query) to filter on, supports '=', '==', '!=', 'in', 'notin'.(e.g. -l key1=value1,key2=value2,key3 in (value3)). Matching objects must satisfy all of the specified label constraints. | | --show-managed-fields | | | | If true, keep the managedFields when printing objects in JSON or YAML format. | | --template string | | | | Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_resume.md | main | kubernetes | [
-0.033707089722156525,
0.07201820611953735,
0.019684823229908943,
0.02274732105433941,
0.003666939213871956,
0.05729321017861366,
-0.02914297766983509,
-0.04224985092878342,
0.01959494687616825,
-0.011424889788031578,
0.0494702085852623,
-0.01148422434926033,
-0.02867237478494644,
-0.01078... | 0.063899 |
HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl rollout](../) - Manage the rollout of a resource | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_resume.md | main | kubernetes | [
-0.029822679236531258,
0.03361715003848076,
-0.05471969023346901,
-0.03289901465177536,
-0.04547976702451706,
-0.006984403822571039,
-0.009832587093114853,
-0.001616599503904581,
0.04669959098100662,
-0.008762621320784092,
-0.0034223340917378664,
-0.10577799379825592,
0.021854575723409653,
... | 0.046897 |
## {{% heading "synopsis" %}} Restart a resource. Resource rollout will be restarted. ``` kubectl rollout restart RESOURCE ``` ## {{% heading "examples" %}} ``` # Restart all deployments in the test-namespace namespace kubectl rollout restart deployment -n test-namespace # Restart a deployment kubectl rollout restart deployment/nginx # Restart a daemon set kubectl rollout restart daemonset/abc # Restart deployments with the app=nginx label kubectl rollout restart deployment --selector=app=nginx ``` ## {{% heading "options" %}} | --allow-missing-template-keys Default: true | | | --- | --- | | | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. | | --field-manager string Default: "kubectl-rollout" | | | | Name of the manager used to track field ownership. | | -f, --filename strings | | | | Filename, directory, or URL to files identifying the resource to get from a server. | | -h, --help | | | | help for restart | | -k, --kustomize string | | | | Process the kustomization directory. This flag can't be used together with -f or -R. | | -o, --output string | | | | Output format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). | | -R, --recursive | | | | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. | | -l, --selector string | | | | Selector (label query) to filter on, supports '=', '==', '!=', 'in', 'notin'.(e.g. -l key1=value1,key2=value2,key3 in (value3)). Matching objects must satisfy all of the specified label constraints. | | --show-managed-fields | | | | If true, keep the managedFields when printing objects in JSON or YAML format. | | --template string | | | | Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_restart.md | main | kubernetes | [
-0.017418239265680313,
0.09632805734872818,
0.04387279972434044,
-0.005247623194009066,
-0.05030910670757294,
0.02271748147904873,
-0.0201247651129961,
-0.047508180141448975,
0.04633725807070732,
0.010027644224464893,
0.008246120996773243,
-0.06174306571483612,
-0.01771216094493866,
-0.018... | 0.062383 |
certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl rollout](../) - Manage the rollout of a resource | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_restart.md | main | kubernetes | [
-0.014254527166485786,
0.020722893998026848,
-0.014083008281886578,
-0.036260854452848434,
-0.0423867329955101,
-0.018414633348584175,
-0.013207711279392242,
-0.019770583137869835,
0.059410709887742996,
-0.027809256687760353,
-0.0228425320237875,
-0.12018215656280518,
0.05845820903778076,
... | -0.002959 |
## {{% heading "synopsis" %}} Show the status of the rollout. By default 'rollout status' will watch the status of the latest rollout until it's done. If you don't want to wait for the rollout to finish then you can use --watch=false. Note that if a new rollout starts in-between, then 'rollout status' will continue watching the latest revision. If you want to pin to a specific revision and abort if it is rolled over by another revision, use --revision=N where N is the revision you need to watch for. ``` kubectl rollout status (TYPE NAME | TYPE/NAME) [flags] ``` ## {{% heading "examples" %}} ``` # Watch the rollout status of a deployment kubectl rollout status deployment/nginx ``` ## {{% heading "options" %}} | -f, --filename strings | | | --- | --- | | | Filename, directory, or URL to files identifying the resource to get from a server. | | -h, --help | | | | help for status | | -k, --kustomize string | | | | Process the kustomization directory. This flag can't be used together with -f or -R. | | -R, --recursive | | | | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. | | --revision int | | | | Pin to a specific revision for showing its status. Defaults to 0 (last revision). | | -l, --selector string | | | | Selector (label query) to filter on, supports '=', '==', '!=', 'in', 'notin'.(e.g. -l key1=value1,key2=value2,key3 in (value3)). Matching objects must satisfy all of the specified label constraints. | | --timeout duration | | | | The length of time to wait before ending watch, zero means never. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h). | | -w, --watch Default: true | | | | Watch the status of the rollout until it's done. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_status.md | main | kubernetes | [
-0.008762475103139877,
0.06461987644433975,
0.012767455540597439,
-0.000457930495031178,
0.03172856196761131,
-0.002635166747495532,
-0.03433072194457054,
-0.06672001630067825,
0.09618686139583588,
0.04181063920259476,
-0.032491300255060196,
0.00036733943852595985,
-0.07468028366565704,
-0... | 0.026839 |
will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl rollout](../) - Manage the rollout of a resource | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_status.md | main | kubernetes | [
-0.007761749438941479,
0.02144199050962925,
-0.022761764004826546,
-0.039177924394607544,
-0.038514457643032074,
-0.02808194048702717,
-0.005484211724251509,
-0.03603459522128105,
0.06221320480108261,
-0.014222437515854836,
-0.014614339917898178,
-0.10569233447313309,
0.03289729729294777,
... | 0.020769 |
## {{% heading "synopsis" %}} Mark the provided resource as paused. Paused resources will not be reconciled by a controller. Use "kubectl rollout resume" to resume a paused resource. Currently only deployments support being paused. ``` kubectl rollout pause RESOURCE ``` ## {{% heading "examples" %}} ``` # Mark the nginx deployment as paused # Any current state of the deployment will continue its function; new updates # to the deployment will not have an effect as long as the deployment is paused kubectl rollout pause deployment/nginx ``` ## {{% heading "options" %}} | --allow-missing-template-keys Default: true | | | --- | --- | | | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. | | --field-manager string Default: "kubectl-rollout" | | | | Name of the manager used to track field ownership. | | -f, --filename strings | | | | Filename, directory, or URL to files identifying the resource to get from a server. | | -h, --help | | | | help for pause | | -k, --kustomize string | | | | Process the kustomization directory. This flag can't be used together with -f or -R. | | -o, --output string | | | | Output format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). | | -R, --recursive | | | | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. | | -l, --selector string | | | | Selector (label query) to filter on, supports '=', '==', '!=', 'in', 'notin'.(e.g. -l key1=value1,key2=value2,key3 in (value3)). Matching objects must satisfy all of the specified label constraints. | | --show-managed-fields | | | | If true, keep the managedFields when printing objects in JSON or YAML format. | | --template string | | | | Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_pause.md | main | kubernetes | [
-0.014211773872375488,
0.07913509756326675,
0.028282100334763527,
-0.008826125413179398,
0.003395358333364129,
0.04439906030893326,
-0.025837155058979988,
-0.06763598322868347,
0.014037230983376503,
0.03425617516040802,
0.044017940759658813,
-0.011162687093019485,
-0.043912921100854874,
-0... | 0.031048 |
response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl rollout](../) - Manage the rollout of a resource | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_pause.md | main | kubernetes | [
-0.02885688841342926,
0.0693630576133728,
0.012722667306661606,
-0.027462273836135864,
-0.057077180594205856,
-0.0313003771007061,
-0.031392283737659454,
-0.05878755450248718,
0.07281477749347687,
-0.010444988496601582,
-0.043908119201660156,
-0.12063832581043243,
0.03173530101776123,
-0.0... | 0.069259 |
## {{% heading "synopsis" %}} Manage the rollout of one or many resources. Valid resource types include: \* deployments \* daemonsets \* statefulsets ``` kubectl rollout SUBCOMMAND ``` ## {{% heading "examples" %}} ``` # Rollback to the previous deployment kubectl rollout undo deployment/abc # Check the rollout status of a daemonset kubectl rollout status daemonset/foo # Restart a deployment kubectl rollout restart deployment/abc # Restart deployments with the 'app=nginx' label kubectl rollout restart deployment --selector=app=nginx ``` ## {{% heading "options" %}} | -h, --help | | | --- | --- | | | help for rollout | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/_index.md | main | kubernetes | [
-0.08179643005132675,
0.06518830358982086,
0.013235127553343773,
0.013660728931427002,
-0.06190546602010727,
0.0009877310367301106,
0.03083869069814682,
-0.025450358167290688,
0.026285290718078613,
0.028473103418946266,
-0.014139734208583832,
-0.05198013037443161,
-0.013651827350258827,
0.... | 0.103034 |
be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl](../kubectl/) - kubectl controls the Kubernetes cluster manager \* [kubectl rollout history](kubectl\_rollout\_history/) - View rollout history \* [kubectl rollout pause](kubectl\_rollout\_pause/) - Mark the provided resource as paused \* [kubectl rollout restart](kubectl\_rollout\_restart/) - Restart a resource \* [kubectl rollout resume](kubectl\_rollout\_resume/) - Resume a paused resource \* [kubectl rollout status](kubectl\_rollout\_status/) - Show the status of the rollout \* [kubectl rollout undo](kubectl\_rollout\_undo/) - Undo a previous rollout | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/_index.md | main | kubernetes | [
0.036498408764600754,
0.03340483456850052,
-0.09901131689548492,
0.011982045136392117,
-0.11643248796463013,
-0.030110087245702744,
0.0009477111743763089,
0.026883674785494804,
0.05155862867832184,
0.021257147192955017,
0.00963718444108963,
-0.11099988222122192,
0.09732532501220703,
-0.028... | 0.097015 |
## {{% heading "synopsis" %}} View previous rollout revisions and configurations. ``` kubectl rollout history (TYPE NAME | TYPE/NAME) [flags] ``` ## {{% heading "examples" %}} ``` # View the rollout history of a deployment kubectl rollout history deployment/abc # View the details of daemonset revision 3 kubectl rollout history daemonset/abc --revision=3 ``` ## {{% heading "options" %}} | --allow-missing-template-keys Default: true | | | --- | --- | | | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. | | -f, --filename strings | | | | Filename, directory, or URL to files identifying the resource to get from a server. | | -h, --help | | | | help for history | | -k, --kustomize string | | | | Process the kustomization directory. This flag can't be used together with -f or -R. | | -o, --output string | | | | Output format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). | | -R, --recursive | | | | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. | | --revision int | | | | See the details, including podTemplate of the revision specified | | -l, --selector string | | | | Selector (label query) to filter on, supports '=', '==', '!=', 'in', 'notin'.(e.g. -l key1=value1,key2=value2,key3 in (value3)). Matching objects must satisfy all of the specified label constraints. | | --show-managed-fields | | | | If true, keep the managedFields when printing objects in JSON or YAML format. | | --template string | | | | Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_history.md | main | kubernetes | [
0.014798336662352085,
0.11109839379787445,
0.0002808508579619229,
-0.019111262634396553,
-0.03741271048784256,
0.05007193610072136,
-0.05952933803200722,
0.013382099568843842,
0.03034735471010208,
-0.02393535152077675,
0.04935603588819504,
-0.05029600113630295,
-0.030432453379034996,
-0.03... | 0.082096 |
| | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl rollout](../) - Manage the rollout of a resource | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_history.md | main | kubernetes | [
-0.02121763862669468,
0.0024951465893536806,
-0.01771743968129158,
-0.024499420076608658,
-0.045569151639938354,
0.014506988227367401,
-0.011392787098884583,
0.015095129609107971,
0.043119896203279495,
0.0004951826995238662,
-0.009961439296603203,
-0.10884206742048264,
-0.0019891962874680758... | 0.071666 |
## {{% heading "synopsis" %}} Set the latest last-applied-configuration annotations by setting it to match the contents of a file. This results in the last-applied-configuration being updated as though 'kubectl apply -f<file> ' was run, without updating any other parts of the object. ``` kubectl apply set-last-applied -f FILENAME ``` ## {{% heading "examples" %}} ``` # Set the last-applied-configuration of a resource to match the contents of a file kubectl apply set-last-applied -f deploy.yaml # Execute set-last-applied against each configuration file in a directory kubectl apply set-last-applied -f path/ # Set the last-applied-configuration of a resource to match the contents of a file; will create the annotation if it does not already exist kubectl apply set-last-applied -f deploy.yaml --create-annotation=true ``` ## {{% heading "options" %}} | --allow-missing-template-keys Default: true | | | --- | --- | | | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. | | --create-annotation | | | | Will create 'last-applied-configuration' annotations if current objects doesn't have one | | --dry-run string[="unchanged"] Default: "none" | | | | Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. | | -f, --filename strings | | | | Filename, directory, or URL to files that contains the last-applied-configuration annotations | | -h, --help | | | | help for set-last-applied | | -o, --output string | | | | Output format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). | | --show-managed-fields | | | | If true, keep the managedFields when printing objects in JSON or YAML format. | | --template string | | | | Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_apply/kubectl_apply_set-last-applied.md | main | kubernetes | [
0.005211960058659315,
0.0423109196126461,
0.06558062136173248,
0.000056779797887429595,
0.04139374569058418,
-0.0016021899646148086,
-0.0051275696605443954,
-0.017116669565439224,
0.07414976507425308,
0.03035818040370941,
-0.00839773565530777,
-0.03668544441461563,
-0.021268561482429504,
-... | 0.09686 |
certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl apply](../) - Apply a configuration to a resource by file name or stdin | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_apply/kubectl_apply_set-last-applied.md | main | kubernetes | [
-0.014254527166485786,
0.020722893998026848,
-0.014083008281886578,
-0.036260854452848434,
-0.0423867329955101,
-0.018414633348584175,
-0.013207711279392242,
-0.019770583137869835,
0.059410709887742996,
-0.027809256687760353,
-0.0228425320237875,
-0.12018215656280518,
0.05845820903778076,
... | -0.002959 |
## {{% heading "synopsis" %}} Edit the latest last-applied-configuration annotations of resources from the default editor. The edit-last-applied command allows you to directly edit any API resource you can retrieve via the command-line tools. It will open the editor defined by your KUBE\_EDITOR, or EDITOR environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows. You can edit multiple objects, although changes are applied one at a time. The command accepts file names as well as command-line arguments, although the files you point to must be previously saved versions of resources. The default format is YAML. To edit in JSON, specify "-o json". The flag --windows-line-endings can be used to force Windows line endings, otherwise the default for your operating system will be used. In the event an error occurs while updating, a temporary file will be created on disk that contains your unapplied changes. The most common error when updating a resource is another editor changing the resource on the server. When this occurs, you will have to apply your changes to the newer version of the resource, or update your temporary saved copy to include the latest resource version. ``` kubectl apply edit-last-applied (RESOURCE/NAME | -f FILENAME) ``` ## {{% heading "examples" %}} ``` # Edit the last-applied-configuration annotations by type/name in YAML kubectl apply edit-last-applied deployment/nginx # Edit the last-applied-configuration annotations by file in JSON kubectl apply edit-last-applied -f deploy.yaml -o json ``` ## {{% heading "options" %}} | --allow-missing-template-keys Default: true | | | --- | --- | | | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. | | --field-manager string Default: "kubectl-client-side-apply" | | | | Name of the manager used to track field ownership. | | -f, --filename strings | | | | Filename, directory, or URL to files to use to edit the resource | | -h, --help | | | | help for edit-last-applied | | -k, --kustomize string | | | | Process the kustomization directory. This flag can't be used together with -f or -R. | | -o, --output string | | | | Output format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). | | -R, --recursive | | | | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. | | --show-managed-fields | | | | If true, keep the managedFields when printing objects in JSON or YAML format. | | --template string | | | | Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. | | --validate string[="strict"] Default: "strict" | | | | Must be one of: strict (or true), warn, ignore (or false). "true" or "strict" will use a schema to validate the input and fail the request if invalid. It will perform server side validation if ServerSideFieldValidation is enabled on the api-server, but will fall back to less reliable client-side validation if not. "warn" will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as "ignore" otherwise. "false" or "ignore" will not perform any schema validation, silently dropping any unknown or duplicate fields. | | --windows-line-endings | | | | Defaults to the line ending native to your platform. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_apply/kubectl_apply_edit-last-applied.md | main | kubernetes | [
-0.042763978242874146,
0.044584374874830246,
0.026839125901460648,
0.04035525396466255,
-0.010041875764727592,
0.020694421604275703,
-0.058872971683740616,
0.036559153348207474,
0.08268921077251434,
0.04578036069869995,
-0.014018264599144459,
-0.03410462662577629,
-0.017989983782172203,
-0... | 0.172132 |
not perform any schema validation, silently dropping any unknown or duplicate fields. | | --windows-line-endings | | | | Defaults to the line ending native to your platform. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_apply/kubectl_apply_edit-last-applied.md | main | kubernetes | [
-0.0100039541721344,
0.05897991359233856,
-0.025851430371403694,
0.015177639201283455,
-0.06452580541372299,
-0.05312567204236984,
0.07966816425323486,
-0.02001107670366764,
-0.017370738089084625,
0.020825812593102455,
0.01826445199549198,
-0.10330351442098618,
0.02975590154528618,
0.01070... | 0.006272 |
"stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl apply](../) - Apply a configuration to a resource by file name or stdin | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_apply/kubectl_apply_edit-last-applied.md | main | kubernetes | [
0.00948330108076334,
0.07203850150108337,
-0.028307858854532242,
-0.002353188581764698,
-0.057900313287973404,
-0.011616808362305164,
0.006522958632558584,
0.01883603073656559,
0.03901704400777817,
0.0007036521565169096,
-0.04051331430673599,
-0.149424210190773,
0.09551210701465607,
-0.021... | 0.089023 |
## {{% heading "synopsis" %}} View the latest last-applied-configuration annotations by type/name or file. The default output will be printed to stdout in YAML format. You can use the -o option to change the output format. ``` kubectl apply view-last-applied (TYPE [NAME | -l label] | TYPE/NAME | -f FILENAME) ``` ## {{% heading "examples" %}} ``` # View the last-applied-configuration annotations by type/name in YAML kubectl apply view-last-applied deployment/nginx # View the last-applied-configuration annotations by file in JSON kubectl apply view-last-applied -f deploy.yaml -o json ``` ## {{% heading "options" %}} | --all | | | --- | --- | | | Select all resources in the namespace of the specified resource types | | -f, --filename strings | | | | Filename, directory, or URL to files that contains the last-applied-configuration annotations | | -h, --help | | | | help for view-last-applied | | -k, --kustomize string | | | | Process the kustomization directory. This flag can't be used together with -f or -R. | | -o, --output string Default: "yaml" | | | | Output format. Must be one of (yaml, json) | | -R, --recursive | | | | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. | | -l, --selector string | | | | Selector (label query) to filter on, supports '=', '==', '!=', 'in', 'notin'.(e.g. -l key1=value1,key2=value2,key3 in (value3)). Matching objects must satisfy all of the specified label constraints. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_apply/kubectl_apply_view-last-applied.md | main | kubernetes | [
0.02410944551229477,
0.0686742514371872,
0.04443711042404175,
0.0026836961042135954,
0.053221575915813446,
0.0202054213732481,
-0.015530801378190517,
-0.014177304692566395,
0.04276077449321747,
0.005746334791183472,
-0.04706861451268196,
-0.0530116967856884,
-0.02510436624288559,
-0.010265... | 0.039246 |
version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl apply](../) - Apply a configuration to a resource by file name or stdin | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_apply/kubectl_apply_view-last-applied.md | main | kubernetes | [
-0.005788404028862715,
0.050656240433454514,
-0.0457872599363327,
-0.035500239580869675,
-0.03771479055285454,
-0.0038752099499106407,
-0.010343235917389393,
0.05306752026081085,
0.047009874135255814,
0.006549444515258074,
-0.0035247483756393194,
-0.08366888016462326,
0.021895546466112137,
... | 0.034284 |
## {{% heading "synopsis" %}} Apply a configuration to a resource by file name or stdin. The resource name must be specified. This resource will be created if it doesn't exist yet. To use 'apply', always create the resource initially with either 'apply' or 'create --save-config'. JSON and YAML formats are accepted. Alpha Disclaimer: the --prune functionality is not yet complete. Do not use unless you are aware of what the current state is. See https://issues.k8s.io/34274. ``` kubectl apply (-f FILENAME | -k DIRECTORY) ``` ## {{% heading "examples" %}} ``` # Apply the configuration in pod.json to a pod kubectl apply -f ./pod.json # Apply resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml kubectl apply -k dir/ # Apply the JSON passed into stdin to a pod cat pod.json | kubectl apply -f - # Apply the configuration from all files that end with '.json' kubectl apply -f '\*.json' # Note: --prune is still in Alpha # Apply the configuration in manifest.yaml that matches label app=nginx and delete all other resources that are not in the file and match label app=nginx kubectl apply --prune -f manifest.yaml -l app=nginx # Apply the configuration in manifest.yaml and delete all the other config maps that are not in the file kubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/v1/ConfigMap ``` ## {{% heading "options" %}} | --all | | | --- | --- | | | Select all resources in the namespace of the specified resource types. | | --allow-missing-template-keys Default: true | | | | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. | | --cascade string[="background"] Default: "background" | | | | Must be "background", "orphan", or "foreground". Selects the deletion cascading strategy for the dependents (e.g. Pods created by a ReplicationController). Defaults to background. | | --dry-run string[="unchanged"] Default: "none" | | | | Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. | | --field-manager string Default: "kubectl-client-side-apply" | | | | Name of the manager used to track field ownership. | | -f, --filename strings | | | | The files that contain the configurations to apply. | | --force | | | | If true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation. | | --force-conflicts | | | | If true, server-side apply will force the changes against conflicts. | | --grace-period int Default: -1 | | | | Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion). | | -h, --help | | | | help for apply | | -k, --kustomize string | | | | Process a kustomization directory. This flag can't be used together with -f or -R. | | --openapi-patch Default: true | | | | If true, use openapi to calculate diff when the openapi presents and the resource can be found in the openapi spec. Otherwise, fall back to use baked-in types. | | -o, --output string | | | | Output format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). | | --overwrite Default: true | | | | Automatically resolve conflicts between the modified and live configuration by using values from | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_apply/_index.md | main | kubernetes | [
0.01878349483013153,
0.0850096195936203,
0.043191973119974136,
0.009701735340058804,
0.0031583590898662806,
0.01723296195268631,
-0.014632473699748516,
0.04512353613972664,
0.01616634614765644,
0.030292904004454613,
0.028210632503032684,
-0.006477627903223038,
0.0017008695285767317,
-0.002... | 0.087932 |
to use baked-in types. | | -o, --output string | | | | Output format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). | | --overwrite Default: true | | | | Automatically resolve conflicts between the modified and live configuration by using values from the modified configuration | | --prune | | | | Automatically delete resource objects, that do not appear in the configs and are created by either apply or create --save-config. Should be used with either -l or --all. | | --prune-allowlist strings | | | | Overwrite the default allowlist with <group/version/kind> for --prune | | -R, --recursive | | | | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. | | -l, --selector string | | | | Selector (label query) to filter on, supports '=', '==', '!=', 'in', 'notin'.(e.g. -l key1=value1,key2=value2,key3 in (value3)). Matching objects must satisfy all of the specified label constraints. | | --server-side | | | | If true, apply runs in the server instead of the client. | | --show-managed-fields | | | | If true, keep the managedFields when printing objects in JSON or YAML format. | | --subresource string | | | | If specified, apply will operate on the subresource of the requested object. Only allowed when using --server-side. | | --template string | | | | Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. | | --timeout duration | | | | The length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object | | --validate string[="strict"] Default: "strict" | | | | Must be one of: strict (or true), warn, ignore (or false). "true" or "strict" will use a schema to validate the input and fail the request if invalid. It will perform server side validation if ServerSideFieldValidation is enabled on the api-server, but will fall back to less reliable client-side validation if not. "warn" will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as "ignore" otherwise. "false" or "ignore" will not perform any schema validation, silently dropping any unknown or duplicate fields. | | --wait | | | | If true, wait for resources to be gone before returning. This waits for finalizers. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_apply/_index.md | main | kubernetes | [
0.025687331333756447,
0.08111558109521866,
-0.05634469538927078,
0.00008324726513819769,
0.04001457989215851,
0.045573145151138306,
-0.007739237044006586,
0.003338567214086652,
-0.09104439616203308,
-0.029957272112369537,
0.0811261385679245,
0.03804395720362663,
-0.048934511840343475,
0.03... | -0.00868 |
string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl](../kubectl/) - kubectl controls the Kubernetes cluster manager \* [kubectl apply edit-last-applied](kubectl\_apply\_edit-last-applied/) - Edit latest last-applied-configuration annotations of a resource/object \* [kubectl apply set-last-applied](kubectl\_apply\_set-last-applied/) - Set the last-applied-configuration annotation on a live object to match the contents of a file \* [kubectl apply view-last-applied](kubectl\_apply\_view-last-applied/) - View the latest last-applied-configuration annotations of a resource/object | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_apply/_index.md | main | kubernetes | [
-0.006641767453402281,
0.06654543429613113,
-0.003195993835106492,
0.0020408809650689363,
-0.07809747755527496,
-0.01573213003575802,
-0.03141161426901817,
-0.05598750337958336,
0.08693614602088928,
-0.03453105688095093,
-0.02762475050985813,
-0.08888661861419678,
0.06567081063985825,
0.00... | 0.038635 |
of a resource/object \* [kubectl apply set-last-applied](kubectl\_apply\_set-last-applied/) - Set the last-applied-configuration annotation on a live object to match the contents of a file \* [kubectl apply view-last-applied](kubectl\_apply\_view-last-applied/) - View the latest last-applied-configuration annotations of a resource/object | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_apply/_index.md | main | kubernetes | [
-0.012025319039821625,
0.0544019378721714,
0.011879165656864643,
-0.034640684723854065,
0.06376652419567108,
0.01997499354183674,
0.053315404802560806,
-0.04509764164686203,
0.03847465664148331,
0.029840193688869476,
-0.02964708022773266,
-0.05288633331656456,
-0.03528083115816116,
-0.0325... | 0.131285 |
## {{% heading "synopsis" %}} Print the client and server version information for the current context. ``` kubectl version [flags] ``` ## {{% heading "examples" %}} ``` # Print the client and server versions for the current context kubectl version ``` ## {{% heading "options" %}} | --client | | | --- | --- | | | If true, shows client version only (no server required). | | -h, --help | | | | help for version | | -o, --output string | | | | One of 'yaml' or 'json'. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_version/_index.md | main | kubernetes | [
-0.0020791995339095592,
0.06300295889377594,
0.040694598108530045,
-0.00031304667936638,
-0.012610790319740772,
-0.03818324953317642,
0.022537441924214363,
0.002764681354165077,
0.028179587796330452,
-0.009266490116715431,
0.02522979862987995,
-0.10634840279817581,
0.005945031531155109,
-0... | 0.058494 |
committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl](../kubectl/) - kubectl controls the Kubernetes cluster manager | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_version/_index.md | main | kubernetes | [
0.02065977454185486,
0.017925752326846123,
-0.08806876838207245,
0.010327421128749847,
-0.09272976964712143,
-0.025673000141978264,
-0.001775683369487524,
0.008105049841105938,
0.0691470131278038,
0.016305312514305115,
0.014517203904688358,
-0.11707139760255814,
0.11167927831411362,
-0.020... | 0.084095 |
## {{% heading "synopsis" %}} Build a set of KRM resources using a 'kustomization.yaml' file. The DIR argument must be a path to a directory containing 'kustomization.yaml', or a git repository URL with a path suffix specifying same with respect to the repository root. If DIR is omitted, '.' is assumed. ``` kubectl kustomize DIR [flags] ``` ## {{% heading "examples" %}} ``` # Build the current working directory kubectl kustomize # Build some shared configuration directory kubectl kustomize /home/config/production # Build from github kubectl kustomize https://github.com/kubernetes-sigs/kustomize.git/examples/helloWorld?ref=v1.0.6 ``` ## {{% heading "options" %}} | --as-current-user | | | --- | --- | | | use the uid and gid of the command executor to run the function in the container | | --enable-alpha-plugins | | | | enable kustomize plugins | | --enable-helm | | | | Enable use of the Helm chart inflator generator. | | -e, --env strings | | | | a list of environment variables to be used by functions | | --helm-api-versions strings | | | | Kubernetes api versions used by Helm for Capabilities.APIVersions | | --helm-command string Default: "helm" | | | | helm command (path to executable) | | --helm-debug | | | | Enable debug output from the Helm chart inflator generator. | | --helm-kube-version string | | | | Kubernetes version used by Helm for Capabilities.KubeVersion | | -h, --help | | | | help for kustomize | | --load-restrictor string Default: "LoadRestrictionsRootOnly" | | | | if set to 'LoadRestrictionsNone', local kustomizations may load files from outside their root. This does, however, break the relocatability of the kustomization. | | --mount strings | | | | a list of storage options read from the filesystem | | --network | | | | enable network access for functions that declare it | | --network-name string Default: "bridge" | | | | the docker network to run the container in | | -o, --output string | | | | If specified, write output to this path. | ## {{% heading "parentoptions" %}} | --as string | | | --- | --- | | | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | | --as-group strings | | | | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | | --as-uid string | | | | UID to impersonate for the operation. | | --as-user-extra strings | | | | User extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. | | --cache-dir string Default: "$HOME/.kube/cache" | | | | Default cache directory | | --certificate-authority string | | | | Path to a cert file for the certificate authority | | --client-certificate string | | | | Path to a client certificate file for TLS | | --client-key string | | | | Path to a client key file for TLS | | --cluster string | | | | The name of the kubeconfig cluster to use | | --context string | | | | The name of the kubeconfig context to use | | --disable-compression | | | | If true, opt-out of response compression for all requests to the server | | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_kustomize/_index.md | main | kubernetes | [
0.0015817444073036313,
0.04870355874300003,
0.01695415750145912,
0.007145451381802559,
-0.03349560499191284,
-0.020864212885499,
0.030372941866517067,
0.030977418646216393,
0.002303100423887372,
0.001682913745753467,
0.017827313393354416,
-0.09580374509096146,
0.011273995973169804,
0.01310... | 0.070451 |
| | --insecure-skip-tls-verify | | | | If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure | | --kubeconfig string | | | | Path to the kubeconfig file to use for CLI requests. | | --kuberc string | | | | Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL\_KUBERC=false feature gate or turning off the feature KUBERC=off. | | --match-server-version | | | | Require server version to match client version | | -n, --namespace string | | | | If present, the namespace scope for this CLI request | | --password string | | | | Password for basic authentication to the API server | | --profile string Default: "none" | | | | Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace) | | --profile-output string Default: "profile.pprof" | | | | Name of the file to write the profile to | | --request-timeout string Default: "0" | | | | The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. | | -s, --server string | | | | The address and port of the Kubernetes API server | | --storage-driver-buffer-duration duration Default: 1m0s | | | | Writes in the storage driver will be buffered for this duration, and committed to the non memory backends as a single transaction | | --storage-driver-db string Default: "cadvisor" | | | | database name | | --storage-driver-host string Default: "localhost:8086" | | | | database host:port | | --storage-driver-password string Default: "root" | | | | database password | | --storage-driver-secure | | | | use secure connection with database | | --storage-driver-table string Default: "stats" | | | | table name | | --storage-driver-user string Default: "root" | | | | database username | | --tls-server-name string | | | | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used | | --token string | | | | Bearer token for authentication to the API server | | --user string | | | | The name of the kubeconfig user to use | | --username string | | | | Username for basic authentication to the API server | | --version version[=true] | | | | --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version | | --warnings-as-errors | | | | Treat warnings received from the server as errors and exit with a non-zero exit code | ## {{% heading "seealso" %}} \* [kubectl](../kubectl/) - kubectl controls the Kubernetes cluster manager | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/kubectl/generated/kubectl_kustomize/_index.md | main | kubernetes | [
-0.014064783230423927,
0.030785085633397102,
0.0018734517507255077,
-0.03915904462337494,
-0.0702904760837555,
-0.00687636062502861,
-0.024071479216217995,
-0.04037684574723244,
0.06272318959236145,
-0.024602651596069336,
-0.025586191564798355,
-0.1347288340330124,
0.038478534668684006,
0.... | 0.027402 |
This page provides an overview of authentication in Kubernetes, with a focus on authentication to the [Kubernetes API](/docs/concepts/overview/kubernetes-api/). ## Users in Kubernetes All Kubernetes clusters have two categories of users: service accounts managed by Kubernetes, and normal users. It is assumed that a cluster-independent service manages normal users in the following ways: - an administrator distributing private keys - a user store like Keystone or Google Accounts - a file with a list of usernames and passwords In this regard, \_Kubernetes does not have objects which represent normal user accounts.\_ Normal users cannot be added to a cluster through an API call. Even though a normal user cannot be added via an API call, any user that presents a valid certificate signed by the cluster's certificate authority (CA) is considered authenticated. In this configuration, Kubernetes determines the username from the common name field in the 'subject' of the cert (e.g., "/CN=bob"). From there, the role based access control (RBAC) sub-system would determine whether the user is authorized to perform a specific operation on a resource. In contrast, service accounts are users managed by the Kubernetes API. They are bound to specific namespaces, and created automatically by the API server or manually through API calls. Service accounts are tied to a set of credentials stored as `Secrets`, which are mounted into pods allowing in-cluster processes to talk to the Kubernetes API. API requests are tied to either a normal user or a service account, or are treated as [anonymous requests](#anonymous-requests). This means every process inside or outside the cluster, from a human user typing `kubectl` on a workstation, to `kubelets` on nodes, to members of the control plane, must authenticate when making requests to the API server, or be treated as an anonymous user. ## Authentication strategies Kubernetes uses client certificates, bearer tokens, or an authenticating proxy to authenticate API requests through authentication plugins. As HTTP requests are made to the API server, plugins attempt to associate the following attributes with the request: \* Username: a string which identifies the end user. Common values might be `kube-admin` or `jane@example.com`. \* UID: a string which identifies the end user and attempts to be more consistent and unique than username. \* Groups: a set of strings, each of which indicates the user's membership in a named logical collection of users. Common values might be `system:masters` or `devops-team`. \* Extra fields: a map of strings to list of strings which holds additional information authorizers may find useful. {{< note >}} All values are opaque to the authentication system and only hold significance when interpreted by an [authorizer](/docs/reference/access-authn-authz/authorization/). {{< /note >}} ## Anonymous requests When enabled, requests that are not rejected by other configured authentication methods are treated as anonymous requests, and given a username of `system:anonymous` and a group of `system:unauthenticated`. For example, on a server with token authentication configured, and anonymous access enabled, a request providing an invalid bearer token would receive a `401 Unauthorized` error. A request providing no bearer token would be treated as an anonymous request. Anonymous access is enabled by default if an [authorization mode](/docs/reference/access-authn-authz/authorization/#authorization-modules) other than `AlwaysAllow` is used; you can disable it by passing the `--anonymous-auth=false` command line option to the API server. The built-in ABAC and RBAC authorizers require explicit authorization of the `system:anonymous` user or the `system:unauthenticated` group; if you have legacy policy rules (from Kubernetes version 1.5 or earlier), those legacy rules that grant access to the `\*` user or `\*` group do not automatically allow access to anonymous users. ### Anonymous authenticator configuration {{< feature-state feature\_gate\_name="AnonymousAuthConfigurableEndpoints" >}} The `AuthenticationConfiguration` can be used to | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.01837853342294693,
-0.029622623696923256,
-0.0046117608435451984,
-0.014617114327847958,
-0.0732005164027214,
-0.0003980595211032778,
0.06332778185606003,
-0.015604491345584393,
0.09729307144880295,
0.013106693513691425,
0.003787160851061344,
-0.07186377793550491,
0.05778591334819794,
-... | 0.150521 |
the `system:unauthenticated` group; if you have legacy policy rules (from Kubernetes version 1.5 or earlier), those legacy rules that grant access to the `\*` user or `\*` group do not automatically allow access to anonymous users. ### Anonymous authenticator configuration {{< feature-state feature\_gate\_name="AnonymousAuthConfigurableEndpoints" >}} The `AuthenticationConfiguration` can be used to configure the anonymous authenticator. If you set the anonymous field in the `AuthenticationConfiguration` file then you cannot set the `--anonymous-auth` command line option. The main advantage of configuring anonymous authenticator using the authentication configuration file is that in addition to enabling and disabling anonymous authentication you can also configure which endpoints support anonymous authentication. A sample authentication configuration file is below: {{< highlight yaml "linenos=false,hl\_lines=2-5" >}} --- # # CAUTION: this is an example configuration. # Do not use this as-is for your own cluster! # apiVersion: apiserver.config.k8s.io/v1 kind: AuthenticationConfiguration anonymous: enabled: true conditions: - path: /livez - path: /readyz - path: /healthz {{< /highlight >}} In the configuration above, only the `/livez`, `/readyz` and `/healthz` endpoints are reachable by anonymous requests. Any other endpoints will not be reachable anonymously, even if your authorization configuration would allow it. ## Authentication methods You can enable multiple authentication methods at once. You should usually use at least two methods: - service account tokens for service accounts - at least one other method for user authentication. When multiple authenticator modules are enabled, the first module to successfully authenticate the request short-circuits evaluation. The API server does not guarantee the order authenticators run in. The `system:authenticated` group is included in the list of groups for all authenticated users. [Integrations](#external-integrations) with other authentication protocols (LDAP, SAML, Kerberos, alternate x509 schemes, etc) are available; for example using an [authenticating proxy](#authenticating-proxy) or the [authentication webhook](#webhook-token-authentication). ### X.509 client certificates {#x509-client-certificates} Any Kubernetes client that presents a valid client certificate signed by the cluster's \_client trust\_ certificate authority (CA) is considered authenticated. In this configuration, Kubernetes determines the username from the `commonName` field in the \_subject\_ of the certificate (for example, `commonName=bob` represents a user with username "bob"). From there, Kubernetes [authorization](/docs/reference/access-authn-authz/authorization) mechanisms determine whether the user is allowed to perform a specific operation on a resource. Client certificate authentication is enabled by passing the `--client-ca-file=` option to the API server. This option configures the cluster's \_client trust\_ certificate authority. The referenced file must contain one or more certificate authorities that the API server can use, when it needs to validate client certificates. If a client certificate is presented and verified, the common name of the subject is used as the user name for the request. Client certificates can also indicate a user's group memberships using the certificate's organization fields. To include multiple group memberships for a user, include multiple organization fields in the certificate. See [Managing Certificates](/docs/tasks/administer-cluster/certificates/) for how to generate a client cert, or read the brief [example](#x509-client-certificates-example) later in this page. #### Kubernetes-compatible client certificates {#x509-client-certificates-k8s} You can present a valid certificate, issued by a CA in a trust chain that the API server accepts for client certificates, and use that to authenticate to Kubernetes. The certificate must be valid; the API server checks that based on the X.509 `notBefore` and `notAfter` attributes, and the certificate must have an \_extended key usage\_ that includes client authentication (`ClientAuth`). {{< note >}} Kubernetes {{< skew currentVersion >}} does not support certificate \_revocation\_. Any certificate that is issued remains valid until it expires. {{< /note >}} ##### Username mapping {#x509-client-certificates-k8s-username} Kubernetes expects a client certificate that contains a `commonName` (OID `2.5.4.3`) attribute, that is used as the username of the subject. ##### User ID mapping {{< feature-state feature\_gate\_name="AllowParsingUserUIDFromCertAuth" | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.03937949985265732,
0.03338439390063286,
-0.002063789637759328,
-0.00017669198859948665,
-0.04386431723833084,
-0.003649424761533737,
0.01842605136334896,
-0.054277051240205765,
0.0691213384270668,
0.024831198155879974,
0.030648913234472275,
-0.07694745808839798,
-0.0008236414287239313,
... | 0.059366 |
does not support certificate \_revocation\_. Any certificate that is issued remains valid until it expires. {{< /note >}} ##### Username mapping {#x509-client-certificates-k8s-username} Kubernetes expects a client certificate that contains a `commonName` (OID `2.5.4.3`) attribute, that is used as the username of the subject. ##### User ID mapping {{< feature-state feature\_gate\_name="AllowParsingUserUIDFromCertAuth" >}} To use this feature, the certificate must have the attribute `1.3.6.1.4.1.57683.2` included, and the `AllowParsingUserUIDFromCertAuth` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) must be enabled (it is on by default). Kubernetes can parse an \*\*optional\*\* user UID from a certificate. UID is different from user name; it is an opaque value with a meaning defined by the person who requested the certificate, or alternatively by whoever has set the certificate approval rules. For example, the UID could be `1042` (a simple integer) in one cluster, but another certificate might use `d3f77937-ec82-4f16-8010-61821abe315a` (a UUID) as the UID. Here is an example to explain what that means. If you have a certificate with the common name set to "Ada Lovelace" and the certificate also had a `uid` attribute, (OID `0.9.2342.19200300.100.1.1`) with uid set to "aaking1815", Kubernetes considers that the client's username is "Ada Lovelace"; Kubernetes ignores the `uid` attribute because it is not the CNCF-specific OID that Kubernetes looks for. If you wanted `aaking1815` to be recognized as UID by Kubernetes, it must be set as a value to the OID `1.3.6.1.4.1.57683.2` attribute in the certificate's subject. ##### Group mapping {#x509-client-certificates-k8s-group} You can map a user into groups by statically including group information into the certificate. For each group that the user is a member of, add the group name as an `organization` (OID `2.5.6.4`) in your certificate's subject. To include multiple group memberships for a user, include multiple organizations in the certificate subject (the order does not matter). For the example user, the distinguished name for a certificate might be CN=Ada Lovelace,O=Users,O=Staff,O=Programmers, which would place her into the groups "Programmers", "Staff", "system:authenticated", and "Users". Putting group information into a certificate is optional; if you don't specify any groups in the certificate, then the user will be a member of "system:authenticated" only. ##### Node client certificates {#x509-client-certificates-nodes} Kubernetes can use the same approach for node identity; nodes are clients of the Kubernetes API server that run a {{}} (also, although less relevant here, the API server is usually also a client of each node). For example: a Node "server-1a-antarctica42", with the domain name "server-1a-antarctica42.cluster.example", could use a certificate issued to "CN=system:node:server-1a-antarctica/42,O=system:nodes". The node's username is then "system:node:server-1a-antarctica/g42", and the node is a member of "system:authenticated" and "system:nodes". The kubelet uses the node's certificate and private key to authenticate to the cluster's API server. {{< note >}} Machine identities for nodes are not the same as {{< glossary\_tooltip text="ServiceAccounts" term\_id="service-account" >}}. {{< /note >}} #### Example {#x509-client-certificates-example} You could use the `openssl` command line tool to generate a certificate signing request: ```bash # This example assumes that you already have a private key alovelace.pem openssl req -new -key alovelace.pem -out alovelace-csr.pem -subj "/CN=alovelace/O=app1/O=app2" ``` This would create a signing request for the username "alovelace", belonging to two groups, "app1" and "app2". You could then have that signing request be signed by your cluster's client trust certificate authority to obtain a certificate you can use for client authentication to your cluster. ### Bootstrap tokens {{< feature-state for\_k8s\_version="v1.18" state="stable" >}} To allow for streamlined bootstrapping for new clusters, Kubernetes includes a dynamically-managed Bearer token type called a \*Bootstrap Token\*. These tokens are stored as Secrets in the `kube-system` namespace, where they can be dynamically managed and created. Controller Manager contains a TokenCleaner controller that deletes bootstrap tokens as they | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.008404789492487907,
0.06568478047847748,
0.09916283190250397,
-0.020853901281952858,
-0.06014024838805199,
-0.013647666200995445,
0.034228917211294174,
-0.009989239275455475,
0.07070378959178925,
0.0015669451095163822,
-0.04515783116221428,
-0.08035775274038315,
0.048981618136167526,
0.... | 0.009097 |
>}} To allow for streamlined bootstrapping for new clusters, Kubernetes includes a dynamically-managed Bearer token type called a \*Bootstrap Token\*. These tokens are stored as Secrets in the `kube-system` namespace, where they can be dynamically managed and created. Controller Manager contains a TokenCleaner controller that deletes bootstrap tokens as they expire. The tokens are of the form `[a-z0-9]{6}.[a-z0-9]{16}`. The first component is a Token ID and the second component is the Token Secret. You specify the token in an HTTP header as follows: ```http Authorization: Bearer 781292.db7bc3a58fc5f07e ``` You must enable the Bootstrap Token Authenticator with the `--enable-bootstrap-token-auth` flag on the API Server. You must enable the TokenCleaner controller via the `--controllers` command line argument for kube-controller-manager. This is done with something like `--controllers=\*,tokencleaner`. The `kubeadm` tool will do this for you if you are using it to bootstrap a cluster. The authenticator authenticates as `system:bootstrap:`. It is included in the `system:bootstrappers` group. The naming and groups are intentionally limited to discourage users from using these tokens past bootstrapping. The user names and group can be used (and are used by `kubeadm`) to craft the appropriate authorization policies to support bootstrapping a cluster. Please see [Bootstrap Tokens](/docs/reference/access-authn-authz/bootstrap-tokens/) for in depth documentation on the Bootstrap Token authenticator and controllers along with how to manage these tokens with `kubeadm`. #### Putting a bearer token in a request When using bearer token authentication from an HTTP client, the API server expects an `Authorization` header with a value of `Bearer `. The bearer token must be a character sequence that can be put in an HTTP header value using no more than the encoding and quoting facilities of HTTP. For example: if the bearer token is `31ada4fd-adec-460c-809a-9e56ceb75269` then it would appear in an HTTP header as shown below. ```http Authorization: Bearer 31ada4fd-adec-460c-809a-9e56ceb75269 ``` ### Service account tokens A service account is an automatically enabled authenticator that uses signed bearer tokens to verify requests. The plugin takes two optional flags: \* `--service-account-key-file` File containing PEM-encoded x509 RSA or ECDSA private or public keys, used to verify ServiceAccount tokens. The specified file can contain multiple keys, and the flag can be specified multiple times with different files. If unspecified, --tls-private-key-file is used. \* `--service-account-lookup` If enabled, tokens which are deleted from the API will be revoked. Service accounts are usually created automatically by the API server and associated with pods running in the cluster through the `ServiceAccount` [Admission Controller](/docs/reference/access-authn-authz/admission-controllers/). Bearer tokens are mounted into pods at well-known locations, and allow in-cluster processes to talk to the API server. Accounts may be explicitly associated with pods using the `serviceAccountName` field of a `PodSpec`. {{< note >}} `serviceAccountName` is usually omitted because this is done automatically. {{< /note >}} ```yaml apiVersion: apps/v1 # this apiVersion is relevant as of Kubernetes 1.9 kind: Deployment metadata: name: nginx-deployment namespace: default spec: replicas: 3 template: metadata: # ... spec: serviceAccountName: bob-the-bot containers: - name: nginx image: nginx:1.14.2 ``` Service account bearer tokens are perfectly valid to use outside the cluster and can be used to create identities for long standing jobs that wish to talk to the Kubernetes API. To manually create a service account, use the `kubectl create serviceaccount (NAME)` command. This creates a service account in the current namespace. ```bash kubectl create serviceaccount jenkins ``` ```none serviceaccount/jenkins created ``` You can manually create an associated token: ```bash kubectl create token jenkins ``` ```none eyJhbGciOiJSUzI1NiIsImtp... ``` The created token is a signed [JSON Web Token](https://www.rfc-editor.org/rfc/rfc7519) (JWT). The signed JWT can be used as a bearer token to authenticate as the given service account. See [above](#putting-a-bearer-token-in-a-request) for how the token is | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.07618412375450134,
0.014374316670000553,
0.007151824422180653,
0.02420070953667164,
0.00106741301715374,
0.004657871555536985,
-0.01098725013434887,
0.004569284617900848,
0.08920203894376755,
0.05712500959634781,
-0.032140232622623444,
-0.05866647884249687,
0.0479191392660141,
-0.009104... | 0.137682 |
You can manually create an associated token: ```bash kubectl create token jenkins ``` ```none eyJhbGciOiJSUzI1NiIsImtp... ``` The created token is a signed [JSON Web Token](https://www.rfc-editor.org/rfc/rfc7519) (JWT). The signed JWT can be used as a bearer token to authenticate as the given service account. See [above](#putting-a-bearer-token-in-a-request) for how the token is included in a request. Normally these tokens are mounted into pods for in-cluster access to the API server, but can be used from outside the cluster as well. Service accounts authenticate with the username `system:serviceaccount:(NAMESPACE):(SERVICEACCOUNT)`, and are assigned to the groups `system:serviceaccounts` and `system:serviceaccounts:(NAMESPACE)`. {{< warning >}} Because service account tokens can also be stored in Secret API objects, any user with write access to Secrets can request a token, and any user with read access to those Secrets can authenticate as the service account. Be cautious when granting permissions to service accounts and read or write capabilities for Secrets. {{< /warning >}} ## External integrations Kubernetes has native support for JWT and for OpenID Connect (OIDC); see [JSON Web Token authentication](#json-web-token-authentication). Integrations with other authentication protocols (for example: LDAP, SAML, Kerberos, alternate X.509 schemes) can be accomplished using an [authenticating proxy](#authenticating-proxy) or by integrating with an [authentication webhook](#webhook-token-authentication). You can also use any custom method that issues [client X.509 certificates](#x509-client-certificates) to clients, provided that the API server will trust the valid certificates. Read [X.509 client certificates](#x509-client-certificates) to learn about how to generate a certificate. If you do issue certificates to clients, it is up to you (as a cloud platform administrator) to make sure that the certificate validity period, and other design choices you make, provide a suitable level of security. ### JSON Web Token authentication You can configure Kubernetes to authenticate users using [JSON Web Token](https://www.rfc-editor.org/rfc/rfc7519) (JWT) compliant tokens. JWT authentication mechanism is used for the ServiceAccount tokens that Kubernetes itself issues, and you can also use it to integrate with other identity sources. The authenticator attempts to parse a raw ID token, verify it's been signed by the configured issuer. For externally issued tokens, the public key to verify the signature is discovered from the issuer's public endpoint using OIDC discovery. The minimum valid JWT payload \*\*must\*\* contain the following claims: ```javascript { "iss": "https://example.com", // must match the issuer.url "aud": ["my-app"], // at least one of the entries in issuer.audiences must match the "aud" claim in presented JWTs. "exp": 1234567890, // token expiration as Unix time (the number of seconds elapsed since January 1, 1970 UTC) "": "user" // this is the username claim configured in the claimMappings.username.claim or claimMappings.username.expression } ``` #### JWT egress selector type {{< feature-state feature\_gate\_name="StructuredAuthenticationConfigurationEgressSelector" >}} The `egressSelectorType` field in the JWT issuer configuration allows you to specify which \_egress selector\_ should be used for sending all traffic related to the issuer (discovery, JWKS, distributed claims, etc). This feature requires the `StructuredAuthenticationConfigurationEgressSelector` feature gate to be enabled. #### OpenID Connect tokens [OpenID Connect](https://openid.net/connect/) is a flavor of OAuth2 supported by some OAuth2 providers, notably Microsoft Entra ID, Salesforce, and Google. The protocol's main extension of OAuth2 is an additional field returned with the access token called an [ID Token](https://openid.net/specs/openid-connect-core-1\_0.html#IDToken). This token is a JSON Web Token (JWT) with well known fields, such as a user's email, signed by the server. To identify the user, the authenticator uses the `id\_token` (not the `access\_token`) from the OAuth2 [token response](https://openid.net/specs/openid-connect-core-1\_0.html#TokenResponse) as a bearer token. See [above](#putting-a-bearer-token-in-a-request) for how the token is included in a request. {{< mermaid >}} sequenceDiagram participant user as User participant idp as Identity Provider participant kube as kubectl participant api as API Server user ->> idp: 1. Log in to | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.04158506542444229,
-0.028164535760879517,
-0.016480404883623123,
-0.03166612237691879,
-0.06540984660387039,
-0.035232678055763245,
0.036010660231113434,
0.008545484393835068,
0.12090625613927841,
0.013380865566432476,
-0.0976596549153328,
-0.09654324501752853,
0.0487399585545063,
-0.01... | 0.193041 |
`access\_token`) from the OAuth2 [token response](https://openid.net/specs/openid-connect-core-1\_0.html#TokenResponse) as a bearer token. See [above](#putting-a-bearer-token-in-a-request) for how the token is included in a request. {{< mermaid >}} sequenceDiagram participant user as User participant idp as Identity Provider participant kube as kubectl participant api as API Server user ->> idp: 1. Log in to IdP activate idp idp -->> user: 2. Provide access\_token, id\_token, and refresh\_token deactivate idp activate user user ->> kube: 3. Call kubectl with --token being the id\_token OR add tokens to .kube/config deactivate user activate kube kube ->> api: 4. Authorization: Bearer... deactivate kube activate api api ->> api: 5. Is JWT signature valid? api ->> api: 6. Has the JWT expired? (iat+exp) api ->> api: 7. User authorized? api -->> kube: 8. Authorized: Perform action and return result deactivate api activate kube kube --x user: 9. Return result deactivate kube {{< /mermaid >}} 1. Log in to your identity provider 1. Your identity provider will provide you with an `access\_token`, `id\_token` and a `refresh\_token` 1. When using `kubectl`, use your `id\_token` with the `--token` command line argument or add it directly to your `kubeconfig` 1. `kubectl` sends your `id\_token` in a header called Authorization to the API server 1. The API server will make sure the JWT signature is valid 1. Check to make sure the `id\_token` hasn't expired Perform claim and/or user validation if CEL expressions are configured with `AuthenticationConfiguration`. 1. Make sure the user is authorized 1. Once authorized the API server returns a response to `kubectl` 1. `kubectl` provides feedback to the user Since all of the data needed to validate who you are is in the `id\_token`, Kubernetes doesn't need to "phone home" to the identity provider. In a model where every request is stateless this provides a very scalable solution for authentication. It does offer a few challenges: 1. Kubernetes has no "web interface" to trigger the authentication process. There is no browser or interface to collect credentials which is why you need to authenticate to your identity provider first. 1. The `id\_token` can't be revoked, it's like a certificate so it should be short-lived (only a few minutes) so it can be very annoying to have to get a new token every few minutes. 1. To authenticate to the Kubernetes dashboard, you must use the `kubectl proxy` command or a reverse proxy that injects the `id\_token`. #### Configuring the API Server ##### Using command line arguments To enable the plugin, configure the following command line arguments for the API server: | Parameter | Description | Example | Required | | --------- | ----------- | ------- | ------- | | `--oidc-issuer-url` | URL of the provider that allows the API server to discover public signing keys. Only URLs that use the `https://` scheme are accepted. This is typically the provider's discovery URL, changed to have an empty path. | If the issuer's OIDC discovery URL is `https://accounts.provider.example/.well-known/openid-configuration`, the value should be `https://accounts.provider.example` | Yes | | `--oidc-client-id` | A client id that all tokens must be issued for. | kubernetes | Yes | | `--oidc-username-claim` | JWT claim to use as the user name. By default `sub`, which is expected to be a unique identifier of the end user. Admins can choose other claims, such as `email` or `name`, depending on their provider. However, claims other than `email` will be prefixed with the issuer URL to prevent naming clashes with other plugins. | sub | No | | `--oidc-username-prefix` | Prefix prepended to username claims to prevent clashes with existing names (such as `system:` users). For example, the value `oidc:` will create usernames like | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.004945874679833651,
0.05408931523561478,
0.05363118276000023,
-0.021278347820043564,
-0.01875528320670128,
-0.03168721869587898,
0.041403643786907196,
0.04486348107457161,
0.08528262376785278,
-0.05468352884054184,
-0.03262912109494209,
-0.054727502167224884,
-0.021863916888833046,
-0.0... | 0.17217 |
claims other than `email` will be prefixed with the issuer URL to prevent naming clashes with other plugins. | sub | No | | `--oidc-username-prefix` | Prefix prepended to username claims to prevent clashes with existing names (such as `system:` users). For example, the value `oidc:` will create usernames like `oidc:jane.doe`. If this argument isn't provided and `--oidc-username-claim` is a value other than `email` the prefix defaults to `( Issuer URL )#` where `( Issuer URL )` is the value of `--oidc-issuer-url`. The value `-` can be used to disable all prefixing. | `oidc:` | No | | `--oidc-groups-claim` | JWT claim to use as the user's group. If the claim is present it must be an array of strings. | groups | No | | `--oidc-groups-prefix` | Prefix prepended to group claims to prevent clashes with existing names (such as `system:` groups). For example, the value `oidc:` will create group names like `oidc:engineering` and `oidc:infra`. | `oidc:` | No | | `--oidc-required-claim` | A key=value pair that describes a required claim in the ID Token. If set, the claim is verified to be present in the ID Token with a matching value. Repeat this argument to specify multiple claims. | `claim=value` | No | | `--oidc-ca-file` | The path to the certificate for the CA that signed your identity provider's web certificate. Defaults to the host's root CAs. | `/etc/kubernetes/ssl/kc-ca.pem` | No | | `--oidc-signing-algs` | The signing algorithms accepted. Default is RS256. Allowed values are: RS256, RS384, RS512, ES256, ES384, ES512, PS256, PS384, PS512. Values are defined by RFC 7518 https://tools.ietf.org/html/rfc7518#section-3.1. | `RS512` | No | ##### Authentication configuration from a file {#using-authentication-configuration} {{< feature-state feature\_gate\_name="StructuredAuthenticationConfiguration" >}} The configuration file approach allows you to configure multiple JWT authenticators, each with a unique `issuer.url` and `issuer.discoveryURL`. The configuration file even allows you to specify [CEL](/docs/reference/using-api/cel/) expressions to map claims to user attributes, and to validate claims and user information. The API server also automatically reloads the authenticators when the configuration file is modified. You can use `apiserver\_authentication\_config\_controller\_automatic\_reload\_last\_timestamp\_seconds` metric to monitor the last time the configuration was reloaded by the API server. You must specify the path to the authentication configuration using the `--authentication-config` command line argument to the API server. If you want to use command line arguments instead of the configuration file, those will continue to work as-is. To access the new capabilities like configuring multiple authenticators, setting multiple audiences for an issuer, switch to using the configuration file. To use structured authentication, specify the `--authentication-config` command line argument to the kube-apiserver. An example of the structured authentication configuration file is shown below. {{< note >}} If you specify `--authentication-config` along with any of the `--oidc-\*` command line arguments, this is a misconfiguration. In this situation, the API server reports an error and then immediately exits. If you want to switch to using structured authentication configuration, you have to remove the `--oidc-\*` command line arguments, and use the configuration file instead. {{< /note >}} {{< highlight yaml "linenos=false,hl\_lines=2-5" >}} --- # # CAUTION: this is an example configuration. # Do not use this for your own cluster! # apiVersion: apiserver.config.k8s.io/v1 kind: AuthenticationConfiguration # list of authenticators to authenticate Kubernetes users using JWT compliant tokens. # the maximum number of allowed authenticators is 64. jwt: - issuer: # url must be unique across all authenticators. # url must not conflict with issuer configured in --service-account-issuer. url: https://example.com # Same as --oidc-issuer-url. # discoveryURL, if specified, overrides the URL used to fetch discovery # information instead of using "{url}/.well-known/openid-configuration". # The exact value specified is used, so "/.well-known/openid-configuration" # must | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.16626060009002686,
0.02121191844344139,
-0.03477061912417412,
0.048271480947732925,
0.01439568493515253,
-0.06638369709253311,
0.024155255407094955,
0.01520032249391079,
0.035399630665779114,
-0.0752781480550766,
-0.011977003887295723,
-0.06832169741392136,
0.04581403359770775,
0.002322... | 0.079776 |
must be unique across all authenticators. # url must not conflict with issuer configured in --service-account-issuer. url: https://example.com # Same as --oidc-issuer-url. # discoveryURL, if specified, overrides the URL used to fetch discovery # information instead of using "{url}/.well-known/openid-configuration". # The exact value specified is used, so "/.well-known/openid-configuration" # must be included in discoveryURL if needed. # # The "issuer" field in the fetched discovery information must match the "issuer.url" field # in the AuthenticationConfiguration and will be used to validate the "iss" claim in the presented JWT. # This is for scenarios where the well-known and jwks endpoints are hosted at a different # location than the issuer (such as locally in the cluster). # discoveryURL must be different from url if specified and must be unique across all authenticators. discoveryURL: https://discovery.example.com/.well-known/openid-configuration # PEM encoded CA certificates used to validate the connection when fetching # discovery information. If not set, the system verifier will be used. # Same value as the content of the file referenced by the --oidc-ca-file command line argument. certificateAuthority: # audiences is the set of acceptable audiences the JWT must be issued to. # At least one of the entries must match the "aud" claim in presented JWTs. audiences: - my-app # Same as --oidc-client-id. - my-other-app # this is required to be set to "MatchAny" when multiple audiences are specified. audienceMatchPolicy: MatchAny # egressSelectorType is an indicator of which egress selection should be used for sending all traffic related # to this issuer (discovery, JWKS, distributed claims, etc). If unspecified, no custom dialer is used. # The StructuredAuthenticationConfigurationEgressSelector feature gate must be enabled # before you can use the egressSelectorType field. # When specified, the valid choices are "controlplane" and "cluster". These correspond to the associated # values in the --egress-selector-config-file. # - controlplane: for traffic intended to go to the control plane. # - cluster: for traffic intended to go to the system being managed by Kubernetes. egressSelectorType: # rules applied to validate token claims to authenticate users. claimValidationRules: # Same as --oidc-required-claim key=value. - claim: hd requiredValue: example.com # Instead of claim and requiredValue, you can use expression to validate the claim. # expression is a CEL expression that evaluates to a boolean. # all the expressions must evaluate to true for validation to succeed. - expression: 'claims.hd == "example.com"' # Message customizes the error message seen in the API server logs when the validation fails. message: the hd claim must be set to example.com - expression: 'claims.exp - claims.nbf <= 86400' message: total token lifetime must not exceed 24 hours claimMappings: # username represents an option for the username attribute. # This is the only required attribute. username: # Same as --oidc-username-claim. Mutually exclusive with username.expression. claim: "sub" # Same as --oidc-username-prefix. Mutually exclusive with username.expression. # if username.claim is set, username.prefix is required. # Explicitly set it to "" if no prefix is desired. prefix: "" # Mutually exclusive with username.claim and username.prefix. # expression is a CEL expression that evaluates to a string. # # 1. If username.expression uses 'claims.email', then 'claims.email\_verified' must be used in # username.expression or extra[\*].valueExpression or claimValidationRules[\*].expression. # An example claim validation rule expression that matches the validation automatically # applied when username.claim is set to 'email' is 'claims.?email\_verified.orValue(true) == true'. # By explicitly comparing the value to true, we let type-checking see the result will be a boolean, and # to make sure a non-boolean email\_verified claim will be caught at runtime. # 2. If the username asserted based on username.expression is the empty string, the authentication # request will fail. expression: 'claims.username | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.09198292344808578,
0.06006778031587601,
0.007088271901011467,
0.03654847666621208,
0.021691223606467247,
-0.05649271607398987,
0.03563278540968895,
-0.05338399484753609,
0.056743357330560684,
-0.03314443305134773,
-0.04879818111658096,
-0.05454310402274132,
0.08476781845092773,
0.023399... | 0.036503 |
comparing the value to true, we let type-checking see the result will be a boolean, and # to make sure a non-boolean email\_verified claim will be caught at runtime. # 2. If the username asserted based on username.expression is the empty string, the authentication # request will fail. expression: 'claims.username + ":external-user"' # groups represents an option for the groups attribute. groups: # Same as --oidc-groups-claim. Mutually exclusive with groups.expression. claim: "sub" # Same as --oidc-groups-prefix. Mutually exclusive with groups.expression. # if groups.claim is set, groups.prefix is required. # Explicitly set it to "" if no prefix is desired. prefix: "" # Mutually exclusive with groups.claim and groups.prefix. # expression is a CEL expression that evaluates to a string or a list of strings. expression: 'claims.roles.split(",")' # uid represents an option for the uid attribute. uid: # Mutually exclusive with uid.expression. claim: 'sub' # Mutually exclusive with uid.claim # expression is a CEL expression that evaluates to a string. expression: 'claims.sub' # extra attributes to be added to the UserInfo object. Keys must be domain-prefix path and must be unique. extra: # key is a string to use as the extra attribute key. # key must be a domain-prefix path (e.g. example.org/foo). All characters before the first "/" must be a valid # subdomain as defined by RFC 1123. All characters trailing the first "/" must # be valid HTTP Path characters as defined by RFC 3986. # k8s.io, kubernetes.io and their subdomains are reserved for Kubernetes use and cannot be used. # key must be lowercase and unique across all extra attributes. - key: 'example.com/tenant' # valueExpression is a CEL expression that evaluates to a string or a list of strings. valueExpression: 'claims.tenant' # validation rules applied to the final user object. userValidationRules: # expression is a CEL expression that evaluates to a boolean. # all the expressions must evaluate to true for the user to be valid. - expression: "!user.username.startsWith('system:')" # Message customizes the error message seen in the API server logs when the validation fails. message: 'username cannot used reserved system: prefix' - expression: "user.groups.all(group, !group.startsWith('system:'))" message: 'groups cannot used reserved system: prefix' {{< /highlight >}} \* Claim validation rule expression `jwt.claimValidationRules[i].expression` represents the expression which will be evaluated by CEL. CEL expressions have access to the contents of the token payload, organized into `claims` CEL variable. `claims` is a map of claim names (as strings) to claim values (of any type). \* User validation rule expression `jwt.userValidationRules[i].expression` represents the expression which will be evaluated by CEL. CEL expressions have access to the contents of `userInfo`, organized into `user` CEL variable. Refer to the [UserInfo](/docs/reference/generated/kubernetes-api/v{{< skew currentVersion >}}/#userinfo-v1-authentication-k8s-io) API documentation for the schema of `user`. \* Claim mapping expression `jwt.claimMappings.username.expression`, `jwt.claimMappings.groups.expression`, `jwt.claimMappings.uid.expression` `jwt.claimMappings.extra[i].valueExpression` represents the expression which will be evaluated by CEL. CEL expressions have access to the contents of the token payload, organized into `claims` CEL variable. `claims` is a map of claim names (as strings) to claim values (of any type). To learn more, see the [Documentation on CEL](/docs/reference/using-api/cel/) Here are examples of the `AuthenticationConfiguration` with different token payloads. {{< tabs name="example\_configuration" >}} {{% tab name="Valid token" %}} ```yaml apiVersion: apiserver.config.k8s.io/v1 kind: AuthenticationConfiguration jwt: - issuer: url: https://example.com audiences: - my-app claimMappings: username: expression: 'claims.username + ":external-user"' groups: expression: 'claims.roles.split(",")' uid: expression: 'claims.sub' extra: - key: 'example.com/tenant' valueExpression: 'claims.tenant' userValidationRules: - expression: "!user.username.startsWith('system:')" # the expression will evaluate to true, so validation will succeed. message: 'username cannot used reserved system: prefix' ``` ```bash TOKEN=eyJhbGciOiJSUzI1NiIsImtpZCI6ImY3dF9tOEROWmFTQk1oWGw5QXZTWGhBUC04Y0JmZ0JVbFVpTG5oQkgxdXMiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJrdWJlcm5ldGVzIiwiZXhwIjoxNzAzMjMyOTQ5LCJpYXQiOjE3MDExMDcyMzMsImlzcyI6Imh0dHBzOi8vZXhhbXBsZS5jb20iLCJqdGkiOiI3YzMzNzk0MjgwN2U3M2NhYTJjMzBjODY4YWMwY2U5MTBiY2UwMmRkY2JmZWJlOGMyM2I4YjVmMjdhZDYyODczIiwibmJmIjoxNzAxMTA3MjMzLCJyb2xlcyI6InVzZXIsYWRtaW4iLCJzdWIiOiJhdXRoIiwidGVuYW50IjoiNzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjRhIiwidXNlcm5hbWUiOiJmb28ifQ.TBWF2RkQHm4QQz85AYPcwLxSk-VLvQW-mNDHx7SEOSv9LVwcPYPuPajJpuQn9C\_gKq1R94QKSQ5F6UgHMILz8OfmPKmX\_00wpwwNVGeevJ79ieX2V-\_\_W56iNR5gJ-i9nn6FYk5pwfVREB0l4HSlpTOmu80gbPWAXY5hLW0ZtcE1JTEEmefORHV2ge8e3jp1xGafNy6LdJWabYuKiw8d7Qga\_\_HxtKB-t0kRMNzLRS7rka\_SfQg0dSYektuxhLbiDkqhmRffGlQKXGVzUsuvFw7IGM5ZWnZgEMDzCI357obHeM3tRqpn5WRjtB8oM7JgnCymaJi-P3iCd88iu1xnzA ``` where the token payload is: ```json { "aud": "kubernetes", "exp": 1703232949, "iat": 1701107233, "iss": "https://example.com", "jti": "7c337942807e73caa2c30c868ac0ce910bce02ddcbfebe8c23b8b5f27ad62873", "nbf": 1701107233, "roles": | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.14330941438674927,
0.06601408123970032,
-0.009826350025832653,
0.0828377902507782,
0.03871644660830498,
-0.050406184047460556,
0.0900656208395958,
0.0009573157876729965,
0.02609427459537983,
-0.06428346782922745,
0.016784626990556717,
-0.12376496195793152,
0.06925364583730698,
0.0535169... | -0.006408 |
key: 'example.com/tenant' valueExpression: 'claims.tenant' userValidationRules: - expression: "!user.username.startsWith('system:')" # the expression will evaluate to true, so validation will succeed. message: 'username cannot used reserved system: prefix' ``` ```bash TOKEN=eyJhbGciOiJSUzI1NiIsImtpZCI6ImY3dF9tOEROWmFTQk1oWGw5QXZTWGhBUC04Y0JmZ0JVbFVpTG5oQkgxdXMiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJrdWJlcm5ldGVzIiwiZXhwIjoxNzAzMjMyOTQ5LCJpYXQiOjE3MDExMDcyMzMsImlzcyI6Imh0dHBzOi8vZXhhbXBsZS5jb20iLCJqdGkiOiI3YzMzNzk0MjgwN2U3M2NhYTJjMzBjODY4YWMwY2U5MTBiY2UwMmRkY2JmZWJlOGMyM2I4YjVmMjdhZDYyODczIiwibmJmIjoxNzAxMTA3MjMzLCJyb2xlcyI6InVzZXIsYWRtaW4iLCJzdWIiOiJhdXRoIiwidGVuYW50IjoiNzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjRhIiwidXNlcm5hbWUiOiJmb28ifQ.TBWF2RkQHm4QQz85AYPcwLxSk-VLvQW-mNDHx7SEOSv9LVwcPYPuPajJpuQn9C\_gKq1R94QKSQ5F6UgHMILz8OfmPKmX\_00wpwwNVGeevJ79ieX2V-\_\_W56iNR5gJ-i9nn6FYk5pwfVREB0l4HSlpTOmu80gbPWAXY5hLW0ZtcE1JTEEmefORHV2ge8e3jp1xGafNy6LdJWabYuKiw8d7Qga\_\_HxtKB-t0kRMNzLRS7rka\_SfQg0dSYektuxhLbiDkqhmRffGlQKXGVzUsuvFw7IGM5ZWnZgEMDzCI357obHeM3tRqpn5WRjtB8oM7JgnCymaJi-P3iCd88iu1xnzA ``` where the token payload is: ```json { "aud": "kubernetes", "exp": 1703232949, "iat": 1701107233, "iss": "https://example.com", "jti": "7c337942807e73caa2c30c868ac0ce910bce02ddcbfebe8c23b8b5f27ad62873", "nbf": 1701107233, "roles": "user,admin", "sub": "auth", "tenant": "72f988bf-86f1-41af-91ab-2d7cd011db4a", "username": "foo" } ``` The token with the above `AuthenticationConfiguration` will produce the following `UserInfo` object and successfully authenticate the user. ```json { "username": "foo:external-user", "uid": "auth", "groups": [ "user", "admin" ], "extra": { "example.com/tenant": ["72f988bf-86f1-41af-91ab-2d7cd011db4a"] } } ``` {{% /tab %}} {{% tab name="Fails claim validation" %}} ```yaml apiVersion: apiserver.config.k8s.io/v1 kind: AuthenticationConfiguration jwt: - issuer: url: https://example.com audiences: - my-app claimValidationRules: - expression: 'claims.hd == "example.com"' # the token below does not have this claim, so validation will fail. message: the hd claim must be set to example.com claimMappings: username: expression: 'claims.username + ":external-user"' groups: expression: 'claims.roles.split(",")' uid: expression: 'claims.sub' extra: - key: 'example.com/tenant' valueExpression: 'claims.tenant' userValidationRules: - expression: "!user.username.startsWith('system:')" # the expression will evaluate to true, so validation will succeed. message: 'username cannot used reserved system: prefix' ``` ```bash TOKEN=eyJhbGciOiJSUzI1NiIsImtpZCI6ImY3dF9tOEROWmFTQk1oWGw5QXZTWGhBUC04Y0JmZ0JVbFVpTG5oQkgxdXMiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJrdWJlcm5ldGVzIiwiZXhwIjoxNzAzMjMyOTQ5LCJpYXQiOjE3MDExMDcyMzMsImlzcyI6Imh0dHBzOi8vZXhhbXBsZS5jb20iLCJqdGkiOiI3YzMzNzk0MjgwN2U3M2NhYTJjMzBjODY4YWMwY2U5MTBiY2UwMmRkY2JmZWJlOGMyM2I4YjVmMjdhZDYyODczIiwibmJmIjoxNzAxMTA3MjMzLCJyb2xlcyI6InVzZXIsYWRtaW4iLCJzdWIiOiJhdXRoIiwidGVuYW50IjoiNzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjRhIiwidXNlcm5hbWUiOiJmb28ifQ.TBWF2RkQHm4QQz85AYPcwLxSk-VLvQW-mNDHx7SEOSv9LVwcPYPuPajJpuQn9C\_gKq1R94QKSQ5F6UgHMILz8OfmPKmX\_00wpwwNVGeevJ79ieX2V-\_\_W56iNR5gJ-i9nn6FYk5pwfVREB0l4HSlpTOmu80gbPWAXY5hLW0ZtcE1JTEEmefORHV2ge8e3jp1xGafNy6LdJWabYuKiw8d7Qga\_\_HxtKB-t0kRMNzLRS7rka\_SfQg0dSYektuxhLbiDkqhmRffGlQKXGVzUsuvFw7IGM5ZWnZgEMDzCI357obHeM3tRqpn5WRjtB8oM7JgnCymaJi-P3iCd88iu1xnzA ``` where the token payload is: ```json { "aud": "kubernetes", "exp": 1703232949, "iat": 1701107233, "iss": "https://example.com", "jti": "7c337942807e73caa2c30c868ac0ce910bce02ddcbfebe8c23b8b5f27ad62873", "nbf": 1701107233, "roles": "user,admin", "sub": "auth", "tenant": "72f988bf-86f1-41af-91ab-2d7cd011db4a", "username": "foo" } ``` The token with the above `AuthenticationConfiguration` will fail to authenticate because the `hd` claim is not set to `example.com`. The API server will return `401 Unauthorized` error. {{% /tab %}} {{% tab name="Fails user validation" %}} ```yaml apiVersion: apiserver.config.k8s.io/v1 kind: AuthenticationConfiguration jwt: - issuer: url: https://example.com audiences: - my-app claimValidationRules: - expression: 'claims.hd == "example.com"' message: the hd claim must be set to example.com claimMappings: username: expression: '"system:" + claims.username' # this will prefix the username with "system:" and will fail user validation. groups: expression: 'claims.roles.split(",")' uid: expression: 'claims.sub' extra: - key: 'example.com/tenant' valueExpression: 'claims.tenant' userValidationRules: - expression: "!user.username.startsWith('system:')" # the username will be system:foo and expression will evaluate to false, so validation will fail. message: 'username cannot used reserved system: prefix' ``` ```bash TOKEN=eyJhbGciOiJSUzI1NiIsImtpZCI6ImY3dF9tOEROWmFTQk1oWGw5QXZTWGhBUC04Y0JmZ0JVbFVpTG5oQkgxdXMiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJrdWJlcm5ldGVzIiwiZXhwIjoxNzAzMjMyOTQ5LCJoZCI6ImV4YW1wbGUuY29tIiwiaWF0IjoxNzAxMTEzMTAxLCJpc3MiOiJodHRwczovL2V4YW1wbGUuY29tIiwianRpIjoiYjViMDY1MjM3MmNkMjBlMzQ1YjZmZGZmY2RjMjE4MWY0YWZkNmYyNTlhYWI0YjdlMzU4ODEyMzdkMjkyMjBiYyIsIm5iZiI6MTcwMTExMzEwMSwicm9sZXMiOiJ1c2VyLGFkbWluIiwic3ViIjoiYXV0aCIsInRlbmFudCI6IjcyZjk4OGJmLTg2ZjEtNDFhZi05MWFiLTJkN2NkMDExZGI0YSIsInVzZXJuYW1lIjoiZm9vIn0.FgPJBYLobo9jnbHreooBlvpgEcSPWnKfX6dc0IvdlRB-F0dCcgy91oCJeK\_aBk-8zH5AKUXoFTlInfLCkPivMOJqMECA1YTrMUwt\_IVqwb116AqihfByUYIIqzMjvUbthtbpIeHQm2fF0HbrUqa\_Q0uaYwgy8mD807h7sBcUMjNd215ff\_nFIHss-9zegH8GI1d9fiBf-g6zjkR1j987EP748khpQh9IxPjMJbSgG\_uH5x80YFuqgEWwq-aYJPQxXX6FatP96a2EAn7wfPpGlPRt0HcBOvq5pCnudgCgfVgiOJiLr\_7robQu4T1bis0W75VPEvwWtgFcLnvcQx0JWg ``` where the token payload is: ```json { "aud": "kubernetes", "exp": 1703232949, "hd": "example.com", "iat": 1701113101, "iss": "https://example.com", "jti": "b5b0652372cd20e345b6fdffcdc2181f4afd6f259aab4b7e35881237d29220bc", "nbf": 1701113101, "roles": "user,admin", "sub": "auth", "tenant": "72f988bf-86f1-41af-91ab-2d7cd011db4a", "username": "foo" } ``` The token with the above `AuthenticationConfiguration` will produce the following `UserInfo` object: ```json { "username": "system:foo", "uid": "auth", "groups": [ "user", "admin" ], "extra": { "example.com/tenant": ["72f988bf-86f1-41af-91ab-2d7cd011db4a"] } } ``` which will fail user validation because the username starts with `system:`. The API server will return `401 Unauthorized` error. {{% /tab %}} {{< /tabs >}} ##### Limitations {#oidc-limitations} 1. Distributed claims do not work via [CEL](/docs/reference/using-api/cel/) expressions. Kubernetes does not provide an OpenID Connect Identity Provider. You can use an existing public OpenID Connect Identity Provider or run your own Identity Provider that supports the OpenID Connect protocol. For an identity provider to work with Kubernetes it must: 1. Support [OpenID connect discovery](https://openid.net/specs/openid-connect-discovery-1\_0.html) The public key to verify the signature is discovered from the issuer's public endpoint using OIDC discovery. If you're using the authentication configuration file, the identity provider doesn't need to publicly expose the discovery endpoint. You can host the discovery endpoint at a different location than the issuer (such as locally in the cluster) and specify the `issuer.discoveryURL` in the configuration file. 1. Run in TLS with non-obsolete ciphers 1. Have a CA signed certificate (even if the CA is not a commercial CA or is self signed) A note about requirement #3 above, requiring a CA signed certificate. If you deploy your own identity provider you MUST have your identity provider's web | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
0.0005654102424159646,
-0.017072219401597977,
-0.06779985129833221,
-0.02083137072622776,
0.013373732566833496,
-0.003902232740074396,
0.05901804566383362,
0.006610936485230923,
0.04513216018676758,
0.009842699393630028,
0.0689268633723259,
-0.09976962953805923,
0.07767433673143387,
0.0296... | 0.008076 |
Run in TLS with non-obsolete ciphers 1. Have a CA signed certificate (even if the CA is not a commercial CA or is self signed) A note about requirement #3 above, requiring a CA signed certificate. If you deploy your own identity provider you MUST have your identity provider's web server certificate signed by a certificate with the `CA` flag set to `TRUE`, even if it is self signed. This is due to GoLang's TLS client implementation being very strict to the standards around certificate validation. If you don't have a CA handy, you can create a simple CA and a signed certificate and key pair using standard certificate generation tools. #### Using kubectl ##### Option 1 - OIDC authenticator The first option is to use the kubectl `oidc` authenticator, which sets the `id\_token` as a bearer token for all requests and refreshes the token once it expires. After you've logged into your provider, use kubectl to add your `id\_token`, `refresh\_token`, `client\_id`, and `client\_secret` to configure the plugin. Providers that don't return an `id\_token` as part of their refresh token response aren't supported by this plugin and should use [Option 2](#option-2-use-the-token-option) (specifying `--token`). ```bash kubectl config set-credentials USER\_NAME \ --auth-provider=oidc \ --auth-provider-arg=idp-issuer-url=( issuer url ) \ --auth-provider-arg=client-id=( your client id ) \ --auth-provider-arg=client-secret=( your client secret ) \ --auth-provider-arg=refresh-token=( your refresh token ) \ --auth-provider-arg=idp-certificate-authority=( path to your ca certificate ) \ --auth-provider-arg=id-token=( your id\_token ) ``` As an example, running the below command after authenticating to your identity provider: ```bash kubectl config set-credentials mmosley \ --auth-provider=oidc \ --auth-provider-arg=idp-issuer-url=https://oidcidp.tremolo.lan:8443/auth/idp/OidcIdP \ --auth-provider-arg=client-id=kubernetes \ --auth-provider-arg=client-secret=1db158f6-177d-4d9c-8a8b-d36869918ec5 \ --auth-provider-arg=refresh-token=q1bKLFOyUiosTfawzA93TzZIDzH2TNa2SMm0zEiPKTUwME6BkEo6Sql5yUWVBSWpKUGphaWpxSVAfekBOZbBhaEW+VlFUeVRGcluyVF5JT4+haZmPsluFoFu5XkpXk5BXqHega4GAXlF+ma+vmYpFcHe5eZR+slBFpZKtQA= \ --auth-provider-arg=idp-certificate-authority=/root/ca.pem \ --auth-provider-arg=id-token=eyJraWQiOiJDTj1vaWRjaWRwLnRyZW1vbG8ubGFuLCBPVT1EZW1vLCBPPVRybWVvbG8gU2VjdXJpdHksIEw9QXJsaW5ndG9uLCBTVD1WaXJnaW5pYSwgQz1VUy1DTj1rdWJlLWNhLTEyMDIxNDc5MjEwMzYwNzMyMTUyIiwiYWxnIjoiUlMyNTYifQ.eyJpc3MiOiJodHRwczovL29pZGNpZHAudHJlbW9sby5sYW46ODQ0My9hdXRoL2lkcC9PaWRjSWRQIiwiYXVkIjoia3ViZXJuZXRlcyIsImV4cCI6MTQ4MzU0OTUxMSwianRpIjoiMm96US15TXdFcHV4WDlHZUhQdy1hZyIsImlhdCI6MTQ4MzU0OTQ1MSwibmJmIjoxNDgzNTQ5MzMxLCJzdWIiOiI0YWViMzdiYS1iNjQ1LTQ4ZmQtYWIzMC0xYTAxZWU0MWUyMTgifQ.w6p4J\_6qQ1HzTG9nrEOrubxIMb9K5hzcMPxc9IxPx2K4xO9l-oFiUw93daH3m5pluP6K7eOE6txBuRVfEcpJSwlelsOsW8gb8VJcnzMS9EnZpeA0tW\_p-mnkFc3VcfyXuhe5R3G7aa5d8uHv70yJ9Y3-UhjiN9EhpMdfPAoEB9fYKKkJRzF7utTTIPGrSaSU6d2pcpfYKaxIwePzEkT4DfcQthoZdy9ucNvvLoi1DIC-UocFD8HLs8LYKEqSxQvOcvnThbObJ9af71EwmuE21fO5KzMW20KtAeget1gnldOosPtz1G5EwvaQ401-RPQzPGMVBld0\_zMCAwZttJ4knw ``` Which would produce the below configuration: ```yaml users: - name: mmosley user: auth-provider: config: client-id: kubernetes client-secret: 1db158f6-177d-4d9c-8a8b-d36869918ec5 id-token: eyJraWQiOiJDTj1vaWRjaWRwLnRyZW1vbG8ubGFuLCBPVT1EZW1vLCBPPVRybWVvbG8gU2VjdXJpdHksIEw9QXJsaW5ndG9uLCBTVD1WaXJnaW5pYSwgQz1VUy1DTj1rdWJlLWNhLTEyMDIxNDc5MjEwMzYwNzMyMTUyIiwiYWxnIjoiUlMyNTYifQ.eyJpc3MiOiJodHRwczovL29pZGNpZHAudHJlbW9sby5sYW46ODQ0My9hdXRoL2lkcC9PaWRjSWRQIiwiYXVkIjoia3ViZXJuZXRlcyIsImV4cCI6MTQ4MzU0OTUxMSwianRpIjoiMm96US15TXdFcHV4WDlHZUhQdy1hZyIsImlhdCI6MTQ4MzU0OTQ1MSwibmJmIjoxNDgzNTQ5MzMxLCJzdWIiOiI0YWViMzdiYS1iNjQ1LTQ4ZmQtYWIzMC0xYTAxZWU0MWUyMTgifQ.w6p4J\_6qQ1HzTG9nrEOrubxIMb9K5hzcMPxc9IxPx2K4xO9l-oFiUw93daH3m5pluP6K7eOE6txBuRVfEcpJSwlelsOsW8gb8VJcnzMS9EnZpeA0tW\_p-mnkFc3VcfyXuhe5R3G7aa5d8uHv70yJ9Y3-UhjiN9EhpMdfPAoEB9fYKKkJRzF7utTTIPGrSaSU6d2pcpfYKaxIwePzEkT4DfcQthoZdy9ucNvvLoi1DIC-UocFD8HLs8LYKEqSxQvOcvnThbObJ9af71EwmuE21fO5KzMW20KtAeget1gnldOosPtz1G5EwvaQ401-RPQzPGMVBld0\_zMCAwZttJ4knw idp-certificate-authority: /root/ca.pem idp-issuer-url: https://oidcidp.tremolo.lan:8443/auth/idp/OidcIdP refresh-token: q1bKLFOyUiosTfawzA93TzZIDzH2TNa2SMm0zEiPKTUwME6BkEo6Sql5yUWVBSWpKUGphaWpxSVAfekBOZbBhaEW+VlFUeVRGcluyVF5JT4+haZmPsluFoFu5XkpXk5BXq name: oidc ``` Once your `id\_token` expires, `kubectl` will attempt to refresh your `id\_token` using your `refresh\_token` and `client\_secret` storing the new values for the `refresh\_token` and `id\_token` in your `.kube/config`. ##### Option 2 - Use the `--token` command line argument {#option-2-use-the-token-option} The `kubectl` command lets you pass in a token using the `--token` command line argument. Copy and paste the `id\_token` into this option: ```bash kubectl --token=eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL21sYi50cmVtb2xvLmxhbjo4MDQzL2F1dGgvaWRwL29pZGMiLCJhdWQiOiJrdWJlcm5ldGVzIiwiZXhwIjoxNDc0NTk2NjY5LCJqdGkiOiI2RDUzNXoxUEpFNjJOR3QxaWVyYm9RIiwiaWF0IjoxNDc0NTk2MzY5LCJuYmYiOjE0NzQ1OTYyNDksInN1YiI6Im13aW5kdSIsInVzZXJfcm9sZSI6WyJ1c2VycyIsIm5ldy1uYW1lc3BhY2Utdmlld2VyIl0sImVtYWlsIjoibXdpbmR1QG5vbW9yZWplZGkuY29tIn0.f2As579n9VNoaKzoF-dOQGmXkFKf1FMyNV0-va\_B63jn-\_n9LGSCca\_6IVMP8pO-Zb4KvRqGyTP0r3HkHxYy5c81AnIh8ijarruczl-TK\_yF5akjSTHFZD-0gRzlevBDiH8Q79NAr-ky0P4iIXS8lY9Vnjch5MF74Zx0c3alKJHJUnnpjIACByfF2SCaYzbWFMUNat-K1PaUk5-ujMBG7yYnr95xD-63n8CO8teGUAAEMx6zRjzfhnhbzX-ajwZLGwGUBT4WqjMs70-6a7\_8gZmLZb2az1cZynkFRj2BaCkVT3A2RrjeEwZEtGXlMqKJ1\_I2ulrOVsYx01\_yD35-rw get nodes ``` ### Webhook token authentication Kubernetes \_webhook authentication\_ is a mechanism to make an HTTP callout for verifying bearer tokens. In terms of how you configure the API server: \* `--authentication-token-webhook-config-file` a configuration file describing how to access the remote webhook service. \* `--authentication-token-webhook-cache-ttl` how long to cache authentication decisions. Defaults to two minutes. \* `--authentication-token-webhook-version` determines whether to use `authentication.k8s.io/v1beta1` or `authentication.k8s.io/v1` `TokenReview` objects to send/receive information from the webhook. Defaults to `v1beta1`. The configuration file uses the [kubeconfig](/docs/concepts/configuration/organize-cluster-access-kubeconfig/) file format. Within the file, `clusters` refers to the remote service and `users` refers to the API server webhook. An example would be: ```yaml # Kubernetes API version apiVersion: v1 # kind of the API object kind: Config # clusters refers to the remote service. clusters: - name: name-of-remote-authn-service cluster: certificate-authority: /path/to/ca.pem # CA for verifying the remote service. server: https://authn.example.com/authenticate # URL of remote service to query. 'https' recommended for production. # users refers to the API server's webhook configuration. users: - name: name-of-api-server user: client-certificate: /path/to/cert.pem # cert for the webhook plugin to use client-key: /path/to/key.pem # key matching the cert # kubeconfig files require a context. Provide one for the API server. current-context: webhook contexts: - context: cluster: name-of-remote-authn-service user: name-of-api-server name: webhook ``` When a client attempts to authenticate with the API server using a bearer token as discussed [above](#putting-a-bearer-token-in-a-request), the authentication webhook POSTs a JSON-serialized `TokenReview` object containing the | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.031123757362365723,
0.0747566968202591,
0.0010148509172722697,
-0.021002747118473053,
-0.09877701103687286,
-0.03323835879564285,
0.03563825413584709,
-0.002990424633026123,
0.10124505311250687,
-0.0629584789276123,
0.000281105050817132,
-0.1258971393108368,
0.014552246779203415,
0.0531... | 0.07122 |
kubeconfig files require a context. Provide one for the API server. current-context: webhook contexts: - context: cluster: name-of-remote-authn-service user: name-of-api-server name: webhook ``` When a client attempts to authenticate with the API server using a bearer token as discussed [above](#putting-a-bearer-token-in-a-request), the authentication webhook POSTs a JSON-serialized `TokenReview` object containing the token to the remote service. Note that webhook API objects are subject to the same [versioning compatibility rules](/docs/concepts/overview/kubernetes-api/) as other Kubernetes API objects. Implementers should check the `apiVersion` field of the request to ensure correct deserialization, and \*\*must\*\* respond with a `TokenReview` object of the same version as the request. {{< tabs name="TokenReview\_request" >}} {{% tab name="authentication.k8s.io/v1" %}} {{< note >}} The Kubernetes API server defaults to sending `authentication.k8s.io/v1beta1` token reviews for backwards compatibility. To opt into receiving `authentication.k8s.io/v1` token reviews, the API server must be started with `--authentication-token-webhook-version=v1`. {{< /note >}} ```yaml { "apiVersion": "authentication.k8s.io/v1", "kind": "TokenReview", "spec": { # Opaque bearer token sent to the API server "token": "014fbff9a07c...", # Optional list of the audience identifiers for the server the token was presented to. # Audience-aware token authenticators (for example, OIDC token authenticators) # should verify the token was intended for at least one of the audiences in this list, # and return the intersection of this list and the valid audiences for the token in the response status. # This ensures the token is valid to authenticate to the server it was presented to. # If no audiences are provided, the token should be validated to authenticate to the Kubernetes API server. "audiences": ["https://myserver.example.com", "https://myserver.internal.example.com"] } } ``` {{% /tab %}} {{% tab name="authentication.k8s.io/v1beta1" %}} ```yaml { "apiVersion": "authentication.k8s.io/v1beta1", "kind": "TokenReview", "spec": { # Opaque bearer token sent to the API server "token": "014fbff9a07c...", # Optional list of the audience identifiers for the server the token was presented to. # Audience-aware token authenticators (for example, OIDC token authenticators) # should verify the token was intended for at least one of the audiences in this list, # and return the intersection of this list and the valid audiences for the token in the response status. # This ensures the token is valid to authenticate to the server it was presented to. # If no audiences are provided, the token should be validated to authenticate to the Kubernetes API server. "audiences": ["https://myserver.example.com", "https://myserver.internal.example.com"] } } ``` {{% /tab %}} {{< /tabs >}} The remote service is expected to fill the `status` field of the request to indicate the success of the login. The response body's `spec` field is ignored and may be omitted. The remote service must return a response using the same `TokenReview` API version that it received. A successful validation of the bearer token would return: {{< tabs name="TokenReview\_response\_success" >}} {{% tab name="authentication.k8s.io/v1" %}} ```yaml { "apiVersion": "authentication.k8s.io/v1", "kind": "TokenReview", "status": { "authenticated": true, "user": { # Required "username": "janedoe@example.com", # Optional "uid": "42", # Optional group memberships "groups": ["developers", "qa"], # Optional additional information provided by the authenticator. # This should not contain confidential data, as it can be recorded in logs # or API objects, and is made available to admission webhooks. "extra": { "extrafield1": [ "extravalue1", "extravalue2" ] } }, # Optional list audience-aware token authenticators can return, # containing the audiences from the `spec.audiences` list for which the provided token was valid. # If this is omitted, the token is considered to be valid to authenticate to the Kubernetes API server. "audiences": ["https://myserver.example.com"] } } ``` {{% /tab %}} {{% tab name="authentication.k8s.io/v1beta1" %}} ```yaml { "apiVersion": "authentication.k8s.io/v1beta1", "kind": "TokenReview", "status": { "authenticated": true, "user": { # Required "username": "janedoe@example.com", # Optional "uid": "42", | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.04455273970961571,
0.043811097741127014,
0.004312238655984402,
-0.03298826515674591,
-0.03887481987476349,
-0.02392509952187538,
-0.02290906012058258,
-0.030372316017746925,
0.0661151111125946,
0.049409862607717514,
-0.043223269283771515,
-0.10356631129980087,
0.014789128676056862,
-0.0... | 0.124514 |
If this is omitted, the token is considered to be valid to authenticate to the Kubernetes API server. "audiences": ["https://myserver.example.com"] } } ``` {{% /tab %}} {{% tab name="authentication.k8s.io/v1beta1" %}} ```yaml { "apiVersion": "authentication.k8s.io/v1beta1", "kind": "TokenReview", "status": { "authenticated": true, "user": { # Required "username": "janedoe@example.com", # Optional "uid": "42", # Optional group memberships "groups": ["developers", "qa"], # Optional additional information provided by the authenticator. # This should not contain confidential data, as it can be recorded in logs # or API objects, and is made available to admission webhooks. "extra": { "extrafield1": [ "extravalue1", "extravalue2" ] } }, # Optional list audience-aware token authenticators can return, # containing the audiences from the `spec.audiences` list for which the provided token was valid. # If this is omitted, the token is considered to be valid to authenticate to the Kubernetes API server. "audiences": ["https://myserver.example.com"] } } ``` {{% /tab %}} {{< /tabs >}} An unsuccessful request would return: {{< tabs name="TokenReview\_response\_error" >}} {{% tab name="authentication.k8s.io/v1" %}} ```yaml { "apiVersion": "authentication.k8s.io/v1", "kind": "TokenReview", "status": { "authenticated": false, # Optionally include details about why authentication failed. # If no error is provided, the API will return a generic Unauthorized message. # The error field is ignored when authenticated=true. "error": "Credentials are expired" } } ``` {{% /tab %}} {{% tab name="authentication.k8s.io/v1beta1" %}} ```yaml { "apiVersion": "authentication.k8s.io/v1beta1", "kind": "TokenReview", "status": { "authenticated": false, # Optionally include details about why authentication failed. # If no error is provided, the API will return a generic Unauthorized message. # The error field is ignored when authenticated=true. "error": "Credentials are expired" } } ``` {{% /tab %}} {{< /tabs >}} ### Authenticating reverse proxy {#authenticating-proxy} {{< warning >}} If you have a certificate authority (CA) that is also used in a different context, \*\*do not\*\* trust that certificate authority to identify authenticating proxy clients, unless you understand the risks and the mechanisms to protect that CA's usage. {{< /warning >}} The API server can be configured to identify users from request header values, such as `X-Remote-User`. It is designed for use in combination with an \_authenticating proxy\_ that sets these headers. Using an authenticating reverse proxy is different from [user impersonation](/docs/reference/access-authn-authz/user-impersonation/). With user impersonation, one user requests the API server to treat the request as if it were being made by a different user. With an authenticating reverse proxy, the API server trusts its direct client to provide information about the identity of the principal making the original request. See [web request header configuration](#api-server-authn-config-cli-reverse-proxy) to learn about configuring this using command line arguments. #### Example {#authenticating-proxy-example} For example, with this configuration: ``` --requestheader-username-headers=X-Remote-User --requestheader-group-headers=X-Remote-Group --requestheader-extra-headers-prefix=X-Remote-Extra- ``` this request: ```http GET / HTTP/1.1 X-Remote-User: fido X-Remote-Group: dogs X-Remote-Group: dachshunds X-Remote-Extra-Acme.com%2Fproject: some-project X-Remote-Extra-Scopes: openid X-Remote-Extra-Scopes: profile ``` would result in this user info: ```yaml name: fido groups: - dogs - dachshunds extra: acme.com/project: - some-project scopes: - openid - profile ``` #### Client certificate {#reverse-proxy-client-certificate} In order to prevent header spoofing, the authenticating proxy is required to present a valid client certificate to the API server for validation against the specified CA before the request headers are checked. See the [command line option](#api-server-authn-config-cli-reverse-proxy) reference for request header authentication mode. Do \*\*not\*\* reuse a CA that is used in a different context unless you understand the risks and the mechanisms to protect the CA's usage. ### Static token file integration {#static-token-file} The API server reads static bearer tokens from a file when given the `--token-auth-file=` option on the command line. In Kubernetes {{< skew currentVersion >}}, tokens last indefinitely, and the token list cannot be changed without restarting the API server. | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
0.015197285450994968,
0.062261056154966354,
0.026501914486289024,
-0.006184727884829044,
-0.004064383450895548,
-0.013065770268440247,
0.06973044574260712,
-0.022189414128661156,
0.08237618952989578,
0.03269382193684578,
-0.01638103276491165,
-0.11262909322977066,
0.025485118851065636,
0.0... | 0.110947 |
protect the CA's usage. ### Static token file integration {#static-token-file} The API server reads static bearer tokens from a file when given the `--token-auth-file=` option on the command line. In Kubernetes {{< skew currentVersion >}}, tokens last indefinitely, and the token list cannot be changed without restarting the API server. The token file is a CSV file with a minimum of 3 columns: token, user name, user uid, followed by a comma-separated list of optional group names. {{< note >}} If you have more than one group, the column must be double quoted e.g. ```conf token,user,uid,"group1,group2,group3" ``` {{< /note >}} Using a static token file is appropriate for tokens that by their nature are long-lived, static, and perhaps may never be rotated. It is also useful when the client is local to a particular API server within the control plane, such as a monitoring agent. If you use this method during cluster provisioning, and then transition to a different authentication method that will be used longer term, you should deactivate the token that was used for bootstrapping (this requires a restart of each API server. For other circumstances, and especially where very prompt token rotation is important, the Kubernetes project recommends using a [webhook token authenticator](#webhook-token-authentication) instead of this mechanism. ## User impersonation [User impersonation](/docs/reference/access-authn-authz/user-impersonation/) provides a method that a user can act as another user through impersonation headers ## Authentication configuration {#api-server-authn-config} You can configure Kubernetes authentication either using [command line arguments](#api-server-authn-config-cli), or using a [configuration file](#api-server-authn-config-file). Typically, you use a mix of these approaches. ### Configuration via command line arguments {#api-server-authn-config-cli} You can use the following command line arguments to configure how your cluster's control plane authenticates clients. The [command line reference](/docs/reference/command-line-tools-reference/kube-apiserver/) for the API server describes all of the relevant command line arguments in more detail. #### Anonymous authentication configuration {#api-server-authn-config-cli-anonymous} `--anonymous-auth` : Controls whether clients who have not authenticated can make request via the API server's secure port. Anonymous requests have a username of `system:anonymous`, and a group name of `system:unauthenticated`. Also see [anonymous requests](#anonymous-requests). #### Bootstrap token configuration {#api-server-authn-config-cli-bootstrap} `--enable-bootstrap-token-auth` : When this flag is set, you can use [bootstrap tokens](#bootstrap-tokens) to authenticate. #### Certificate authentication configuration {#api-server-authn-config-cli-x-509} `--client-ca-file` : The path to the trust anchor(s) for validating client identity, when clients use X.509 certificate authentication. #### OIDC configuration {#api-server-authn-config-cli-oidc} `--oidc-ca-file` : The path to the trust anchor(s) for validating client identity, when clients use OIDC. `--oidc-client-id` : The client ID for the OpenID Connect client. `--oidc-username-claim` : The name of a JWT claim for specifying the username. claim to use as the user name. Default claim name is `sub`, as this should be a unique identifier of the end user. You can choose other claims, such as `email` or `name`. For claims other than `sub` or `email`, the kube-apiserver adds a prefix to the group name (to prevent naming clashes). `--oidc-username-prefix` : Prefix prepended to username claims to prevent clashes with existing names (such as `system:` users). For example, the value `oidc:` will create usernames like `oidc:jane.doe`. If this argument isn't provided and `--oidc-username-claim` is a value other than `email` the prefix defaults to `( Issuer URL )#` where `( Issuer URL )` is the value of `--oidc-issuer-url`. You can specify the prefix value as `-` to disable username prefixing. `--oidc-groups-claim` : The name of a custom OpenID Connect claim for specifying user groups. The claim in the token must be an array of strings. No default. `--oidc-groups-prefix` : Prefix prepended to group claims to prevent clashes with existing names (such as `system:` groups). For example, the value `oidc:` will create group names like | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.02591688185930252,
0.05786054581403732,
0.006900740787386894,
-0.022402185946702957,
-0.022516798228025436,
-0.011057225055992603,
0.0373261459171772,
0.0022093344014137983,
0.1232379600405693,
0.039463575929403305,
0.011949865147471428,
-0.07940541952848434,
0.019447991624474525,
0.002... | 0.154027 |
of a custom OpenID Connect claim for specifying user groups. The claim in the token must be an array of strings. No default. `--oidc-groups-prefix` : Prefix prepended to group claims to prevent clashes with existing names (such as `system:` groups). For example, the value `oidc:` will create group names like `oidc:engineering` and `oidc:infra`. The default prefix is `oidc:` `--oidc-issuer-url` : The URL of the OpenID issuer. The URL scheme \*\*must\*\* be `https`. If the issuer's OIDC discovery URL is `https://accounts.provider.example/.well-known/openid-configuration`, the value should be `https://accounts.provider.example`. `--oidc-required-claim` : A claim that must be present in a token before Kubernetes authenticates a client. Format is `key=value`. You can specify this argument more than once. `--oidc-signing-algs` : The signing algorithms accepted. Allowed values are: RS256, RS384, RS512, ES256, ES384, ES512, PS256, PS384, PS512. Values are defined by [RFC 7518](https://tools.ietf.org/html/rfc7518#section-3.1). Default is `RS512`. #### ServiceAccount configuration {#api-server-authn-config-cli-sa} `--api-audiences` : Defines the authentication audience for service account tokens. `--service-account-extend-token-expiration` : This flag turns on projected service account expiration extension during token generation, which helps safe transition from legacy tokens to bound service account token feature. See [authenticating service account credentials](/docs/concepts/security/service-accounts/#authenticating-credentials). `--service-account-issuer` : Identifier of the service account token issuer. The issuer asserts this identifier in `iss` claim of each issued token. The Kubernetes project recommends using a URL here, with the scheme set to `https`. `--service-account-jwks-uri` : Overrides the URI for the [JSON Web Key Set](https://www.rfc-editor.org/rfc/rfc7517) in the discovery document that is served at `/.well-known/openid-configuration` `--service-account-key-file` : Path to a file containing PEM-encoded X.509 public or private keys (RSA or ECDSA), used to verify ServiceAccount tokens. The specified file can contain multiple keys, and you can specify the argument multiple times with different paths. `--service-account-lookup` : If true, the API server validates that ServiceAccount tokens exist in etcd as part of authentication. `--service-account-max-token-expiration` : The maximum validity duration of a token created by the service account token issuer, as a Kubernetes duration string. `--service-account-signing-endpoint` : Path to socket where an external JWT signer is listening. You can use this to integrate with an external token signer. `--service-account-signing-key-file` : Path to the file that contains the current private key of the service account token issuer. Changes made to this file while the API server is running are \*\*not\*\* re-read. #### Static token configuration {#api-server-authn-config-cli-bearer} `--token-auth-file` : Path to the configuration file for [static bearer tokens](#static-token-file). Changes made to this file while the API server is running are \*\*not\*\* re-read. #### Webhook authentication configuration {#api-server-authn-config-cli-webhook} `--authentication-token-webhook-cache-ttl` : How long (as a Kubernetes duration specification) the API server should cache the outcome of HTTP callouts to validate tokens. `--authentication-token-webhook-config-file` : The path to a kubeconfig format client configuration, that specifies how the API server authenticates when making HTTP callouts. Changes made to this file while the API server is running are \*\*not\*\* re-read. `--authentication-token-webhook-version` : The API version of TokenReview to use when making HTTP callouts to check tokens. #### Web request authentication configuration {#api-server-authn-config-cli-reverse-proxy} {{< caution >}} You should read the documentation about configuring an [authenticating proxy](#authenticating-proxy) before you specify these command line arguments, as there is important information security advice that you must follow. {{< /caution >}} `--requestheader-client-ca-file` : \_Required.\_ Path to a PEM-encoded certificate bundle containing trust anchor(s) for validating authenticating proxy identity. A valid [client certificate](#reverse-proxy-client-certificate) must be presented and validated against the certificate authorities in the specified file before the request headers are checked for user names. `--requestheader-allowed-names` : \_Optional.\_ Comma-separated list of Common Name values (CNs). If set, a valid client certificate with a CN in the specified list must be presented before the request headers are checked for user names. If | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.06005259230732918,
0.047462113201618195,
0.006993844173848629,
0.06358122825622559,
-0.010153640992939472,
-0.030595703050494194,
0.031629759818315506,
0.00871400348842144,
0.13117417693138123,
-0.005260871257632971,
-0.011584717780351639,
-0.08261082321405411,
0.02211196906864643,
0.03... | 0.071149 |
authorities in the specified file before the request headers are checked for user names. `--requestheader-allowed-names` : \_Optional.\_ Comma-separated list of Common Name values (CNs). If set, a valid client certificate with a CN in the specified list must be presented before the request headers are checked for user names. If empty, any CN is allowed. `--requestheader-username-headers` : \_Required; case-insensitive.\_ Header names to check, in order, for the user identity. The first header containing a value is used as the username. `--requestheader-group-headers` : \_Optional; case-insensitive.\_ Header names to check, in order, for the user's groups. `X-Remote-Group` is suggested. All values in all specified headers are used as group names. `--requestheader-extra-headers-prefix` : \_Optional; case-insensitive.\_ Header prefixes to look for to determine extra information about the user. `X-Remote-Extra-` is suggested. Extra data is typically used by the configured authorization plugin(s). Any headers beginning with any of the specified prefixes have the prefix removed. The remainder of the header name is lowercased and [percent-decoded](https://tools.ietf.org/html/rfc3986#section-2.1) and becomes the extra key, and the header value is the extra value. ### Configuration via configuration file {#api-server-authn-config-file} {{< feature-state feature\_gate\_name="StructuredAuthenticationConfiguration" >}} When you specify the `--authentication-config` command line argument to the kube-apiserver, the API server loads a file at the path you specify, and uses the contents of that file to configure authentication. The contents of that file can be changed while the API server is running and, if you do that, the API server re-reads the file afterwards. {{< note >}} Modifications to this file should be done in an atomic way (for example: writing to a peer temporary file, then renaming the temporary file to replace this file). {{< /note >}} #### Configuration file path {#api-server-authn-config-cli-general} `--authentication-config` : This special command line argument specifies that you want to [configure authentication using a configuration file](#api-server-authn-config-file). #### Example {#api-server-authn-config-file-example} Here is an example of a Kubernetes (structured) authentication configuration file: {{< highlight yaml "linenos=false,hl\_lines=2-5" >}} --- # # CAUTION: this is an example configuration. # Check and amend this before you use it in your own cluster! # apiVersion: apiserver.config.k8s.io/v1 kind: AuthenticationConfiguration anonymous: enabled: false {{< /highlight >}} ## client-go credential plugins {{< feature-state for\_k8s\_version="v1.22" state="stable" >}} `k8s.io/client-go` and tools using it such as `kubectl` and `kubelet` are able to execute an external command to receive user credentials. This feature is intended for client side integrations with authentication protocols not natively supported by `k8s.io/client-go` (LDAP, Kerberos, OAuth2, SAML, etc.). The plugin implements the protocol specific logic, then returns opaque credentials to use. Almost all credential plugin use cases require a server side component with support for the [webhook token authenticator](#webhook-token-authentication) to interpret the credential format produced by the client plugin. {{< note >}} Earlier versions of `kubectl` included built-in support for authenticating to AKS and GKE, but this is no longer present. {{< /note >}} ### Example use case In a hypothetical use case, an organization would run an external service that exchanges LDAP credentials for user specific, signed tokens. The service would also be capable of responding to [webhook token authenticator](#webhook-token-authentication) requests to validate the tokens. Users would be required to install a credential plugin on their workstation. To authenticate against the API: \* The user issues a `kubectl` command. \* Credential plugin prompts the user for LDAP credentials, exchanges credentials with external service for a token. \* Credential plugin returns token to client-go, which uses it as a bearer token against the API server. \* API server uses the [webhook token authenticator](#webhook-token-authentication) to submit a `TokenReview` to the external service. \* External service verifies the signature on the token and returns the user's username and groups. | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.05196620523929596,
0.10485783964395523,
-0.022385096177458763,
-0.060114406049251556,
0.007701375056058168,
-0.050237130373716354,
0.06551429629325867,
0.015539145097136497,
-0.02075083926320076,
-0.02067411318421364,
0.03883921727538109,
-0.1260765790939331,
0.07748136669397354,
0.0368... | -0.030663 |
\* Credential plugin returns token to client-go, which uses it as a bearer token against the API server. \* API server uses the [webhook token authenticator](#webhook-token-authentication) to submit a `TokenReview` to the external service. \* External service verifies the signature on the token and returns the user's username and groups. ### Configuration Credential plugins are configured through [kubectl config files](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) as part of the user fields. {{< tabs name="exec\_plugin\_kubeconfig\_example\_1" >}} {{% tab name="client.authentication.k8s.io/v1" %}} ```yaml apiVersion: v1 kind: Config users: - name: my-user user: exec: # Command to execute. Required. command: "example-client-go-exec-plugin" # API version to use when decoding the ExecCredentials resource. Required. # # The API version returned by the plugin MUST match the version listed here. # # To integrate with tools that support multiple versions (such as client.authentication.k8s.io/v1beta1), # set an environment variable, pass an argument to the tool that indicates which version the exec plugin expects, # or read the version from the ExecCredential object in the KUBERNETES\_EXEC\_INFO environment variable. apiVersion: "client.authentication.k8s.io/v1" # Environment variables to set when executing the plugin. Optional. env: - name: "FOO" value: "bar" # Arguments to pass when executing the plugin. Optional. args: - "arg1" - "arg2" # Text shown to the user when the executable doesn't seem to be present. Optional. installHint: | example-client-go-exec-plugin is required to authenticate to the current cluster. It can be installed: On macOS: brew install example-client-go-exec-plugin On Ubuntu: apt-get install example-client-go-exec-plugin On Fedora: dnf install example-client-go-exec-plugin ... # Whether or not to provide cluster information, which could potentially contain # very large CA data, to this exec plugin as a part of the KUBERNETES\_EXEC\_INFO # environment variable. provideClusterInfo: true # The contract between the exec plugin and the standard input I/O stream. If the # contract cannot be satisfied, this plugin will not be run and an error will be # returned. Valid values are "Never" (this exec plugin never uses standard input), # "IfAvailable" (this exec plugin wants to use standard input if it is available), # or "Always" (this exec plugin requires standard input to function). Required. interactiveMode: Never clusters: - name: my-cluster cluster: server: "https://172.17.4.100:6443" certificate-authority: "/etc/kubernetes/ca.pem" extensions: - name: client.authentication.k8s.io/exec # reserved extension name for per cluster exec config extension: arbitrary: config this: can be provided via the KUBERNETES\_EXEC\_INFO environment variable upon setting provideClusterInfo you: ["can", "put", "anything", "here"] contexts: - name: my-cluster context: cluster: my-cluster user: my-user current-context: my-cluster ``` {{% /tab %}} {{% tab name="client.authentication.k8s.io/v1beta1" %}} ```yaml apiVersion: v1 kind: Config users: - name: my-user user: exec: # Command to execute. Required. command: "example-client-go-exec-plugin" # API version to use when decoding the ExecCredentials resource. Required. # # The API version returned by the plugin MUST match the version listed here. # # To integrate with tools that support multiple versions (such as client.authentication.k8s.io/v1), # set an environment variable, pass an argument to the tool that indicates which version the exec plugin expects, # or read the version from the ExecCredential object in the KUBERNETES\_EXEC\_INFO environment variable. apiVersion: "client.authentication.k8s.io/v1beta1" # Environment variables to set when executing the plugin. Optional. env: - name: "FOO" value: "bar" # Arguments to pass when executing the plugin. Optional. args: - "arg1" - "arg2" # Text shown to the user when the executable doesn't seem to be present. Optional. installHint: | example-client-go-exec-plugin is required to authenticate to the current cluster. It can be installed: On macOS: brew install example-client-go-exec-plugin On Ubuntu: apt-get install example-client-go-exec-plugin On Fedora: dnf install example-client-go-exec-plugin ... # Whether or not to provide cluster information, which could potentially contain # very large CA data, to this exec plugin as a part of | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.062390346080064774,
0.01856115646660328,
-0.04300985112786293,
-0.033786673098802567,
-0.05956680327653885,
-0.028119876980781555,
0.022559968754649162,
0.02726111374795437,
0.07142552733421326,
0.03929600864648819,
-0.03612706437706947,
-0.13103745877742767,
0.02557375095784664,
-0.004... | 0.151648 |
authenticate to the current cluster. It can be installed: On macOS: brew install example-client-go-exec-plugin On Ubuntu: apt-get install example-client-go-exec-plugin On Fedora: dnf install example-client-go-exec-plugin ... # Whether or not to provide cluster information, which could potentially contain # very large CA data, to this exec plugin as a part of the KUBERNETES\_EXEC\_INFO # environment variable. provideClusterInfo: true # The contract between the exec plugin and the standard input I/O stream. If the # contract cannot be satisfied, this plugin will not be run and an error will be # returned. Valid values are "Never" (this exec plugin never uses standard input), # "IfAvailable" (this exec plugin wants to use standard input if it is available), # or "Always" (this exec plugin requires standard input to function). Optional. # Defaults to "IfAvailable". interactiveMode: Never clusters: - name: my-cluster cluster: server: "https://172.17.4.100:6443" certificate-authority: "/etc/kubernetes/ca.pem" extensions: - name: client.authentication.k8s.io/exec # reserved extension name for per cluster exec config extension: arbitrary: config this: can be provided via the KUBERNETES\_EXEC\_INFO environment variable upon setting provideClusterInfo you: ["can", "put", "anything", "here"] contexts: - name: my-cluster context: cluster: my-cluster user: my-user current-context: my-cluster ``` {{% /tab %}} {{< /tabs >}} Relative command paths are interpreted as relative to the directory of the config file. If KUBECONFIG is set to `/home/jane/kubeconfig` and the exec command is `./bin/example-client-go-exec-plugin`, the binary `/home/jane/bin/example-client-go-exec-plugin` is executed. ```yaml - name: my-user user: exec: # Path relative to the directory of the kubeconfig command: "./bin/example-client-go-exec-plugin" apiVersion: "client.authentication.k8s.io/v1" interactiveMode: Never ``` ### Input and output formats The executed command prints an `ExecCredential` object to `stdout`. `k8s.io/client-go` authenticates against the Kubernetes API using the returned credentials in the `status`. The executed command is passed an `ExecCredential` object as input via the `KUBERNETES\_EXEC\_INFO` environment variable. This input contains helpful information like the expected API version of the returned `ExecCredential` object and whether or not the plugin can use `stdin` to interact with the user. When run from an interactive session (i.e., a terminal), `stdin` can be exposed directly to the plugin. Plugins should use the `spec.interactive` field of the input `ExecCredential` object from the `KUBERNETES\_EXEC\_INFO` environment variable in order to determine if `stdin` has been provided. A plugin's `stdin` requirements (i.e., whether `stdin` is optional, strictly required, or never used in order for the plugin to run successfully) is declared via the `user.exec.interactiveMode` field in the [kubeconfig](/docs/concepts/configuration/organize-cluster-access-kubeconfig/) (see table below for valid values). The `user.exec.interactiveMode` field is optional in `client.authentication.k8s.io/v1beta1` and required in `client.authentication.k8s.io/v1`. {{< table caption="interactiveMode values" >}} | `interactiveMode` Value | Meaning | | ----------------------- | ------- | | `Never` | This exec plugin never needs to use standard input, and therefore the exec plugin will be run regardless of whether standard input is available for user input. | | `IfAvailable` | This exec plugin would like to use standard input if it is available, but can still operate if standard input is not available. Therefore, the exec plugin will be run regardless of whether stdin is available for user input. If standard input is available for user input, then it will be provided to this exec plugin. | | `Always` | This exec plugin requires standard input in order to run, and therefore the exec plugin will only be run if standard input is available for user input. If standard input is not available for user input, then the exec plugin will not be run and an error will be returned by the exec plugin runner. | {{< /table >}} To use bearer token credentials, the plugin returns a token in the status of the [`ExecCredential`](/docs/reference/config-api/client-authentication.v1beta1/#client-authentication-k8s-io-v1beta1-ExecCredential) {{< tabs name="exec\_plugin\_ExecCredential\_example\_1" >}} {{% tab name="client.authentication.k8s.io/v1" %}} | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
0.015776140615344048,
-0.01795000582933426,
-0.03174246847629547,
-0.03358736261725426,
-0.016947854310274124,
0.0278423260897398,
0.0069602360017597675,
0.017909491434693336,
0.08301375061273575,
0.0199761763215065,
0.007523505017161369,
-0.07585222274065018,
-0.05935299023985863,
0.05873... | 0.17263 |
for user input, then the exec plugin will not be run and an error will be returned by the exec plugin runner. | {{< /table >}} To use bearer token credentials, the plugin returns a token in the status of the [`ExecCredential`](/docs/reference/config-api/client-authentication.v1beta1/#client-authentication-k8s-io-v1beta1-ExecCredential) {{< tabs name="exec\_plugin\_ExecCredential\_example\_1" >}} {{% tab name="client.authentication.k8s.io/v1" %}} ```json { "apiVersion": "client.authentication.k8s.io/v1", "kind": "ExecCredential", "status": { "token": "my-bearer-token" } } ``` {{% /tab %}} {{% tab name="client.authentication.k8s.io/v1beta1" %}} ```json { "apiVersion": "client.authentication.k8s.io/v1beta1", "kind": "ExecCredential", "status": { "token": "my-bearer-token" } } ``` {{% /tab %}} {{< /tabs >}} Alternatively, a PEM-encoded client certificate and key can be returned to use TLS client auth. If the plugin returns a different certificate and key on a subsequent call, `k8s.io/client-go` will close existing connections with the server to force a new TLS handshake. If specified, `clientKeyData` and `clientCertificateData` must both must be present. `clientCertificateData` may contain additional intermediate certificates to send to the server. {{< tabs name="exec\_plugin\_ExecCredential\_example\_2" >}} {{% tab name="client.authentication.k8s.io/v1" %}} ```json { "apiVersion": "client.authentication.k8s.io/v1", "kind": "ExecCredential", "status": { "clientCertificateData": "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----", "clientKeyData": "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----" } } ``` {{% /tab %}} {{% tab name="client.authentication.k8s.io/v1beta1" %}} ```json { "apiVersion": "client.authentication.k8s.io/v1beta1", "kind": "ExecCredential", "status": { "clientCertificateData": "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----", "clientKeyData": "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----" } } ``` {{% /tab %}} {{< /tabs >}} Optionally, the response can include the expiry of the credential formatted as a [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339) timestamp. Presence or absence of an expiry has the following impact: - If an expiry is included, the bearer token and TLS credentials are cached until the expiry time is reached, or if the server responds with a 401 HTTP status code, or when the process exits. - If an expiry is omitted, the bearer token and TLS credentials are cached until the server responds with a 401 HTTP status code or until the process exits. {{< tabs name="exec\_plugin\_ExecCredential\_example\_3" >}} {{% tab name="client.authentication.k8s.io/v1" %}} ```json { "apiVersion": "client.authentication.k8s.io/v1", "kind": "ExecCredential", "status": { "token": "my-bearer-token", "expirationTimestamp": "2018-03-05T17:30:20-08:00" } } ``` {{% /tab %}} {{% tab name="client.authentication.k8s.io/v1beta1" %}} ```json { "apiVersion": "client.authentication.k8s.io/v1beta1", "kind": "ExecCredential", "status": { "token": "my-bearer-token", "expirationTimestamp": "2018-03-05T17:30:20-08:00" } } ``` {{% /tab %}} {{< /tabs >}} To enable the exec plugin to obtain cluster-specific information, set `provideClusterInfo` on the `user.exec` field in the [kubeconfig](/docs/concepts/configuration/organize-cluster-access-kubeconfig/). The plugin will then be supplied this cluster-specific information in the `KUBERNETES\_EXEC\_INFO` environment variable. Information from this environment variable can be used to perform cluster-specific credential acquisition logic. The following `ExecCredential` manifest describes a cluster information sample. {{< tabs name="exec\_plugin\_ExecCredential\_example\_4" >}} {{% tab name="client.authentication.k8s.io/v1" %}} ```json { "apiVersion": "client.authentication.k8s.io/v1", "kind": "ExecCredential", "spec": { "cluster": { "server": "https://172.17.4.100:6443", "certificate-authority-data": "LS0t...", "config": { "arbitrary": "config", "this": "can be provided via the KUBERNETES\_EXEC\_INFO environment variable upon setting provideClusterInfo", "you": ["can", "put", "anything", "here"] } }, "interactive": true } } ``` {{% /tab %}} {{% tab name="client.authentication.k8s.io/v1beta1" %}} ```json { "apiVersion": "client.authentication.k8s.io/v1beta1", "kind": "ExecCredential", "spec": { "cluster": { "server": "https://172.17.4.100:6443", "certificate-authority-data": "LS0t...", "config": { "arbitrary": "config", "this": "can be provided via the KUBERNETES\_EXEC\_INFO environment variable upon setting provideClusterInfo", "you": ["can", "put", "anything", "here"] } }, "interactive": true } } ``` {{% /tab %}} {{< /tabs >}} ## API access to authentication information for a client {#self-subject-review} {{< feature-state for\_k8s\_version="v1.28" state="stable" >}} If your cluster has the API enabled, you can use the SelfSubjectReview API to find out how your Kubernetes cluster maps your authentication information to identify you as a client. This works whether you are authenticating as a user (typically representing a real person) or as a ServiceAccount. SelfSubjectReview objects do not have any configurable fields. On receiving a request, the Kubernetes API server | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.061607662588357925,
0.048342179507017136,
-0.06185365840792656,
0.003735874779522419,
-0.05984910577535629,
0.004768996499478817,
0.016059698536992073,
0.10579483211040497,
-0.0039579011499881744,
0.04470670223236084,
0.007844844833016396,
-0.09394659101963043,
0.04179302603006363,
0.11... | 0.080032 |
find out how your Kubernetes cluster maps your authentication information to identify you as a client. This works whether you are authenticating as a user (typically representing a real person) or as a ServiceAccount. SelfSubjectReview objects do not have any configurable fields. On receiving a request, the Kubernetes API server fills the status with the user attributes and returns it to the user. Request example (the body would be a SelfSubjectReview): ```http POST /apis/authentication.k8s.io/v1/selfsubjectreviews ``` ```json { "apiVersion": "authentication.k8s.io/v1", "kind": "SelfSubjectReview" } ``` Response example: ```json { "apiVersion": "authentication.k8s.io/v1", "kind": "SelfSubjectReview", "status": { "userInfo": { "name": "jane.doe", "uid": "b6c7cfd4-f166-11ec-8ea0-0242ac120002", "groups": [ "viewers", "editors", "system:authenticated" ], "extra": { "provider\_id": ["token.company.example"] } } } } ``` For convenience, the `kubectl auth whoami` command is present. Executing this command will produce the following output (yet different user attributes will be shown): \* Simple output example ``` ATTRIBUTE VALUE Username jane.doe Groups [system:authenticated] ``` \* Complex example including extra attributes ``` ATTRIBUTE VALUE Username jane.doe UID b79dbf30-0c6a-11ed-861d-0242ac120002 Groups [students teachers system:authenticated] Extra: skills [reading learning] Extra: subjects [math sports] ``` By providing the output flag, it is also possible to print the JSON or YAML representation of the result: {{< tabs name="self\_subject\_attributes\_review\_Example\_1" >}} {{% tab name="JSON" %}} ```json { "apiVersion": "authentication.k8s.io/v1", "kind": "SelfSubjectReview", "status": { "userInfo": { "username": "jane.doe", "uid": "b79dbf30-0c6a-11ed-861d-0242ac120002", "groups": [ "students", "teachers", "system:authenticated" ], "extra": { "skills": [ "reading", "learning" ], "subjects": [ "math", "sports" ] } } } } ``` {{% /tab %}} {{% tab name="YAML" %}} ```yaml apiVersion: authentication.k8s.io/v1 kind: SelfSubjectReview status: userInfo: username: jane.doe uid: b79dbf30-0c6a-11ed-861d-0242ac120002 groups: - students - teachers - system:authenticated extra: skills: - reading - learning subjects: - math - sports ``` {{% /tab %}} {{< /tabs >}} This feature is extremely useful when a complicated authentication flow is used in a Kubernetes cluster, for example, if you use [webhook token authentication](/docs/reference/access-authn-authz/authentication/#webhook-token-authentication) or [authenticating proxy](/docs/reference/access-authn-authz/authentication/#authenticating-proxy). {{< note >}} The Kubernetes API server fills the `userInfo` after all authentication mechanisms are applied, including [impersonation](/docs/reference/access-authn-authz/authentication/#user-impersonation). If you, or an authentication proxy, make a SelfSubjectReview using impersonation, you see the user details and properties for the user that was impersonated. {{< /note >}} By default, all authenticated users can create `SelfSubjectReview` objects when the `APISelfSubjectReview` feature is enabled. It is allowed by the `system:basic-user` cluster role. {{< note >}} You can only make `SelfSubjectReview` requests if: \* the `APISelfSubjectReview` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled for your cluster (not needed for Kubernetes {{< skew currentVersion >}}, but older Kubernetes versions might not offer this feature gate, or might default it to be off) \* (if you are running a version of Kubernetes older than v1.28) the API server for your cluster has the `authentication.k8s.io/v1alpha1` or `authentication.k8s.io/v1beta1` {{< glossary\_tooltip term\_id="api-group" text="API group" >}} enabled. {{< /note >}} ## {{% heading "whatsnext" %}} \* To learn about issuing certificates for users, read [Issue a Certificate for a Kubernetes API Client Using A CertificateSigningRequest](/docs/tasks/tls/certificate-issue-client-csr/) \* Read the [client authentication reference (v1)](/docs/reference/config-api/client-authentication.v1/) \* Read the [client authentication reference (v1beta1)](/docs/reference/config-api/client-authentication.v1beta1/) | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authentication.md | main | kubernetes | [
-0.028859183192253113,
0.030183015391230583,
0.03486213833093643,
-0.005337187089025974,
-0.09335709363222122,
-0.008835883811116219,
-0.005355750676244497,
-0.018201332539319992,
0.09126802533864975,
0.049007926136255264,
-0.06919751316308975,
-0.09177419543266296,
0.0023493480402976274,
... | 0.111614 |
Attribute-based access control (ABAC) defines an access control paradigm whereby access rights are granted to users through the use of policies which combine attributes together. ## Policy File Format To enable `ABAC` mode, specify `--authorization-policy-file=SOME\_FILENAME` and `--authorization-mode=ABAC` on startup. The file format is [one JSON object per line](https://jsonlines.org/). There should be no enclosing list or map, only one map per line. Each line is a "policy object", where each such object is a map with the following properties: - Versioning properties: - `apiVersion`, type string; valid values are "abac.authorization.kubernetes.io/v1beta1". Allows versioning and conversion of the policy format. - `kind`, type string: valid values are "Policy". Allows versioning and conversion of the policy format. - `spec` property set to a map with the following properties: - Subject-matching properties: - `user`, type string; the user-string from `--token-auth-file`. If you specify `user`, it must match the username of the authenticated user. - `group`, type string; if you specify `group`, it must match one of the groups of the authenticated user. `system:authenticated` matches all authenticated requests. `system:unauthenticated` matches all unauthenticated requests. - Resource-matching properties: - `apiGroup`, type string; an API group. - Ex: `apps`, `networking.k8s.io` - Wildcard: `\*` matches all API groups. - `namespace`, type string; a namespace. - Ex: `kube-system` - Wildcard: `\*` matches all resource requests. - `resource`, type string; a resource type - Ex: `pods`, `deployments` - Wildcard: `\*` matches all resource requests. - Non-resource-matching properties: - `nonResourcePath`, type string; non-resource request paths. - Ex: `/version` or `/apis` - Wildcard: - `\*` matches all non-resource requests. - `/foo/\*` matches all subpaths of `/foo/`. - `readonly`, type boolean, when true, means that the Resource-matching policy only applies to get, list, and watch operations, Non-resource-matching policy only applies to get operation. {{< note >}} An unset property is the same as a property set to the zero value for its type (e.g. empty string, 0, false). However, unset should be preferred for readability. In the future, policies may be expressed in a JSON format, and managed via a REST interface. {{< /note >}} ## Authorization Algorithm A request has attributes which correspond to the properties of a policy object. When a request is received, the attributes are determined. Unknown attributes are set to the zero value of its type (e.g. empty string, 0, false). A property set to `"\*"` will match any value of the corresponding attribute. The tuple of attributes is checked for a match against every policy in the policy file. If at least one line matches the request attributes, then the request is authorized (but may fail later validation). To permit any authenticated user to do something, write a policy with the group property set to `"system:authenticated"`. To permit any unauthenticated user to do something, write a policy with the group property set to `"system:unauthenticated"`. To permit a user to do anything, write a policy with the apiGroup, namespace, resource, and nonResourcePath properties set to `"\*"`. ## Kubectl Kubectl uses the `/api` and `/apis` endpoints of apiserver to discover served resource types, and validates objects sent to the API by create/update operations using schema information located at `/openapi/v2`. When using ABAC authorization, those special resources have to be explicitly exposed via the `nonResourcePath` property in a policy (see [examples](#examples) below): \* `/api`, `/api/\*`, `/apis`, and `/apis/\*` for API version negotiation. \* `/version` for retrieving the server version via `kubectl version`. \* `/swaggerapi/\*` for create/update operations. To inspect the HTTP calls involved in a specific kubectl operation you can turn up the verbosity: ```shell kubectl --v=8 version ``` ## Examples 1. Alice can do anything to all resources: ```json {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/abac.md | main | kubernetes | [
0.0026127707678824663,
0.08859413117170334,
-0.04030587151646614,
-0.006267217453569174,
-0.04961683601140976,
0.007000402547419071,
0.01877068541944027,
-0.023633522912859917,
0.0009721743990667164,
0.05783660709857941,
0.04896153137087822,
-0.06144671514630318,
-0.03304080665111542,
-0.0... | 0.115242 |
\* `/version` for retrieving the server version via `kubectl version`. \* `/swaggerapi/\*` for create/update operations. To inspect the HTTP calls involved in a specific kubectl operation you can turn up the verbosity: ```shell kubectl --v=8 version ``` ## Examples 1. Alice can do anything to all resources: ```json {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user": "alice", "namespace": "\*", "resource": "\*", "apiGroup": "\*"}} ``` 1. The kubelet can read any pods: ```json {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user": "kubelet", "namespace": "\*", "resource": "pods", "readonly": true}} ``` 1. The kubelet can read and write events: ```json {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user": "kubelet", "namespace": "\*", "resource": "events"}} ``` 1. Bob can just read pods in namespace "projectCaribou": ```json {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user": "bob", "namespace": "projectCaribou", "resource": "pods", "readonly": true}} ``` 1. Anyone can make read-only requests to all non-resource paths: ```json {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"group": "system:authenticated", "readonly": true, "nonResourcePath": "\*"}} {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"group": "system:unauthenticated", "readonly": true, "nonResourcePath": "\*"}} ``` [Complete file example](https://releases.k8s.io/v{{< skew currentPatchVersion >}}/pkg/auth/authorizer/abac/example\_policy\_file.jsonl) ## A quick note on service accounts Every service account has a corresponding ABAC username, and that service account's username is generated according to the naming convention: ```shell system:serviceaccount:: ``` Creating a new namespace leads to the creation of a new service account in the following format: ```shell system:serviceaccount::default ``` For example, if you wanted to grant the default service account (in the `kube-system` namespace) full privilege to the API using ABAC, you would add this line to your policy file: ```json {"apiVersion":"abac.authorization.kubernetes.io/v1beta1","kind":"Policy","spec":{"user":"system:serviceaccount:kube-system:default","namespace":"\*","resource":"\*","apiGroup":"\*"}} ``` The apiserver will need to be restarted to pick up the new policy lines. | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/abac.md | main | kubernetes | [
0.02749325893819332,
0.06055184453725815,
0.01996549405157566,
-0.008207692764699459,
-0.03776878863573074,
-0.05538003146648407,
-0.06900549679994583,
-0.0809783786535263,
0.09526664763689041,
0.017812075093388557,
-0.00004994998380425386,
-0.09222099184989929,
-0.038932111114263535,
-0.0... | 0.08536 |
{{< feature-state for\_k8s\_version="v1.18" state="stable" >}} Bootstrap tokens are a simple bearer token that is meant to be used when creating new clusters or joining new nodes to an existing cluster. It was built to support [kubeadm](/docs/reference/setup-tools/kubeadm/), but can be used in other contexts for users that wish to start clusters without `kubeadm`. It is also built to work, via RBAC policy, with the [kubelet TLS Bootstrapping](/docs/reference/access-authn-authz/kubelet-tls-bootstrapping/) system. ## Bootstrap Tokens Overview Bootstrap Tokens are defined with a specific type (`bootstrap.kubernetes.io/token`) of secrets that lives in the `kube-system` namespace. These Secrets are then read by the Bootstrap Authenticator in the API Server. Expired tokens are removed with the TokenCleaner controller in the Controller Manager. The tokens are also used to create a signature for a specific ConfigMap used in a "discovery" process through a BootstrapSigner controller. ## Token Format Bootstrap Tokens take the form of `abcdef.0123456789abcdef`. More formally, they must match the regular expression `[a-z0-9]{6}\.[a-z0-9]{16}`. The first part of the token is the "Token ID" and is considered public information. It is used when referring to a token without leaking the secret part used for authentication. The second part is the "Token Secret" and should only be shared with trusted parties. ## Enabling Bootstrap Token Authentication The Bootstrap Token authenticator can be enabled using the following flag on the API server: ``` --enable-bootstrap-token-auth ``` When enabled, bootstrapping tokens can be used as bearer token credentials to authenticate requests against the API server. ```http Authorization: Bearer 07401b.f395accd246ae52d ``` Tokens authenticate as the username `system:bootstrap:` and are members of the group `system:bootstrappers`. Additional groups may be specified in the token's Secret. Expired tokens can be deleted automatically by enabling the `tokencleaner` controller on the controller manager. ``` --controllers=\*,tokencleaner ``` ## Bootstrap Token Secret Format Each valid token is backed by a secret in the `kube-system` namespace. You can find the full design doc [here](https://git.k8s.io/design-proposals-archive/cluster-lifecycle/bootstrap-discovery.md). Here is what the secret looks like. ```yaml apiVersion: v1 kind: Secret metadata: # Name MUST be of form "bootstrap-token-" name: bootstrap-token-07401b namespace: kube-system # Type MUST be 'bootstrap.kubernetes.io/token' type: bootstrap.kubernetes.io/token stringData: # Human readable description. Optional. description: "The default bootstrap token generated by 'kubeadm init'." # Token ID and secret. Required. token-id: 07401b token-secret: f395accd246ae52d # Expiration. Optional. expiration: 2017-03-10T03:22:11Z # Allowed usages. usage-bootstrap-authentication: "true" usage-bootstrap-signing: "true" # Extra groups to authenticate the token as. Must start with "system:bootstrappers:" auth-extra-groups: system:bootstrappers:worker,system:bootstrappers:ingress ``` The type of the secret must be `bootstrap.kubernetes.io/token` and the name must be `bootstrap-token-`. It must also exist in the `kube-system` namespace. The `usage-bootstrap-\*` members indicate what this secret is intended to be used for. A value must be set to `true` to be enabled. \* `usage-bootstrap-authentication` indicates that the token can be used to authenticate to the API server as a bearer token. \* `usage-bootstrap-signing` indicates that the token may be used to sign the `cluster-info` ConfigMap as described below. The `expiration` field controls the expiry of the token. Expired tokens are rejected when used for authentication and ignored during ConfigMap signing. The expiry value is encoded as an absolute UTC time using [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339). Enable the `tokencleaner` controller to automatically delete expired tokens. ## Token Management with kubeadm You can use the `kubeadm` tool to manage tokens on a running cluster. See the [kubeadm token docs](/docs/reference/setup-tools/kubeadm/kubeadm-token/) for details. ## ConfigMap Signing In addition to authentication, the tokens can be used to sign a ConfigMap. This is used early in a cluster bootstrap process before the client trusts the API server. The signed ConfigMap can be authenticated by the shared token. Enable ConfigMap signing by enabling the `bootstrapsigner` controller on the Controller Manager. ``` --controllers=\*,bootstrapsigner ``` | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/bootstrap-tokens.md | main | kubernetes | [
-0.07945802807807922,
0.020975550636649132,
-0.02353239618241787,
0.0240319911390543,
0.0015615317970514297,
0.006550327409058809,
-0.009934679605066776,
-0.014528332278132439,
0.07449142634868622,
0.000008985373824543785,
0.017785746604204178,
-0.02386091649532318,
0.06367163360118866,
-0... | 0.19385 |
the tokens can be used to sign a ConfigMap. This is used early in a cluster bootstrap process before the client trusts the API server. The signed ConfigMap can be authenticated by the shared token. Enable ConfigMap signing by enabling the `bootstrapsigner` controller on the Controller Manager. ``` --controllers=\*,bootstrapsigner ``` The ConfigMap that is signed is `cluster-info` in the `kube-public` namespace. The typical flow is that a client reads this ConfigMap while unauthenticated and ignoring TLS errors. It then validates the payload of the ConfigMap by looking at a signature embedded in the ConfigMap. The ConfigMap may look like this: ```yaml apiVersion: v1 kind: ConfigMap metadata: name: cluster-info namespace: kube-public data: jws-kubeconfig-07401b: eyJhbGciOiJIUzI1NiIsImtpZCI6IjA3NDAxYiJ9..tYEfbo6zDNo40MQE07aZcQX2m3EB2rO3NuXtxVMYm9U kubeconfig: | apiVersion: v1 clusters: - cluster: certificate-authority-data: server: https://10.138.0.2:6443 name: "" contexts: [] current-context: "" kind: Config preferences: {} users: [] ``` The `kubeconfig` member of the ConfigMap is a config file with only the cluster information filled out. The key thing being communicated here is the `certificate-authority-data`. This may be expanded in the future. The signature is a JWS signature using the "detached" mode. To validate the signature, the user should encode the `kubeconfig` payload according to JWS rules (base64 encoded while discarding any trailing `=`). That encoded payload is then used to form a whole JWS by inserting it between the 2 dots. You can verify the JWS using the `HS256` scheme (HMAC-SHA256) with the full token (e.g. `07401b.f395accd246ae52d`) as the shared secret. Users \_must\_ verify that HS256 is used. {{< warning >}} Any party with a bootstrapping token can create a valid signature for that token. When using ConfigMap signing it's discouraged to share the same token with many clients, since a compromised client can potentially man-in-the middle another client relying on the signature to bootstrap TLS trust. {{< /warning >}} Consult the [kubeadm implementation details](/docs/reference/setup-tools/kubeadm/implementation-details/) section for more information. | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/bootstrap-tokens.md | main | kubernetes | [
-0.09639039635658264,
0.009020478464663029,
-0.018302464857697487,
0.0167582668364048,
0.061779096722602844,
-0.04954692721366882,
-0.005099248606711626,
-0.02272697351872921,
0.074175164103508,
0.004036190919578075,
0.0042043118737638,
-0.05649535730481148,
0.07329708337783813,
-0.0209646... | 0.187655 |
User \_impersonation\_ is a method of allowing authenticated users to act as another user, group, or service account through HTTP headers. A user can act as another user through impersonation headers. These let requests manually override the user info a request authenticates as. For example, an admin could use this feature to debug an authorization policy by temporarily impersonating another user and seeing if a request was denied. Impersonation requests first authenticate as the requesting user, then switch to the impersonated user info. \* A user makes an API call with their credentials \_and\_ impersonation headers. \* API server authenticates the user. \* API server ensures the authenticated users have impersonation privileges. \* Request user info is replaced with impersonation values. \* Request is evaluated, authorization acts on impersonated user info. The following HTTP headers can be used to performing an impersonation request: \* `Impersonate-User`: The username to act as. \* `Impersonate-Uid`: A unique identifier that represents the user being impersonated. Optional. Requires "Impersonate-User". Kubernetes does not impose any format requirements on this string. \* `Impersonate-Group`: A group name to act as. Can be provided multiple times to set multiple groups. Optional. Requires "Impersonate-User". \* `Impersonate-Extra-( extra name )`: A dynamic header used to associate extra fields with the user. Optional. Requires "Impersonate-User". In order to be preserved consistently, `( extra name )` must be lower-case, and any characters which aren't [legal in HTTP header labels](https://tools.ietf.org/html/rfc7230#section-3.2.6) MUST be utf8 and [percent-encoded](https://tools.ietf.org/html/rfc3986#section-2.1). {{< note >}} Prior to 1.11.3 (and 1.10.7, 1.9.11), `( extra name )` could only contain characters which were [legal in HTTP header labels](https://tools.ietf.org/html/rfc7230#section-3.2.6). {{< /note >}} {{< note >}} `Impersonate-Uid` is only available in versions 1.22.0 and higher. {{< /note >}} An example of the impersonation headers used when impersonating a user with groups: ```http Impersonate-User: jane.doe@example.com Impersonate-Group: developers Impersonate-Group: admins ``` An example of the impersonation headers used when impersonating a user with a UID and extra fields: ```http Impersonate-User: jane.doe@example.com Impersonate-Uid: 06f6ce97-e2c5-4ab8-7ba5-7654dd08d52b Impersonate-Extra-dn: cn=jane,ou=engineers,dc=example,dc=com Impersonate-Extra-acme.com%2Fproject: some-project Impersonate-Extra-scopes: view Impersonate-Extra-scopes: development ``` When using `kubectl` set the `--as` command line argument to configure the `Impersonate-User` header, you can also set the `--as-group` flag to configure the `Impersonate-Group` header, set the `--as-uid` flag (1.23) to configure `Impersonate-Uid` header, and set the `--as-user-extra` flag (1.35) to configure `Impersonate-Extra-( extra name )` header. ```bash kubectl drain mynode ``` ```none Error from server (Forbidden): User "clark" cannot get nodes at the cluster scope. (get nodes mynode) ``` Set the `--as` and `--as-group` flag: ```bash kubectl drain mynode --as=superman --as-group=system:masters ``` ```none node/mynode cordoned node/mynode drained ``` To impersonate a user, user identifier (UID), group or extra fields, the impersonating user must have the ability to perform the \*\*impersonate\*\* verb on the kind of attribute being impersonated ("user", "uid", "group", etc.). For clusters that enable the RBAC authorization plugin, the following ClusterRole encompasses the rules needed to set user and group impersonation headers: ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: impersonator rules: - apiGroups: [""] resources: ["users", "groups", "serviceaccounts"] verbs: ["impersonate"] ``` For impersonation, extra fields and impersonated UIDs are both under the "authentication.k8s.io" `apiGroup`. Extra fields are evaluated as sub-resources of the resource "userextras". To allow a user to use impersonation headers for the extra field `scopes` and for UIDs, a user should be granted the following role: ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: scopes-and-uid-impersonator rules: # Can set "Impersonate-Extra-scopes" header and the "Impersonate-Uid" header. - apiGroups: ["authentication.k8s.io"] resources: ["userextras/scopes", "uids"] verbs: ["impersonate"] ``` The values of impersonation headers can also be restricted by limiting the set of `resourceNames` a resource can take. ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/user-impersonation.md | main | kubernetes | [
-0.16736340522766113,
0.05496611073613167,
0.010416279546916485,
-0.05245274305343628,
-0.017686033621430397,
-0.11508192867040634,
0.08948090672492981,
0.018759367987513542,
0.028377536684274673,
-0.009465191513299942,
-0.0008391058654524386,
-0.03204990178346634,
0.05280213803052902,
-0.... | 0.183735 |
kind: ClusterRole metadata: name: scopes-and-uid-impersonator rules: # Can set "Impersonate-Extra-scopes" header and the "Impersonate-Uid" header. - apiGroups: ["authentication.k8s.io"] resources: ["userextras/scopes", "uids"] verbs: ["impersonate"] ``` The values of impersonation headers can also be restricted by limiting the set of `resourceNames` a resource can take. ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: limited-impersonator rules: # Can impersonate the user "jane.doe@example.com" - apiGroups: [""] resources: ["users"] verbs: ["impersonate"] resourceNames: ["jane.doe@example.com"] # Can impersonate the groups "developers" and "admins" - apiGroups: [""] resources: ["groups"] verbs: ["impersonate"] resourceNames: ["developers","admins"] # Can impersonate the extras field "scopes" with the values "view" and "development" - apiGroups: ["authentication.k8s.io"] resources: ["userextras/scopes"] verbs: ["impersonate"] resourceNames: ["view", "development"] # Can impersonate the uid "06f6ce97-e2c5-4ab8-7ba5-7654dd08d52b" - apiGroups: ["authentication.k8s.io"] resources: ["uids"] verbs: ["impersonate"] resourceNames: ["06f6ce97-e2c5-4ab8-7ba5-7654dd08d52b"] ``` {{< note >}} Impersonating a user or group allows you to perform any action as if you were that user or group; for that reason, impersonation is not namespace scoped. If you want to allow impersonation using Kubernetes RBAC, this requires using a ClusterRole and a ClusterRoleBinding, not a Role and RoleBinding. Granting impersonation over ServiceAccounts is namespace scoped, but the impersonated ServiceAccount could perform actions outside of namespace. {{< /note >}} ## Constrained Impersonation {{< feature-state feature\_gate\_name="ConstrainedImpersonation" >}} With the \*\*impersonate\*\* verb, impersonation cannot be limited or scoped. It either grants full impersonation or none at all. Once granted permission to impersonate a user, you can perform any action that user can perform across all resources and namespaces. With constrained impersonation, an impersonator can be limited to impersonate another user only for specific actions on specific resources, rather than being able to perform all actions that the impersonated user can perform. This feature is enabled by setting the `ConstrainedImpersonation` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/#ConstrainedImpersonation). ### Understanding constrained impersonation Constrained impersonation requires \*\*two separate permissions\*\*: 1. \*\*Permission to impersonate a specific identity\*\* (user, UID, group, service account or node) 2. \*\*Permission to perform specific actions at a particular scope when impersonating\*\* (for example, only `list` and `watch` pods in the `default` namespace) This means an impersonator can be limited to impersonate another user only for specific operations. ### Impersonation modes Constrained impersonation defines three distinct modes, each with its own set of verbs: #### user-info mode Use this mode to impersonate generic users (not service accounts or nodes). This mode applies when the `Impersonate-User` header value: - Does \*\*not\*\* start with `system:serviceaccount:` - Does \*\*not\*\* start with `system:node:` \*\*Verbs:\*\* - `impersonate:user-info` - Permission to impersonate a specific user, group, UID, or extra field - `impersonate-on:user-info:` - Permission to perform `` when impersonating a generic user #### ServiceAccount mode Use this mode to impersonate ServiceAccounts. \*\*Verbs:\*\* - `impersonate:serviceaccount` - Permission to impersonate a specific service account - `impersonate-on:serviceaccount:` - Permission to perform `` when impersonating a service account #### arbitrary-node and associated-node modes Use these modes to impersonate nodes. This mode applies when the `Impersonate-User` header value starts with `system:node:`. \*\*Verbs:\*\* - `impersonate:arbitrary-node` - Permission to impersonate any specified node - `impersonate:associated-node` - Permission to impersonate only the node to which the impersonator is bound - `impersonate-on:arbitrary-node:` - Permission to perform `` when impersonating any node - `impersonate-on:associated-node:` - Permission to perform `` when impersonating the associated node {{< note >}} The `impersonate:associated-node` verb only applies when the impersonator is a service account bound to the node it's trying to impersonate. This is determined by checking if the service account's user info contains an extra field with key `authentication.kubernetes.io/node-name` that matches the node being impersonated. {{< /note >}} ### Configuring constrained impersonation with RBAC All constrained impersonation permissions use the `authentication.k8s.io` API group. Here's how to configure the different modes. #### | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/user-impersonation.md | main | kubernetes | [
-0.05305448919534683,
0.006692651193588972,
-0.05830755457282066,
0.038462162017822266,
-0.0009293321636505425,
0.0012375203659757972,
0.07606389373540878,
-0.04373311251401901,
-0.01423080638051033,
0.009008537046611309,
-0.02546357363462448,
-0.0844680443406105,
0.12166955322027206,
0.06... | 0.143369 |
This is determined by checking if the service account's user info contains an extra field with key `authentication.kubernetes.io/node-name` that matches the node being impersonated. {{< /note >}} ### Configuring constrained impersonation with RBAC All constrained impersonation permissions use the `authentication.k8s.io` API group. Here's how to configure the different modes. #### Example: Impersonate a user for specific actions This example shows how to allow a service account to impersonate a user named `jane.doe@example.com`, but only to `list` and `watch` pods in the `default` namespace. You need both a `ClusterRoleBinding` for the identity permission and a `RoleBinding` for the action permission \*\*Step 1: Grant permission to impersonate the user identity\*\* ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: impersonate-jane-identity rules: - apiGroups: ["authentication.k8s.io"] resources: ["users"] resourceNames: ["jane.doe@example.com"] verbs: ["impersonate:user-info"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: impersonate-jane-identity roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: impersonate-jane-identity subjects: - kind: ServiceAccount name: my-controller namespace: default ``` \*\*Step 2: Grant permission to perform specific actions when impersonating\*\* ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: impersonate-list-watch-pods namespace: default rules: - apiGroups: [""] resources: ["pods"] verbs: - "impersonate-on:user-info:list" - "impersonate-on:user-info:watch" --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: impersonate-list-watch-pods namespace: default roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: impersonate-list-watch-pods subjects: - kind: ServiceAccount name: my-controller namespace: default ``` Now the `my-controller` service account can impersonate `jane.doe@example.com` to list and watch pods in the `default` namespace, but \*\*cannot\*\* perform other actions like deleting pods or accessing resources in other namespaces. #### Example: Impersonate a ServiceAccount To allow impersonating a service account named `app-sa` in the `production` namespace to create and update deployments: ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: impersonate-app-sa namespace: default rules: - apiGroups: ["authentication.k8s.io"] resources: ["serviceaccounts"] resourceNames: ["app-sa"] # For service accounts, you must specify the namespace in the RoleBinding verbs: ["impersonate:serviceaccount"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: impersonate-manage-deployments namespace: production rules: - apiGroups: ["apps"] resources: ["deployments"] verbs: - "impersonate-on:serviceaccount:create" - "impersonate-on:serviceaccount:update" - "impersonate-on:serviceaccount:patch" --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: impersonate-app-sa namespace: default roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: impersonate-app-sa subjects: - kind: ServiceAccount name: deputy-controller namespace: default --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: impersonate-manage-deployments namespace: production roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: impersonate-manage-deployments subjects: - kind: ServiceAccount name: deputy-controller namespace: default ``` #### Example: Impersonate a node To allow `node-impersonator` ServiceAccount in `default` namespace impersonating a node named `mynode` to get and list pods: ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: impersonate-node-sa rules: - apiGroups: ["authentication.k8s.io"] resources: ["nodes"] resourceNames: ["mynode"] verbs: ["impersonate:arbitrary-node"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: impersonate-list-pods rules: - apiGroups: [""] resources: ["pods"] verbs: - "impersonate-on:arbitrary-node:list" - "impersonate-on:arbitrary-node:get" --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: impersonate-node-sa namespace: default roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: impersonate-node-sa subjects: - kind: ServiceAccount name: node-impersonator namespace: default --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: impersonate-list-pods roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: impersonate-list-pods subjects: - kind: ServiceAccount name: node-impersonator namespace: default ``` #### Example: Node agent impersonating the associated node This is a common pattern for node agents (like CNI plugins) that need to read pods on their node without having cluster-wide pod access. ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: impersonate-associated-node-identity rules: - apiGroups: ["authentication.k8s.io"] resources: ["nodes"] verbs: ["impersonate:associated-node"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: impersonate-list-pods-on-node rules: - apiGroups: [""] resources: ["pods"] verbs: - "impersonate-on:associated-node:list" - "impersonate-on:associated-node:get" --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: node-agent-impersonate-node roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: impersonate-associated-node-identity subjects: - kind: ServiceAccount name: node-agent namespace: kube-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: node-agent-impersonate-list-pods roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: impersonate-list-pods-on-node subjects: - kind: ServiceAccount name: node-agent namespace: kube-system ``` The controller would get the node name using the downward API: ```yaml | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/user-impersonation.md | main | kubernetes | [
-0.015200487338006496,
-0.026455601677298546,
0.01659342274069786,
-0.02077239193022251,
0.002915601711720228,
-0.008882486261427402,
0.10638228058815002,
-0.03803759440779686,
0.06908095628023148,
0.07051781564950943,
-0.03497883677482605,
-0.06847085803747177,
0.03929412364959717,
0.0387... | 0.159784 |
apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: impersonate-associated-node-identity subjects: - kind: ServiceAccount name: node-agent namespace: kube-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: node-agent-impersonate-list-pods roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: impersonate-list-pods-on-node subjects: - kind: ServiceAccount name: node-agent namespace: kube-system ``` The controller would get the node name using the downward API: ```yaml env: - name: MY\_NODE\_NAME valueFrom: fieldRef: fieldPath: spec.nodeName ``` Then configure the kubeconfig to impersonate: ```go kubeConfig, \_ := clientcmd.BuildConfigFromFlags("", "") kubeConfig.Impersonate = rest.ImpersonationConfig{ UserName: "system:node:" + os.Getenv("MY\_NODE\_NAME"), } ``` ### Using constrained impersonation From a client perspective, using constrained impersonation is identical to using traditional impersonation. You use the same impersonation headers: ```http Impersonate-User: jane.doe@example.com ``` Or with kubectl: ```bash kubectl get pods -n default --as=jane.doe@example.com ``` The difference is entirely in the authorization checks performed by the API server. ### Working with `impersonate` verb - If you have existing RBAC rules using the `impersonate` verb, they continue to function when the feature gate is enabled. - When an impersonation request is made, the API server first checks for constrained impersonation permissions. If those checks fail, it falls back to checking the `impersonate` permission. ## Auditing An audit event is logged for each impersonation request to help track how impersonation is used. When a request uses constrained impersonation, the audit event includes `authenticationMetadata` object with an `impersonationConstraint` field that indicates which constrained impersonation verb was used to authorize the request. Example audit event: ```json { "kind": "Event", "apiVersion": "audit.k8s.io/v1", "user": { "username": "system:serviceaccount:default:my-controller" }, "impersonatedUser": { "username": "jane.doe@example.com" }, "authenticationMetadata": { "impersonationConstraint": "impersonate:user-info" }, "verb": "list", "objectRef": { "resource": "pods", "namespace": "default" } } ``` The `impersonationConstraint` value indicates which mode was used (for example, `impersonate:user-info`, `impersonate:associated-node`). The specific action (for example, `list`) can be determined from the `verb` field in the audit event. ## {{% heading "whatsnext" %}} - Read about [RBAC authorization](/docs/reference/access-authn-authz/rbac/) - Understand [Kubernetes authentication](/docs/reference/access-authn-authz/authentication/) | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/user-impersonation.md | main | kubernetes | [
-0.0057015735656023026,
0.000658267003018409,
-0.047705117613077164,
0.05450449883937836,
-0.015388259664177895,
-0.008421429432928562,
0.04437556117773056,
-0.0012809443287551403,
0.050123181194067,
0.0472458153963089,
-0.002092427108436823,
-0.09352423995733261,
0.05116727948188782,
0.00... | 0.14394 |
Kubernetes authorization takes place following [authentication](/docs/reference/access-authn-authz/authentication/). Usually, a client making a request must be authenticated (logged in) before its request can be allowed; however, Kubernetes also allows anonymous requests in some circumstances. For an overview of how authorization fits into the wider context of API access control, read [Controlling Access to the Kubernetes API](/docs/concepts/security/controlling-access/). ## Authorization verdicts {#determine-whether-a-request-is-allowed-or-denied} Kubernetes authorization of API requests takes place within the API server. The API server evaluates all of the request attributes against all policies, potentially also consulting external services, and then allows or denies the request. All parts of an API request must be allowed by some authorization mechanism in order to proceed. In other words: access is denied by default. {{% note %}} Access controls and policies that depend on specific fields of specific kinds of objects are handled by {{< glossary\_tooltip text="admission controllers" term\_id="admission-controller" >}}. Kubernetes admission control happens after authorization has completed (and, therefore, only when the authorization decision was to allow the request). {{% /note %}} When multiple [authorization modules](#authorization-modules) are configured, each is checked in sequence. If any authorizer \_approves\_ or \_denies\_ a request, that decision is immediately returned and no other authorizer is consulted. If all modules have \_no opinion\_ on the request, then the request is denied. An overall deny verdict means that the API server rejects the request and responds with an HTTP 403 (Forbidden) status. ## Request attributes used in authorization Kubernetes reviews only the following API request attributes: \* \*\*user\*\* - The `user` string provided during authentication. \* \*\*group\*\* - The list of group names to which the authenticated user belongs. \* \*\*extra\*\* - A map of arbitrary string keys to string values, provided by the authentication layer. \* \*\*API\*\* - Indicates whether the request is for an API resource. \* \*\*Request path\*\* - Path to miscellaneous non-resource endpoints like `/api` or `/healthz`. \* \*\*API request verb\*\* - API verbs like `get`, `list`, `create`, `update`, `patch`, `watch`, `delete`, and `deletecollection` are used for resource requests. To determine the request verb for a resource API endpoint, see [request verbs and authorization](/docs/reference/access-authn-authz/authorization/#determine-the-request-verb). \* \*\*HTTP request verb\*\* - Lowercased HTTP methods like `get`, `post`, `put`, and `delete` are used for non-resource requests. \* \*\*Resource\*\* - The ID or name of the resource that is being accessed (for resource requests only) -- For resource requests using `get`, `update`, `patch`, and `delete` verbs, you must provide the resource name. \* \*\*Subresource\*\* - The subresource that is being accessed (for resource requests only). \* \*\*Namespace\*\* - The namespace of the object that is being accessed (for namespaced resource requests only). \* \*\*API group\*\* - The {{< glossary\_tooltip text="API Group" term\_id="api-group" >}} being accessed (for resource requests only). An empty string designates the \_core\_ [API group](/docs/reference/using-api/#api-groups). ### Request verbs and authorization {#determine-the-request-verb} #### Non-resource requests {#request-verb-non-resource} Requests to endpoints other than `/api/v1/...` or `/apis///...` are considered \_non-resource requests\_, and use the lower-cased HTTP method of the request as the verb. For example, making a `GET` request using HTTP to endpoints such as `/api` or `/healthz` would use \*\*get\*\* as the verb. #### Resource requests {#request-verb-resource} To determine the request verb for a resource API endpoint, Kubernetes maps the HTTP verb used and considers whether or not the request acts on an individual resource or on a collection of resources: HTTP verb | request verb --------------|--------------- `POST` | \*\*create\*\* `GET`, `HEAD` | \*\*get\*\* (for individual resources), \*\*list\*\* (for collections, including full object content), \*\*watch\*\* (for watching an individual resource or collection of resources) `PUT` | \*\*update\*\* `PATCH` | \*\*patch\*\* `DELETE` | \*\*delete\*\* (for individual resources), \*\*deletecollection\*\* (for collections) {{< caution >}} | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authorization.md | main | kubernetes | [
-0.03946353495121002,
0.0649290680885315,
0.03590843826532364,
-0.036557938903570175,
-0.020287983119487762,
-0.02411593683063984,
0.04962373152375221,
-0.0248727984726429,
0.1251346319913864,
0.037796977907419205,
-0.037759702652692795,
-0.005294442176818848,
0.012664132751524448,
0.00599... | 0.141657 |
verb | request verb --------------|--------------- `POST` | \*\*create\*\* `GET`, `HEAD` | \*\*get\*\* (for individual resources), \*\*list\*\* (for collections, including full object content), \*\*watch\*\* (for watching an individual resource or collection of resources) `PUT` | \*\*update\*\* `PATCH` | \*\*patch\*\* `DELETE` | \*\*delete\*\* (for individual resources), \*\*deletecollection\*\* (for collections) {{< caution >}} +The \*\*get\*\*, \*\*list\*\* and \*\*watch\*\* verbs can all return the full details of a resource. In terms of access to the returned data they are equivalent. For example, \*\*list\*\* on `secrets` will reveal the \*\*data\*\* attributes of any returned resources. {{< /caution >}} Kubernetes sometimes checks authorization for additional permissions using specialized verbs. For example: \* Special cases of [authentication](/docs/reference/access-authn-authz/authentication/) \* \*\*impersonate\*\* verb on `users`, `groups`, and `serviceaccounts` in the core API group, and the `userextras` in the `authentication.k8s.io` API group. \* [Authorization of CertificateSigningRequests](/docs/reference/access-authn-authz/certificate-signing-requests/#authorization) \* \*\*approve\*\* verb for CertificateSigningRequests, and \*\*update\*\* for revisions to existing approvals \* [RBAC](/docs/reference/access-authn-authz/rbac/#privilege-escalation-prevention-and-bootstrapping) \* \*\*bind\*\* and \*\*escalate\*\* verbs on `roles` and `clusterroles` resources in the `rbac.authorization.k8s.io` API group. ## Authorization context Kubernetes expects attributes that are common to REST API requests. This means that Kubernetes authorization works with existing organization-wide or cloud-provider-wide access control systems which may handle other APIs besides the Kubernetes API. ## Authorization modes {#authorization-modules} The Kubernetes API server may authorize a request using one of several authorization modes: `AlwaysAllow` : This mode allows all requests, which brings [security risks](#warning-always-allow). Use this authorization mode only if you do not require authorization for your API requests (for example, for testing). `AlwaysDeny` : This mode blocks all requests. Use this authorization mode only for testing. `ABAC` ([attribute-based access control](/docs/reference/access-authn-authz/abac/)) : Kubernetes ABAC mode defines an access control paradigm whereby access rights are granted to users through the use of policies which combine attributes together. The policies can use any type of attributes (user attributes, resource attributes, object, environment attributes, etc). `RBAC` ([role-based access control](/docs/reference/access-authn-authz/rbac/)) : Kubernetes RBAC is a method of regulating access to computer or network resources based on the roles of individual users within an enterprise. In this context, access is the ability of an individual user to perform a specific task, such as view, create, or modify a file. In this mode, Kubernetes uses the `rbac.authorization.k8s.io` API group to drive authorization decisions, allowing you to dynamically configure permission policies through the Kubernetes API. `Node` : A special-purpose authorization mode that grants permissions to kubelets based on the pods they are scheduled to run. To learn more about the Node authorization mode, see [Node Authorization](/docs/reference/access-authn-authz/node/). `Webhook` : Kubernetes [webhook mode](/docs/reference/access-authn-authz/webhook/) for authorization makes a synchronous HTTP callout, blocking the request until the remote HTTP service responds to the query.You can write your own software to handle the callout, or use solutions from the ecosystem. {{< warning >}} Enabling the `AlwaysAllow` mode bypasses authorization; do not use this on a cluster where you do not trust \*\*all\*\* potential API clients, including the workloads that you run. Authorization mechanisms typically return either a \_deny\_ or \_no opinion\_ result; see [authorization verdicts](#determine-whether-a-request-is-allowed-or-denied) for more on this. Activating the `AlwaysAllow` means that if all other authorizers return “no opinion”, the request is allowed. For example, `--authorization-mode=AlwaysAllow,RBAC` has the same effect as `--authorization-mode=AlwaysAllow` because Kubernetes RBAC does not provide negative (deny) access rules. You should not use the `AlwaysAllow` mode on a Kubernetes cluster where the API server is reachable from the public internet. {{< /warning >}} ### The system:masters group The `system:masters` group is a built-in Kubernetes group that grants unrestricted access to the API server. Any user assigned to this group has full cluster administrator privileges, bypassing any authorization restrictions imposed by the RBAC | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authorization.md | main | kubernetes | [
-0.11071338504552841,
0.053956545889377594,
-0.05703740194439888,
0.051682066172361374,
0.05332985520362854,
-0.013763255439698696,
0.09900283068418503,
-0.042860426008701324,
-0.01455130334943533,
0.08109930157661438,
0.03780069574713707,
-0.05242190510034561,
0.06759133189916611,
-0.0195... | 0.125814 |
API server is reachable from the public internet. {{< /warning >}} ### The system:masters group The `system:masters` group is a built-in Kubernetes group that grants unrestricted access to the API server. Any user assigned to this group has full cluster administrator privileges, bypassing any authorization restrictions imposed by the RBAC or Webhook mechanisms. [Avoid adding users](/docs/concepts/security/rbac-good-practices/#least-privilege) to this group. If you do need to grant a user cluster-admin rights, you can create a [ClusterRoleBinding](/docs/reference/access-authn-authz/rbac/#user-facing-roles) to the built-in `cluster-admin` ClusterRole. ### Authorization mode configuration {#choice-of-authz-config} You can configure the Kubernetes API server's authorizer chain using either a [configuration file](#using-configuration-file-for-authorization) only or [command line arguments](#using-flags-for-your-authorization-module). You have to pick one of the two configuration approaches; setting both `--authorization-config` path and configuring an authorization webhook using the `--authorization-mode` and `--authorization-webhook-\*` command line arguments is not allowed. If you try this, the API server reports an error message during startup, then exits immediately. ### Configuring the API Server using an authorization config file {#using-configuration-file-for-authorization} {{< feature-state feature\_gate\_name="StructuredAuthorizationConfiguration" >}} Kubernetes lets you configure authorization chains that can include multiple webhooks. The authorization items in that chain can have well-defined parameters that validate requests in a particular order, offering you fine-grained control, such as explicit Deny on failures. The configuration file approach even allows you to specify [CEL](/docs/reference/using-api/cel/) rules to pre-filter requests before they are dispatched to webhooks, helping you to prevent unnecessary invocations. The API server also automatically reloads the authorizer chain when the configuration file is modified. You specify the path to the authorization configuration using the `--authorization-config` command line argument. If you want to use command line arguments instead of a configuration file, that's also a valid and supported approach. Some authorization capabilities (for example: multiple webhooks, webhook failure policy, and pre-filter rules) are only available if you use an authorization configuration file. #### Example configuration {#authz-config-example} {{< highlight yaml "linenos=false,hl\_lines=2-4" >}} --- # # DO NOT USE THE CONFIG AS IS. THIS IS AN EXAMPLE. # apiVersion: apiserver.config.k8s.io/v1 kind: AuthorizationConfiguration authorizers: - type: Webhook # Name used to describe the authorizer # This is explicitly used in monitoring machinery for metrics # Note: # - Validation for this field is similar to how K8s labels are validated today. # Required, with no default name: webhook webhook: # The duration to cache 'authorized' responses from the webhook # authorizer. # Same as setting `--authorization-webhook-cache-authorized-ttl` flag # Default: 5m0s authorizedTTL: 30s # If set to false, 'authorized' responses from the webhook are not cached # and the specified authorizedTTL is ignored/has no effect. # Same as setting `--authorization-webhook-cache-authorized-ttl` flag to `0`. # Note: Setting authorizedTTL to `0` results in its default value being used. # Default: true cacheAuthorizedRequests: true # The duration to cache 'unauthorized' responses from the webhook # authorizer. # Same as setting `--authorization-webhook-cache-unauthorized-ttl` flag # Default: 30s unauthorizedTTL: 30s # If set to false, 'unauthorized' responses from the webhook are not cached # and the specified unauthorizedTTL is ignored/has no effect. # Same as setting `--authorization-webhook-cache-unauthorized-ttl` flag to `0`. # Note: Setting unauthorizedTTL to `0` results in its default value being used. # Default: true cacheUnauthorizedRequests: true # Timeout for the webhook request # Maximum allowed is 30s. # Required, with no default. timeout: 3s # The API version of the authorization.k8s.io SubjectAccessReview to # send to and expect from the webhook. # Same as setting `--authorization-webhook-version` flag # Required, with no default # Valid values: v1beta1, v1 subjectAccessReviewVersion: v1 # MatchConditionSubjectAccessReviewVersion specifies the SubjectAccessReview # version the CEL expressions are evaluated against # Valid values: v1 # Required, no default value matchConditionSubjectAccessReviewVersion: v1 # Controls the authorization decision when a | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authorization.md | main | kubernetes | [
0.003364084754139185,
-0.0030995842535048723,
-0.05996709689497948,
0.016714289784431458,
-0.051285747438669205,
0.02792222611606121,
-0.009491189382970333,
-0.016852574422955513,
-0.0030460411217063665,
0.05376994609832764,
-0.04711689427495003,
-0.045114487409591675,
0.04172553867101669,
... | 0.1259 |
webhook. # Same as setting `--authorization-webhook-version` flag # Required, with no default # Valid values: v1beta1, v1 subjectAccessReviewVersion: v1 # MatchConditionSubjectAccessReviewVersion specifies the SubjectAccessReview # version the CEL expressions are evaluated against # Valid values: v1 # Required, no default value matchConditionSubjectAccessReviewVersion: v1 # Controls the authorization decision when a webhook request fails to # complete or returns a malformed response or errors evaluating # matchConditions. # Valid values: # - NoOpinion: continue to subsequent authorizers to see if one of # them allows the request # - Deny: reject the request without consulting subsequent authorizers # Required, with no default. failurePolicy: Deny connectionInfo: # Controls how the webhook should communicate with the server. # Valid values: # - KubeConfigFile: use the file specified in kubeConfigFile to locate the # server. # - InClusterConfig: use the in-cluster configuration to call the # SubjectAccessReview API hosted by kube-apiserver. This mode is not # allowed for kube-apiserver. type: KubeConfigFile # Path to KubeConfigFile for connection info # Required, if connectionInfo.Type is KubeConfigFile kubeConfigFile: /kube-system-authz-webhook.yaml # matchConditions is a list of conditions that must be met for a request to be sent to this # webhook. An empty list of matchConditions matches all requests. # There are a maximum of 64 match conditions allowed. # # The exact matching logic is (in order): # 1. If at least one matchCondition evaluates to FALSE, then the webhook is skipped. # 2. If ALL matchConditions evaluate to TRUE, then the webhook is called. # 3. If at least one matchCondition evaluates to an error (but none are FALSE): # - If failurePolicy=Deny, then the webhook rejects the request # - If failurePolicy=NoOpinion, then the error is ignored and the webhook is skipped matchConditions: # expression represents the expression which will be evaluated by CEL. Must evaluate to bool. # CEL expressions have access to the contents of the SubjectAccessReview in v1 version. # If version specified by subjectAccessReviewVersion in the request variable is v1beta1, # the contents would be converted to the v1 version before evaluating the CEL expression. # # Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/ # # only send resource requests to the webhook - expression: has(request.resourceAttributes) # only intercept requests to kube-system - expression: request.resourceAttributes.namespace == 'kube-system' # don't intercept requests from kube-system service accounts - expression: "!('system:serviceaccounts:kube-system' in request.groups)" - type: Node name: node - type: RBAC name: rbac - type: Webhook name: in-cluster-authorizer webhook: authorizedTTL: 5m unauthorizedTTL: 30s timeout: 3s subjectAccessReviewVersion: v1 failurePolicy: NoOpinion connectionInfo: type: InClusterConfig {{< /highlight >}} When configuring the authorizer chain using a configuration file, make sure all the control plane nodes have the same file contents. Take a note of the API server configuration when upgrading / downgrading your clusters. For example, if upgrading from Kubernetes {{< skew currentVersionAddMinor -1 >}} to Kubernetes {{< skew currentVersion >}}, you would need to make sure the config file is in a format that Kubernetes {{< skew currentVersion >}} can understand, before you upgrade the cluster. If you downgrade to {{< skew currentVersionAddMinor -1 >}}, you would need to set the configuration appropriately. #### Authorization configuration and reloads Kubernetes reloads the authorization configuration file when the API server observes a change to the file, and also on a 60 second schedule if no change events were observed. {{< note >}} You must ensure that all non-webhook authorizer types remain unchanged in the file on reload. A reload \*\*must not\*\* add or remove Node or RBAC authorizers (they can be reordered, but cannot be added or removed). {{< /note >}} ### Command line authorization mode configuration {#using-flags-for-your-authorization-module} You can use the | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authorization.md | main | kubernetes | [
-0.07730856537818909,
0.09256184846162796,
-0.040155671536922455,
-0.06637115776538849,
0.029809027910232544,
-0.06129063293337822,
-0.029493074864149094,
-0.06448481976985931,
0.017042357474565506,
0.006804461125284433,
0.01928521692752838,
-0.13887238502502441,
0.044605400413274765,
-0.0... | 0.11175 |
You must ensure that all non-webhook authorizer types remain unchanged in the file on reload. A reload \*\*must not\*\* add or remove Node or RBAC authorizers (they can be reordered, but cannot be added or removed). {{< /note >}} ### Command line authorization mode configuration {#using-flags-for-your-authorization-module} You can use the following modes: \* `--authorization-mode=ABAC` (Attribute-based access control mode) \* `--authorization-mode=RBAC` (Role-based access control mode) \* `--authorization-mode=Node` (Node authorizer) \* `--authorization-mode=Webhook` (Webhook authorization mode) \* `--authorization-mode=AlwaysAllow` (always allows requests; carries [security risks](#warning-always-allow)) \* `--authorization-mode=AlwaysDeny` (always denies requests) You can choose more than one authorization mode; for example: `--authorization-mode=Node,RBAC,Webhook` Kubernetes checks authorization modules based on the order that you specify them on the API server's command line, so an earlier module has higher priority to allow or deny a request. You cannot combine the `--authorization-mode` command line argument with the `--authorization-config` command line argument used for [configuring authorization using a local file](#using-configuration-file-for-authorization-mode). For more information on command line arguments to the API server, read the [`kube-apiserver` reference](/docs/reference/command-line-tools-reference/kube-apiserver/). ## Privilege escalation via workload creation or edits {#privilege-escalation-via-pod-creation} Users who can create/edit pods in a namespace, either directly or through an object that enables indirect [workload management](/docs/concepts/architecture/controller/), may be able to escalate their privileges in that namespace. The potential routes to privilege escalation include Kubernetes [API extensions](/docs/concepts/extend-kubernetes/#api-extensions) and their associated {{< glossary\_tooltip term\_id="controller" text="controllers" >}}. {{< caution >}} As a cluster administrator, use caution when granting access to create or edit workloads. Some details of how these can be misused are documented in [escalation paths](/docs/reference/access-authn-authz/authorization/#escalation-paths). {{< /caution >}} ### Escalation paths {#escalation-paths} There are different ways that an attacker or untrustworthy user could gain additional privilege within a namespace, if you allow them to run arbitrary Pods in that namespace: - Mounting arbitrary Secrets in that namespace - Can be used to access confidential information meant for other workloads - Can be used to obtain a more privileged ServiceAccount's service account token - Using arbitrary ServiceAccounts in that namespace - Can perform Kubernetes API actions as another workload (impersonation) - Can perform any privileged actions that ServiceAccount has - Mounting or using ConfigMaps meant for other workloads in that namespace - Can be used to obtain information meant for other workloads, such as database host names. - Mounting volumes meant for other workloads in that namespace - Can be used to obtain information meant for other workloads, and change it. {{< caution >}} As a system administrator, you should be cautious when deploying CustomResourceDefinitions that let users make changes to the above areas. These may open privilege escalations paths. Consider the consequences of this kind of change when deciding on your authorization controls. {{< /caution >}} ## Checking API access `kubectl` provides the `auth can-i` subcommand for quickly querying the API authorization layer. The command uses the `SelfSubjectAccessReview` API to determine if the current user can perform a given action, and works regardless of the authorization mode used. ```bash kubectl auth can-i create deployments --namespace dev ``` The output is similar to this: ``` yes ``` ```shell kubectl auth can-i create deployments --namespace prod ``` The output is similar to this: ``` no ``` Administrators can combine this with [user impersonation](/docs/reference/access-authn-authz/authentication/#user-impersonation) to determine what action other users can perform. ```bash kubectl auth can-i list secrets --namespace dev --as dave ``` The output is similar to this: ``` no ``` Similarly, to check whether a ServiceAccount named `dev-sa` in Namespace `dev` can list Pods in the Namespace `target`: ```bash kubectl auth can-i list pods \ --namespace target \ --as system:serviceaccount:dev:dev-sa ``` The output is similar to this: ``` yes ``` SelfSubjectAccessReview is part of the | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authorization.md | main | kubernetes | [
-0.01292797178030014,
0.06029271334409714,
-0.06639450043439865,
0.025682488456368446,
-0.04294097051024437,
-0.006634899880737066,
0.01093573309481144,
-0.06549790501594543,
0.0032295193523168564,
0.03633677959442139,
0.020312100648880005,
-0.05921832472085953,
0.038517843931913376,
-0.02... | 0.038145 |
to this: ``` no ``` Similarly, to check whether a ServiceAccount named `dev-sa` in Namespace `dev` can list Pods in the Namespace `target`: ```bash kubectl auth can-i list pods \ --namespace target \ --as system:serviceaccount:dev:dev-sa ``` The output is similar to this: ``` yes ``` SelfSubjectAccessReview is part of the `authorization.k8s.io` API group, which exposes the API server authorization to external services. Other resources in this group include: SubjectAccessReview : Access review for any user, not only the current one. Useful for delegating authorization decisions to the API server. For example, the kubelet and extension API servers use this to determine user access to their own APIs. LocalSubjectAccessReview : Like SubjectAccessReview but restricted to a specific namespace. SelfSubjectRulesReview : A review which returns the set of actions a user can perform within a namespace. Useful for users to quickly summarize their own access, or for UIs to hide/show actions. These APIs can be queried by creating normal Kubernetes resources, where the response `status` field of the returned object is the result of the query. For example: ```bash kubectl create -f - -o yaml << EOF apiVersion: authorization.k8s.io/v1 kind: SelfSubjectAccessReview spec: resourceAttributes: group: apps resource: deployments verb: create namespace: dev EOF ``` The generated SelfSubjectAccessReview is similar to: {{< highlight yaml "linenos=false,hl\_lines=11-13" >}} apiVersion: authorization.k8s.io/v1 kind: SelfSubjectAccessReview metadata: creationTimestamp: null spec: resourceAttributes: group: apps resource: deployments namespace: dev verb: create status: allowed: true denied: false {{< /highlight >}} ## {{% heading "whatsnext" %}} \* To learn more about Authentication, see [Authentication](/docs/reference/access-authn-authz/authentication/). \* For an overview, read [Controlling Access to the Kubernetes API](/docs/concepts/security/controlling-access/). \* To learn more about Admission Control, see [Using Admission Controllers](/docs/reference/access-authn-authz/admission-controllers/). \* Read more about [Common Expression Language in Kubernetes](/docs/reference/using-api/cel/). | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/authorization.md | main | kubernetes | [
-0.02315453812479973,
-0.009233754128217697,
-0.03761110454797745,
-0.01487585250288248,
0.005057959817349911,
-0.03690781816840172,
0.06863927096128464,
-0.0507524311542511,
0.09589895606040955,
0.036250367760658264,
-0.024754995480179787,
-0.08571336418390274,
0.048391055315732956,
-0.01... | 0.256715 |
Node authorization is a special-purpose authorization mode that specifically authorizes API requests made by kubelets. ## Overview The Node authorizer allows a kubelet to perform API operations. This includes: Read operations: \* services \* endpoints \* nodes \* pods \* secrets, configmaps, persistent volume claims and persistent volumes related to pods bound to the kubelet's node {{< feature-state feature\_gate\_name="AuthorizeNodeWithSelectors" >}} Kubelets are limited to reading their own Node objects, and only reading pods bound to their node. Write operations: \* nodes and node status (enable the `NodeRestriction` admission plugin to limit a kubelet to modify its own node) \* pods and pod status (enable the `NodeRestriction` admission plugin to limit a kubelet to modify pods bound to itself) \* events Auth-related operations: \* read/write access to the [CertificateSigningRequests API](/docs/reference/access-authn-authz/certificate-signing-requests/) for TLS bootstrapping \* the ability to create TokenReviews and SubjectAccessReviews for delegated authentication/authorization checks In future releases, the node authorizer may add or remove permissions to ensure kubelets have the minimal set of permissions required to operate correctly. In order to be authorized by the Node authorizer, kubelets must use a credential that identifies them as being in the `system:nodes` group, with a username of `system:node:`. This group and user name format match the identity created for each kubelet as part of [kubelet TLS bootstrapping](/docs/reference/access-authn-authz/kubelet-tls-bootstrapping/). The value of `` \*\*must\*\* match precisely the name of the node as registered by the kubelet. By default, this is the host name as provided by `hostname`, or overridden via the [kubelet option](/docs/reference/command-line-tools-reference/kubelet/) `--hostname-override`. However, when using the `--cloud-provider` kubelet option, the specific hostname may be determined by the cloud provider, ignoring the local `hostname` and the `--hostname-override` option. For specifics about how the kubelet determines the hostname, see the [kubelet options reference](/docs/reference/command-line-tools-reference/kubelet/). To enable the Node authorizer, start the {{< glossary\_tooltip text="API server" term\_id="kube-apiserver" >}} with the `--authorization-config` flag set to a file that includes the `Node` authorizer; for example: ```yaml apiVersion: apiserver.config.k8s.io/v1 kind: AuthorizationConfiguration authorizers: ... - type: Node ... ``` Or, start the {{< glossary\_tooltip text="API server" term\_id="kube-apiserver" >}} with the `--authorization-mode` flag set to a comma-separated list that includes `Node`; for example: ```shell kube-apiserver --authorization-mode=...,Node --other-options --more-options ``` To limit the API objects kubelets are able to write, enable the [NodeRestriction](/docs/reference/access-authn-authz/admission-controllers#noderestriction) admission plugin by starting the apiserver with `--enable-admission-plugins=...,NodeRestriction,...` ## Migration considerations ### Kubelets outside the `system:nodes` group Kubelets outside the `system:nodes` group would not be authorized by the `Node` authorization mode, and would need to continue to be authorized via whatever mechanism currently authorizes them. The node admission plugin would not restrict requests from these kubelets. ### Kubelets with undifferentiated usernames In some deployments, kubelets have credentials that place them in the `system:nodes` group, but do not identify the particular node they are associated with, because they do not have a username in the `system:node:...` format. These kubelets would not be authorized by the `Node` authorization mode, and would need to continue to be authorized via whatever mechanism currently authorizes them. The `NodeRestriction` admission plugin would ignore requests from these kubelets, since the default node identifier implementation would not consider that a node identity. | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/node.md | main | kubernetes | [
0.033489909023046494,
0.03380820155143738,
0.03121379017829895,
0.03892763704061508,
-0.03607679903507233,
-0.04166107997298241,
0.007323463447391987,
-0.006914698984473944,
0.07055488973855972,
0.0261569544672966,
-0.04925635829567909,
-0.028054308146238327,
0.029785914346575737,
-0.03894... | 0.206593 |
A \_ServiceAccount\_ provides an identity for processes that run in a Pod. A process inside a Pod can use the identity of its associated service account to authenticate to the cluster's API server. For an introduction to service accounts, read [configure service accounts](/docs/tasks/configure-pod-container/configure-service-account/). This task guide explains some of the concepts behind ServiceAccounts. The guide also explains how to obtain or revoke tokens that represent ServiceAccounts, and how to (optionally) bind a ServiceAccount's validity to the lifetime of an API object. ## {{% heading "prerequisites" %}} {{< include "task-tutorial-prereqs.md" >}} To be able to follow these steps exactly, ensure you have a namespace named `examplens`. If you don't, create one by running: ```shell kubectl create namespace examplens ``` ## User accounts versus service accounts Kubernetes distinguishes between the concept of a user account and a service account for a number of reasons: - User accounts are for humans. Service accounts are for application processes, which (for Kubernetes) run in containers that are part of pods. - User accounts are intended to be global: names must be unique across all namespaces of a cluster. No matter what namespace you look at, a particular username that represents a user represents the same user. In Kubernetes, service accounts are namespaced: two different namespaces can contain ServiceAccounts that have identical names. - Typically, a cluster's user accounts might be synchronised from a corporate database, where new user account creation requires special privileges and is tied to complex business processes. By contrast, service account creation is intended to be more lightweight, allowing cluster users to create service accounts for specific tasks on demand. Separating ServiceAccount creation from the steps to onboard human users makes it easier for workloads to follow the principle of least privilege. - Auditing considerations for humans and service accounts may differ; the separation makes that easier to achieve. - A configuration bundle for a complex system may include definition of various service accounts for components of that system. Because service accounts can be created without many constraints and have namespaced names, such configuration is usually portable. ## Bound service account tokens ServiceAccount tokens can be bound to API objects that exist in the kube-apiserver. This can be used to tie the validity of a token to the existence of another API object. Supported object types are as follows: \* Pod (used for projected volume mounts, see below) \* Secret (can be used to allow revoking a token by deleting the Secret) \* Node (can be used to auto-revoke a token when its Node is deleted; creating new node-bound tokens is GA in v1.33+) When a token is bound to an object, the object's `metadata.name` and `metadata.uid` are stored as extra 'private claims' in the issued JWT. When a bound token is presented to the kube-apiserver, the service account authenticator will extract and verify these claims. If the referenced object or the ServiceAccount is pending deletion (for example, due to finalizers), then for any instant that is 60 seconds (or more) after the `.metadata.deletionTimestamp` date, authentication with that token would fail. If the referenced object no longer exists (or its `metadata.uid` does not match), the request will not be authenticated. ### Additional metadata in Pod bound tokens {{< feature-state feature\_gate\_name="ServiceAccountTokenPodNodeInfo" >}} When a service account token is bound to a Pod object, additional metadata is also embedded into the token that indicates the value of the bound pod's `spec.nodeName` field, and the uid of that Node, if available. This node information is \*\*not\*\* verified by the kube-apiserver when the token is used for authentication. It is included so integrators do not have | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/service-accounts-admin.md | main | kubernetes | [
-0.048717208206653595,
-0.03264959156513214,
0.01844039186835289,
-0.018496109172701836,
-0.03535333275794983,
0.0002522349823266268,
0.05018328130245209,
-0.012433690950274467,
0.0963858887553215,
0.04123730584979057,
-0.02856690250337124,
-0.0368758887052536,
0.05768865719437599,
-0.0010... | 0.193659 |
additional metadata is also embedded into the token that indicates the value of the bound pod's `spec.nodeName` field, and the uid of that Node, if available. This node information is \*\*not\*\* verified by the kube-apiserver when the token is used for authentication. It is included so integrators do not have to fetch Pod or Node API objects to check the associated Node name and uid when inspecting a JWT. ### Verifying and inspecting private claims The TokenReview API can be used to verify and extract private claims from a token: 1. First, assume you have a pod named `test-pod` and a service account named `my-sa`. 1. Create a token that is bound to this Pod: ```shell kubectl create token my-sa --bound-object-kind="Pod" --bound-object-name="test-pod" ``` 1. Copy this token into a new file named `tokenreview.yaml`: ```yaml apiVersion: authentication.k8s.io/v1 kind: TokenReview spec: token: ``` 1. Submit this resource to the apiserver for review: ```shell # use '-o yaml' to inspect the output kubectl create -o yaml -f tokenreview.yaml ``` You should see an output like below: ```yaml apiVersion: authentication.k8s.io/v1 kind: TokenReview metadata: creationTimestamp: null spec: token: status: audiences: - https://kubernetes.default.svc.cluster.local authenticated: true user: extra: authentication.kubernetes.io/credential-id: - JTI=7ee52be0-9045-4653-aa5e-0da57b8dccdc authentication.kubernetes.io/node-name: - kind-control-plane authentication.kubernetes.io/node-uid: - 497e9d9a-47aa-4930-b0f6-9f2fb574c8c6 authentication.kubernetes.io/pod-name: - test-pod authentication.kubernetes.io/pod-uid: - e87dbbd6-3d7e-45db-aafb-72b24627dff5 groups: - system:serviceaccounts - system:serviceaccounts:default - system:authenticated uid: f8b4161b-2e2b-11e9-86b7-2afc33b31a7e username: system:serviceaccount:default:my-sa ``` {{< note >}} Despite using `kubectl create -f` to create this resource, and defining it similar to other resource types in Kubernetes, TokenReview is a special type and the kube-apiserver does not actually persist the TokenReview object into etcd. Hence `kubectl get tokenreview` is not a valid command. {{< /note >}} #### Schema for service account private claims The schema for the Kubernetes-specific claims within JWT tokens is not currently documented, however the relevant code area can be found in [the serviceaccount package](https://github.com/kubernetes/kubernetes/blob/d8919343526597e0788a1efe133c70d9a0c07f69/pkg/serviceaccount/claims.go#L56-L68) in the Kubernetes codebase. You can inspect a JWT using standard JWT decoding tool. Below is an example of a JWT for the `my-serviceaccount` ServiceAccount, bound to a Pod object named `my-pod` which is scheduled to the Node `my-node`, in the `my-namespace` namespace: ```json { "aud": [ "https://my-audience.example.com" ], "exp": 1729605240, "iat": 1729601640, "iss": "https://my-cluster.example.com", "jti": "aed34954-b33a-4142-b1ec-389d6bbb4936", "kubernetes.io": { "namespace": "my-namespace", "node": { "name": "my-node", "uid": "646e7c5e-32d6-4d42-9dbd-e504e6cbe6b1" }, "pod": { "name": "my-pod", "uid": "5e0bd49b-f040-43b0-99b7-22765a53f7f3" }, "serviceaccount": { "name": "my-serviceaccount", "uid": "14ee3fa4-a7e2-420f-9f9a-dbc4507c3798" } }, "nbf": 1729601640, "sub": "system:serviceaccount:my-namespace:my-serviceaccount" } ``` {{< note >}} The `aud` and `iss` fields in this JWT may differ between different Kubernetes clusters depending on your configuration. The presence of both the `pod` and `node` claim implies that this token is bound to a \*Pod\* object. When verifying Pod bound ServiceAccount tokens, the API server \*\*does not\*\* verify the existence of the referenced Node object. {{< /note >}} Services that run outside of Kubernetes and want to perform offline validation of JWTs may use this schema, along with a compliant JWT validator configured with OpenID Discovery information from the API server, to verify presented JWTs without requiring use of the TokenReview API. Services that verify JWTs in this way \*\*do not verify\*\* the claims embedded in the JWT token to be current and still valid. This means if the token is bound to an object, and that object no longer exists, the token will still be considered valid (until the configured token expires). Clients that require assurance that a token's bound claims are still valid \*\*MUST\*\* use the TokenReview API to present the token to the `kube-apiserver` for it to verify and expand the embedded claims, using similar steps to the [Verifying and inspecting private claims](#verifying-and-inspecting-private-claims) section above, but with a [supported client library](/docs/reference/using-api/client-libraries/). For more | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/service-accounts-admin.md | main | kubernetes | [
-0.016750361770391464,
0.03209594264626503,
0.037775907665491104,
0.016574282199144363,
0.023258142173290253,
-0.04105479270219803,
0.04813842475414276,
0.009450230747461319,
0.0779557004570961,
0.03521407023072243,
-0.03976232558488846,
-0.09050603210926056,
0.057574354112148285,
-0.03094... | 0.175544 |
assurance that a token's bound claims are still valid \*\*MUST\*\* use the TokenReview API to present the token to the `kube-apiserver` for it to verify and expand the embedded claims, using similar steps to the [Verifying and inspecting private claims](#verifying-and-inspecting-private-claims) section above, but with a [supported client library](/docs/reference/using-api/client-libraries/). For more information on JWTs and their structure, see the [JSON Web Token RFC](https://datatracker.ietf.org/doc/html/rfc7519). ## Bound service account token volume mechanism {#bound-service-account-token-volume} {{< feature-state feature\_gate\_name="BoundServiceAccountTokenVolume" >}} By default, the Kubernetes control plane (specifically, the [ServiceAccount admission controller](#serviceaccount-admission-controller)) adds a [projected volume](/docs/concepts/storage/projected-volumes/) to Pods, and this volume includes a token for Kubernetes API access. Here's an example of how that looks for a launched Pod: ```yaml ... - name: kube-api-access- projected: sources: - serviceAccountToken: path: token # must match the path the app expects - configMap: items: - key: ca.crt path: ca.crt name: kube-root-ca.crt - downwardAPI: items: - fieldRef: apiVersion: v1 fieldPath: metadata.namespace path: namespace ``` That manifest snippet defines a projected volume that consists of three sources. In this case, each source also represents a single path within that volume. The three sources are: 1. A `serviceAccountToken` source, that contains a token that the kubelet acquires from kube-apiserver. The kubelet fetches time-bound tokens using the TokenRequest API. A token served for a TokenRequest expires either when the pod is deleted or after a defined lifespan (by default, that is 1 hour). The kubelet also refreshes that token before the token expires. The token is bound to the specific Pod and has the kube-apiserver as its audience. This mechanism superseded an earlier mechanism that added a volume based on a Secret, where the Secret represented the ServiceAccount for the Pod, but did not expire. 1. A `configMap` source. The ConfigMap contains a bundle of certificate authority data. Pods can use these certificates to make sure that they are connecting to your cluster's kube-apiserver (and not to middlebox or an accidentally misconfigured peer). 1. A `downwardAPI` source that looks up the name of the namespace containing the Pod, and makes that name information available to application code running inside the Pod. Any container within the Pod that mounts this particular volume can access the above information. {{< note >}} There is no specific mechanism to invalidate a token issued via TokenRequest. If you no longer trust a bound service account token for a Pod, you can delete that Pod. Deleting a Pod expires its bound service account tokens. {{< /note >}} ## Manual Secret management for ServiceAccounts Versions of Kubernetes before v1.22 automatically created credentials for accessing the Kubernetes API. This older mechanism was based on creating token Secrets that could then be mounted into running Pods. In more recent versions, including Kubernetes v{{< skew currentVersion >}}, API credentials are [obtained directly](#bound-service-account-token-volume) using the [TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/) API, and are mounted into Pods using a projected volume. The tokens obtained using this method have bounded lifetimes, and are automatically invalidated when the Pod they are mounted into is deleted. You can still [manually create](/docs/tasks/configure-pod-container/configure-service-account/#manually-create-an-api-token-for-a-serviceaccount) a Secret to hold a service account token; for example, if you need a token that never expires. Once you manually create a Secret and link it to a ServiceAccount, the Kubernetes control plane automatically populates the token into that Secret. {{< note >}} Although the manual mechanism for creating a long-lived ServiceAccount token exists, using [TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/) to obtain short-lived API access tokens is recommended instead. {{< /note >}} ## Auto-generated legacy ServiceAccount token clean up {#auto-generated-legacy-serviceaccount-token-clean-up} Before version 1.24, Kubernetes automatically generated Secret-based tokens for ServiceAccounts. To distinguish between automatically generated tokens and manually created ones, Kubernetes checks for a reference | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/service-accounts-admin.md | main | kubernetes | [
-0.09205195307731628,
0.0228444654494524,
0.05307292565703392,
-0.04256195202469826,
0.018738875165581703,
-0.013884074985980988,
0.01774398796260357,
0.031124113127589226,
0.0934424102306366,
0.0554787740111351,
-0.051592227071523666,
-0.044543590396642685,
0.08485928177833557,
0.01925577... | 0.115599 |
ServiceAccount token exists, using [TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/) to obtain short-lived API access tokens is recommended instead. {{< /note >}} ## Auto-generated legacy ServiceAccount token clean up {#auto-generated-legacy-serviceaccount-token-clean-up} Before version 1.24, Kubernetes automatically generated Secret-based tokens for ServiceAccounts. To distinguish between automatically generated tokens and manually created ones, Kubernetes checks for a reference from the ServiceAccount's secrets field. If the Secret is referenced in the `secrets` field, it is considered an auto-generated legacy token. Otherwise, it is considered a manually created legacy token. For example: ```yaml apiVersion: v1 kind: ServiceAccount metadata: name: build-robot namespace: default secrets: - name: build-robot-secret # usually NOT present for a manually generated token ``` Beginning from version 1.29, legacy ServiceAccount tokens that were generated automatically will be marked as invalid if they remain unused for a certain period of time (set to default at one year). Tokens that continue to be unused for this defined period (again, by default, one year) will subsequently be purged by the control plane. If users use an invalidated auto-generated token, the token validator will 1. add an audit annotation for the key-value pair `authentication.k8s.io/legacy-token-invalidated: /`, 1. increment the `invalid\_legacy\_auto\_token\_uses\_total` metric count, 1. update the Secret label `kubernetes.io/legacy-token-last-used` with the new date, 1. return an error indicating that the token has been invalidated. When receiving this validation error, users can update the Secret to remove the `kubernetes.io/legacy-token-invalid-since` label to temporarily allow use of this token. Here's an example of an auto-generated legacy token that has been marked with the `kubernetes.io/legacy-token-last-used` and `kubernetes.io/legacy-token-invalid-since` labels: ```yaml apiVersion: v1 kind: Secret metadata: name: build-robot-secret namespace: default labels: kubernetes.io/legacy-token-last-used: 2022-10-24 kubernetes.io/legacy-token-invalid-since: 2023-10-25 annotations: kubernetes.io/service-account.name: build-robot type: kubernetes.io/service-account-token ``` ## Control plane details ### ServiceAccount controller A ServiceAccount controller manages the ServiceAccounts inside namespaces, and ensures a ServiceAccount named "default" exists in every active namespace. ### Token controller The service account token controller runs as part of `kube-controller-manager`. This controller acts asynchronously. It: - watches for ServiceAccount deletion and deletes all corresponding ServiceAccount token Secrets. - watches for ServiceAccount token Secret addition, and ensures the referenced ServiceAccount exists, and adds a token to the Secret if needed. - watches for Secret deletion and removes a reference from the corresponding ServiceAccount if needed. You must pass a service account private key file to the token controller in the `kube-controller-manager` using the `--service-account-private-key-file` flag. The private key is used to sign generated service account tokens. Similarly, you must pass the corresponding public key to the `kube-apiserver` using the `--service-account-key-file` flag. The public key will be used to verify the tokens during authentication. {{< feature-state feature\_gate\_name="ExternalServiceAccountTokenSigner" >}} An alternate setup to setting `--service-account-private-key-file` and `--service-account-key-file` flags is to configure an external JWT signer for [external ServiceAccount token signing and key management](#external-serviceaccount-token-signing-and-key-management). Note that these setups are mutually exclusive and cannot be configured together. ### ServiceAccount admission controller The modification of pods is implemented via a plugin called an [Admission Controller](/docs/reference/access-authn-authz/admission-controllers/). It is part of the API server. This admission controller acts synchronously to modify pods as they are created. When this plugin is active (and it is by default on most distributions), then it does the following when a Pod is created: 1. If the pod does not have a `.spec.serviceAccountName` set, the admission controller sets the name of the ServiceAccount for this incoming Pod to `default`. 1. The admission controller ensures that the ServiceAccount referenced by the incoming Pod exists. If there is no ServiceAccount with a matching name, the admission controller rejects the incoming Pod. That check applies even for the `default` ServiceAccount. 1. Provided that neither the ServiceAccount's `automountServiceAccountToken` field nor the Pod's `automountServiceAccountToken` field is set to | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/service-accounts-admin.md | main | kubernetes | [
-0.07329200953245163,
-0.02124645933508873,
0.058553118258714676,
-0.024494042620062828,
-0.00028310136985965073,
-0.0068717291578650475,
0.014927497133612633,
-0.03703303262591362,
0.13977552950382233,
0.046004075556993484,
-0.007392746862024069,
-0.045470159500837326,
0.010105585679411888,... | 0.14868 |
ensures that the ServiceAccount referenced by the incoming Pod exists. If there is no ServiceAccount with a matching name, the admission controller rejects the incoming Pod. That check applies even for the `default` ServiceAccount. 1. Provided that neither the ServiceAccount's `automountServiceAccountToken` field nor the Pod's `automountServiceAccountToken` field is set to `false`: - the admission controller mutates the incoming Pod, adding an extra {{< glossary\_tooltip text="volume" term\_id="volume" >}} that contains a token for API access. - the admission controller adds a `volumeMount` to each container in the Pod, skipping any containers that already have a volume mount defined for the path `/var/run/secrets/kubernetes.io/serviceaccount`. For Linux containers, that volume is mounted at `/var/run/secrets/kubernetes.io/serviceaccount`; on Windows nodes, the mount is at the equivalent path. 1. If the spec of the incoming Pod doesn't already contain any `imagePullSecrets`, then the admission controller adds `imagePullSecrets`, copying them from the `ServiceAccount`. ### Legacy ServiceAccount token tracking controller {{< feature-state feature\_gate\_name="LegacyServiceAccountTokenTracking" >}} This controller generates a ConfigMap called `kube-system/kube-apiserver-legacy-service-account-token-tracking` in the `kube-system` namespace. The ConfigMap records the timestamp when legacy service account tokens began to be monitored by the system. ### Legacy ServiceAccount token cleaner {{< feature-state feature\_gate\_name="LegacyServiceAccountTokenCleanUp" >}} The legacy ServiceAccount token cleaner runs as part of the `kube-controller-manager` and checks every 24 hours to see if any auto-generated legacy ServiceAccount token has not been used in a \*specified amount of time\*. If so, the cleaner marks those tokens as invalid. The cleaner works by first checking the ConfigMap created by the control plane (provided that `LegacyServiceAccountTokenTracking` is enabled). If the current time is a \*specified amount of time\* after the date in the ConfigMap, the cleaner then loops through the list of Secrets in the cluster and evaluates each Secret that has the type `kubernetes.io/service-account-token`. If a Secret meets all of the following conditions, the cleaner marks it as invalid: - The Secret is auto-generated, meaning that it is bi-directionally referenced by a ServiceAccount. - The Secret is not currently mounted by any pods. - The Secret has not been used in a \*specified amount of time\* since it was created or since it was last used. The cleaner marks a Secret invalid by adding a label called `kubernetes.io/legacy-token-invalid-since` to the Secret, with the current date as the value. If an invalid Secret is not used in a \*specified amount of time\*, the cleaner will delete it. {{< note >}} All the \*specified amount of time\* above defaults to one year. The cluster administrator can configure this value through the `--legacy-service-account-token-clean-up-period` command line argument for the `kube-controller-manager` component. {{< /note >}} ### TokenRequest API {{< feature-state for\_k8s\_version="v1.22" state="stable" >}} You use the [TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/) subresource of a ServiceAccount to obtain a time-bound token for that ServiceAccount. You don't need to call this to obtain an API token for use within a container, since the kubelet sets this up for you using a \_projected volume\_. If you want to use the TokenRequest API from `kubectl`, see [Manually create an API token for a ServiceAccount](/docs/tasks/configure-pod-container/configure-service-account/#manually-create-an-api-token-for-a-serviceaccount). The Kubernetes control plane (specifically, the ServiceAccount admission controller) adds a projected volume to Pods, and the kubelet ensures that this volume contains a token that lets containers authenticate as the right ServiceAccount. (This mechanism superseded an earlier mechanism that added a volume based on a Secret, where the Secret represented the ServiceAccount for the Pod but did not expire.) Here's an example of how that looks for a launched Pod: ```yaml ... - name: kube-api-access- projected: defaultMode: 420 # decimal equivalent of octal 0644 sources: - serviceAccountToken: expirationSeconds: 3607 path: token - configMap: items: - key: ca.crt path: ca.crt name: kube-root-ca.crt - downwardAPI: | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/service-accounts-admin.md | main | kubernetes | [
0.00037955111474730074,
-0.008143448270857334,
0.06978151202201843,
-0.0146830128505826,
0.01966196298599243,
-0.014890258200466633,
0.06673569232225418,
-0.002812744816765189,
0.1277327835559845,
0.0651143342256546,
0.042611319571733475,
-0.036163292825222015,
0.052281081676483154,
0.0115... | 0.151462 |
the Pod but did not expire.) Here's an example of how that looks for a launched Pod: ```yaml ... - name: kube-api-access- projected: defaultMode: 420 # decimal equivalent of octal 0644 sources: - serviceAccountToken: expirationSeconds: 3607 path: token - configMap: items: - key: ca.crt path: ca.crt name: kube-root-ca.crt - downwardAPI: items: - fieldRef: apiVersion: v1 fieldPath: metadata.namespace path: namespace ``` That manifest snippet defines a projected volume that combines information from three sources: 1. A `serviceAccountToken` source, that contains a token that the kubelet acquires from kube-apiserver. The kubelet fetches time-bound tokens using the TokenRequest API. A token served for a TokenRequest expires either when the pod is deleted or after a defined lifespan (by default, that is 1 hour). The token is bound to the specific Pod and has the kube-apiserver as its audience. 1. A `configMap` source. The ConfigMap contains a bundle of certificate authority data. Pods can use these certificates to make sure that they are connecting to your cluster's kube-apiserver (and not to a middlebox or an accidentally misconfigured peer). 1. A `downwardAPI` source. This `downwardAPI` volume makes the name of the namespace containing the Pod available to application code running inside the Pod. Any container within the Pod that mounts this volume can access the above information. ## Create additional API tokens {#create-token} {{< caution >}} Only create long-lived API tokens if the [token request](#tokenrequest-api) mechanism is not suitable. The token request mechanism provides time-limited tokens; because these expire, they represent a lower risk to information security. {{< /caution >}} To create a non-expiring, persisted API token for a ServiceAccount, create a Secret of type `kubernetes.io/service-account-token` with an annotation referencing the ServiceAccount. The control plane then generates a long-lived token and updates that Secret with that generated token data. Here is a sample manifest for such a Secret: {{% code\_sample file="secret/serviceaccount/mysecretname.yaml" %}} To create a Secret based on this example, run: ```shell kubectl -n examplens create -f https://k8s.io/examples/secret/serviceaccount/mysecretname.yaml ``` To see the details for that Secret, run: ```shell kubectl -n examplens describe secret mysecretname ``` The output is similar to: ``` Name: mysecretname Namespace: examplens Labels: Annotations: kubernetes.io/service-account.name=myserviceaccount kubernetes.io/service-account.uid=8a85c4c4-8483-11e9-bc42-526af7764f64 Type: kubernetes.io/service-account-token Data ==== ca.crt: 1362 bytes namespace: 9 bytes token: ... ``` If you launch a new Pod into the `examplens` namespace, it can use the `myserviceaccount` service-account-token Secret that you just created. {{< caution >}} Do not reference manually created Secrets in the `secrets` field of a ServiceAccount. Or the manually created Secrets will be cleaned if it is not used for a long time. Please refer to [auto-generated legacy ServiceAccount token clean up](#auto-generated-legacy-serviceaccount-token-clean-up). {{< /caution >}} ## Delete/invalidate a ServiceAccount token {#delete-token} ### Delete/invalidate a long-lived/legacy ServiceAccount token {#delete-legacy-token} If you know the name of the Secret that contains the token you want to remove: ```shell kubectl delete secret name-of-secret ``` Otherwise, first find the Secret for the ServiceAccount. ```shell # This assumes that you already have a namespace named 'examplens' kubectl -n examplens get serviceaccount/example-automated-thing -o yaml ``` The output is similar to: ```yaml apiVersion: v1 kind: ServiceAccount metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"v1","kind":"ServiceAccount","metadata":{"annotations":{},"name":"example-automated-thing","namespace":"examplens"}} creationTimestamp: "2019-07-21T07:07:07Z" name: example-automated-thing namespace: examplens resourceVersion: "777" selfLink: /api/v1/namespaces/examplens/serviceaccounts/example-automated-thing uid: f23fd170-66f2-4697-b049-e1e266b7f835 secrets: - name: example-automated-thing-token-zyxwv ``` Then, delete the Secret you now know the name of: ```shell kubectl -n examplens delete secret/example-automated-thing-token-zyxwv ``` ### Delete/invalidate a short-lived ServiceAccount token {#delete-short-lived} Short lived ServiceAccount tokens automatically expire after the time-limit specified during their creation. There is no central record of tokens issued, so there is no way to revoke individual tokens. If you have to revoke a short-lived token before its expiration, you can delete and re-create the ServiceAccount | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/service-accounts-admin.md | main | kubernetes | [
-0.02000322751700878,
-0.03838855400681496,
0.03697211295366287,
0.011290042661130428,
0.004437729250639677,
-0.04110255837440491,
-0.056522417813539505,
-0.011587636545300484,
0.1335296481847763,
0.053245946764945984,
-0.01689276099205017,
-0.009919377975165844,
-0.018711702898144722,
-0.... | 0.181326 |
token {#delete-short-lived} Short lived ServiceAccount tokens automatically expire after the time-limit specified during their creation. There is no central record of tokens issued, so there is no way to revoke individual tokens. If you have to revoke a short-lived token before its expiration, you can delete and re-create the ServiceAccount it is associated to. This will change its UID and hence invalidate \*\*all\*\* ServiceAccount tokens that were created for it. ## External ServiceAccount token signing and key management {{< feature-state feature\_gate\_name="ExternalServiceAccountTokenSigner" >}} The kube-apiserver can be configured to use external signer for token signing and token verifying key management. This feature enables kubernetes distributions to integrate with key management solutions of their choice (for example, HSMs, cloud KMSes) for service account credential signing and verification. To configure kube-apiserver to use external-jwt-signer set the `--service-account-signing-endpoint` flag to the location of a Unix domain socket (UDS) on a filesystem, or be prefixed with an @ symbol and name a UDS in the abstract socket namespace. At the configured UDS shall be an RPC server which implements an `ExternalJWTSigner` gRPC service. The external-jwt-signer must be healthy and be ready to serve supported service account keys for the kube-apiserver to start. {{< note >}} The kube-apiserver flags `--service-account-key-file` and `--service-account-signing-key-file` will continue to be used for reading from files unless `--service-account-signing-endpoint` is set; they are mutually exclusive ways of supporting JWT signing and authentication. {{< /note >}} An external signer provides a `v1.ExternalJWTSigner` gRPC service that implements 3 methods: ### Metadata Metadata is meant to be called once by `kube-apiserver` on startup. This enables the external signer to share metadata with kube-apiserver, like the max token lifetime that signer supports. ```proto rpc Metadata(MetadataRequest) returns (MetadataResponse) {} message MetadataRequest {} message MetadataResponse { // used by kube-apiserver for defaulting/validation of JWT lifetime while accounting for configuration flag values: // 1. `--service-account-max-token-expiration` // 2. `--service-account-extend-token-expiration` // // \* If `--service-account-max-token-expiration` is greater than `max\_token\_expiration\_seconds`, kube-apiserver treats that as misconfiguration and exits. // \* If `--service-account-max-token-expiration` is not explicitly set, kube-apiserver defaults to `max\_token\_expiration\_seconds`. // \* If `--service-account-extend-token-expiration` is true, the extended expiration is `min(1 year, max\_token\_expiration\_seconds)`. // // `max\_token\_expiration\_seconds` must be at least 600s. int64 max\_token\_expiration\_seconds = 1; } ``` ### FetchKeys FetchKeys returns the set of public keys that are trusted to sign Kubernetes service account tokens. Kube-apiserver will call this RPC: \* Every time it tries to validate a JWT from the service account issuer with an unknown key ID, and \* Periodically, so it can serve reasonably-up-to-date keys from the OIDC JWKs endpoint. ```proto rpc FetchKeys(FetchKeysRequest) returns (FetchKeysResponse) {} message FetchKeysRequest {} message FetchKeysResponse { repeated Key keys = 1; // The timestamp when this data was pulled from the authoritative source of // truth for verification keys. // kube-apiserver can export this from metrics, to enable end-to-end SLOs. google.protobuf.Timestamp data\_timestamp = 2; // refresh interval for verification keys to pick changes if any. // any value <= 0 is considered a misconfiguration. int64 refresh\_hint\_seconds = 3; } message Key { // A unique identifier for this key. // Length must be <=1024. string key\_id = 1; // The public key, PKIX-serialized. // must be a public key supported by kube-apiserver (currently RSA 256 or ECDSA 256/384/521) bytes key = 2; // Set only for keys that are not used to sign bound tokens. // eg: supported keys for legacy tokens. // If set, key is used for verification but excluded from OIDC discovery docs. // if set, external signer should not use this key to sign a JWT. bool exclude\_from\_oidc\_discovery = 3; } ``` ### Sign Sign takes a serialized JWT payload, | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/service-accounts-admin.md | main | kubernetes | [
-0.04483536258339882,
-0.006639967206865549,
0.08341220766305923,
-0.03447508439421654,
-0.03019218146800995,
-0.018445471301674843,
0.0018769982270896435,
-0.02061278186738491,
0.13933873176574707,
0.05579717457294464,
0.0003877786220982671,
-0.02791438065469265,
0.05406418815255165,
-0.0... | 0.079232 |
tokens. // eg: supported keys for legacy tokens. // If set, key is used for verification but excluded from OIDC discovery docs. // if set, external signer should not use this key to sign a JWT. bool exclude\_from\_oidc\_discovery = 3; } ``` ### Sign Sign takes a serialized JWT payload, and returns the serialized header and signature. `kube-apiserver` then assembles the JWT from the header, payload, and signature. ```proto rpc Sign(SignJWTRequest) returns (SignJWTResponse) {} message SignJWTRequest { // URL-safe base64 wrapped payload to be signed. // Exactly as it appears in the second segment of the JWT string claims = 1; } message SignJWTResponse { // header must contain only alg, kid, typ claims. // typ must be “JWT”. // kid must be non-empty, <=1024 characters, and its corresponding public key should not be excluded from OIDC discovery. // alg must be one of the algorithms supported by kube-apiserver (currently RS256, ES256, ES384, ES512). // header cannot have any additional data that kube-apiserver does not recognize. // Already wrapped in URL-safe base64, exactly as it appears in the first segment of the JWT. string header = 1; // The signature for the JWT. // Already wrapped in URL-safe base64, exactly as it appears in the final segment of the JWT. string signature = 2; } ``` ## Clean up If you created a namespace `examplens` to experiment with, you can remove it: ```shell kubectl delete namespace examplens ``` ## {{% heading "whatsnext" %}} - Read more details about [projected volumes](/docs/concepts/storage/projected-volumes/). | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/service-accounts-admin.md | main | kubernetes | [
-0.0667000412940979,
0.029862256720662117,
0.059572190046310425,
-0.0354909710586071,
0.011380833573639393,
-0.09394031763076782,
0.007407613098621368,
0.028031000867486,
0.07796832919120789,
-0.040471501648426056,
-0.03104322962462902,
-0.0528390109539032,
0.02899649739265442,
-0.02293637... | 0.096559 |
{{< feature-state state="stable" for\_k8s\_version="v1.30" >}} This page provides an overview of Validating Admission Policy. ## What is Validating Admission Policy? Validating admission policies offer a declarative, in-process alternative to validating admission webhooks. Validating admission policies use the Common Expression Language (CEL) to declare the validation rules of a policy. Validation admission policies are highly configurable, enabling policy authors to define policies that can be parameterized and scoped to resources as needed by cluster administrators. ## What Resources Make a Policy A policy is generally made up of three resources: - The `ValidatingAdmissionPolicy` describes the abstract logic of a policy (think: "this policy makes sure a particular label is set to a particular value"). - A parameter resource provides information to a ValidatingAdmissionPolicy to make it a concrete statement (think "the `owner` label must be set to something that ends in `.company.com`"). A native type such as ConfigMap or a CRD defines the schema of a parameter resource. `ValidatingAdmissionPolicy` objects specify what Kind they are expecting for their parameter resource. - A `ValidatingAdmissionPolicyBinding` links the above resources together and provides scoping. If you only want to require an `owner` label to be set for `Pods`, the binding is where you would specify this restriction. At least a `ValidatingAdmissionPolicy` and a corresponding `ValidatingAdmissionPolicyBinding` must be defined for a policy to have an effect. If a `ValidatingAdmissionPolicy` does not need to be configured via parameters, simply leave `spec.paramKind` in `ValidatingAdmissionPolicy` not specified. ## Getting Started with Validating Admission Policy Validating Admission Policy is part of the cluster control-plane. You should write and deploy them with great caution. The following describes how to quickly experiment with Validating Admission Policy. ### Creating a ValidatingAdmissionPolicy The following is an example of a ValidatingAdmissionPolicy. {{% code\_sample language="yaml" file="validatingadmissionpolicy/basic-example-policy.yaml" %}} `spec.validations` contains CEL expressions which use the [Common Expression Language (CEL)](https://github.com/google/cel-spec) to validate the request. If an expression evaluates to false, the validation check is enforced according to the `spec.failurePolicy` field. {{< note >}} You can quickly test CEL expressions in [CEL Playground](https://playcel.undistro.io). {{< /note >}} To configure a validating admission policy for use in a cluster, a binding is required. The following is an example of a ValidatingAdmissionPolicyBinding.: {{% code\_sample language="yaml" file="validatingadmissionpolicy/basic-example-binding.yaml" %}} When trying to create a deployment with replicas set not satisfying the validation expression, an error will return containing message: ```none ValidatingAdmissionPolicy 'demo-policy.example.com' with binding 'demo-binding-test.example.com' denied request: failed expression: object.spec.replicas <= 5 ``` The above provides a simple example of using ValidatingAdmissionPolicy without a parameter configured. #### Validation actions Each `ValidatingAdmissionPolicyBinding` must specify one or more `validationActions` to declare how `validations` of a policy are enforced. The supported `validationActions` are: - `Deny`: Validation failure results in a denied request. - `Warn`: Validation failure is reported to the request client as a [warning](/blog/2020/09/03/warnings/). - `Audit`: Validation failure is included in the audit event for the API request. For example, to both warn clients about a validation failure and to audit the validation failures, use: ```yaml validationActions: [Warn, Audit] ``` `Deny` and `Warn` may not be used together since this combination needlessly duplicates the validation failure both in the API response body and the HTTP warning headers. A `validation` that evaluates to false is always enforced according to these actions. Failures defined by the `failurePolicy` are enforced according to these actions only if the `failurePolicy` is set to `Fail` (or not specified), otherwise the failures are ignored. See [Audit Annotations: validation failures](/docs/reference/labels-annotations-taints/audit-annotations/#validation-policy-admission-k8s-io-validation-failure) for more details about the validation failure audit annotation. ### Parameter resources Parameter resources allow a policy configuration to be separate from its definition. A policy can define paramKind, which outlines GVK of | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/validating-admission-policy.md | main | kubernetes | [
-0.05071774497628212,
0.044538114219903946,
-0.007556650321930647,
-0.02770599164068699,
0.064007468521595,
-0.010385843925178051,
0.07367806881666183,
-0.009578125551342964,
-0.08397836238145828,
0.00017648479843046516,
-0.015777988359332085,
-0.05640820041298866,
0.07535933703184128,
0.0... | 0.159556 |
is set to `Fail` (or not specified), otherwise the failures are ignored. See [Audit Annotations: validation failures](/docs/reference/labels-annotations-taints/audit-annotations/#validation-policy-admission-k8s-io-validation-failure) for more details about the validation failure audit annotation. ### Parameter resources Parameter resources allow a policy configuration to be separate from its definition. A policy can define paramKind, which outlines GVK of the parameter resource, and then a policy binding ties a policy by name (via policyName) to a particular parameter resource via paramRef. If parameter configuration is needed, the following is an example of a ValidatingAdmissionPolicy with parameter configuration. {{% code\_sample language="yaml" file="validatingadmissionpolicy/policy-with-param.yaml" %}} The `spec.paramKind` field of the ValidatingAdmissionPolicy specifies the kind of resources used to parameterize this policy. For this example, it is configured by ReplicaLimit custom resources. Note in this example how the CEL expression references the parameters via the CEL params variable, e.g. `params.maxReplicas`. `spec.matchConstraints` specifies what resources this policy is designed to validate. Note that the native types such like `ConfigMap` could also be used as parameter reference. The `spec.validations` fields contain CEL expressions. If an expression evaluates to false, the validation check is enforced according to the `spec.failurePolicy` field. The validating admission policy author is responsible for providing the ReplicaLimit parameter CRD. To configure an validating admission policy for use in a cluster, a binding and parameter resource are created. The following is an example of a ValidatingAdmissionPolicyBinding that uses a \*\*cluster-wide\*\* param - the same param will be used to validate every resource request that matches the binding: {{% code\_sample language="yaml" file="validatingadmissionpolicy/binding-with-param.yaml" %}} Notice this binding applies a parameter to the policy for all resources which are in the `test` environment. The parameter resource could be as following: {{% code\_sample language="yaml" file="validatingadmissionpolicy/replicalimit-param.yaml" %}} This policy parameter resource limits deployments to a max of 3 replicas. An admission policy may have multiple bindings. To bind all other environments to have a maxReplicas limit of 100, create another ValidatingAdmissionPolicyBinding: {{% code\_sample language="yaml" file="validatingadmissionpolicy/binding-with-param-prod.yaml" %}} Notice this binding applies a different parameter to resources which are not in the `test` environment. And have a parameter resource: {{% code\_sample language="yaml" file="validatingadmissionpolicy/replicalimit-param-prod.yaml" %}} For each admission request, the API server evaluates CEL expressions of each (policy, binding, param) combination that match the request. For a request to be admitted it must pass \*\*all\*\* evaluations. If multiple bindings match the request, the policy will be evaluated for each, and they must all pass evaluation for the policy to be considered passed. If multiple parameters match a single binding, the policy rules will be evaluated for each param, and they too must all pass for the binding to be considered passed. Bindings can have overlapping match criteria. The policy is evaluated for each matching binding-parameter combination. A policy may even be evaluated multiple times if multiple bindings match it, or a single binding that matches multiple parameters. The params object representing a parameter resource will not be set if a parameter resource has not been bound, so for policies requiring a parameter resource, it can be useful to add a check to ensure one has been bound. A parameter resource will not be bound and `params` will be null if `paramKind` of the policy, or `paramRef` of the binding are not specified. For the use cases requiring parameter configuration, we recommend to add a param check in `spec.validations[0].expression`: ``` - expression: "params != null" message: "params missing but required to bind to this policy" ``` #### Optional parameters It can be convenient to be able to have optional parameters as part of a parameter resource, and only validate them if present. CEL provides `has()`, which checks if the key passed to | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/validating-admission-policy.md | main | kubernetes | [
-0.07452508062124252,
0.04895687475800514,
-0.007678085472434759,
-0.01803874969482422,
0.028212158009409904,
-0.013613547198474407,
0.1095583438873291,
-0.036514367908239365,
-0.03310173749923706,
-0.031007470563054085,
-0.018699156120419502,
-0.06926730275154114,
0.08649130910634995,
0.0... | 0.05666 |
"params != null" message: "params missing but required to bind to this policy" ``` #### Optional parameters It can be convenient to be able to have optional parameters as part of a parameter resource, and only validate them if present. CEL provides `has()`, which checks if the key passed to it exists. CEL also implements Boolean short-circuiting. If the first half of a logical OR evaluates to true, it won’t evaluate the other half (since the result of the entire OR will be true regardless). Combining the two, we can provide a way to validate optional parameters: `!has(params.optionalNumber) || (params.optionalNumber >= 5 && params.optionalNumber <= 10)` Here, we first check that the optional parameter is present with `!has(params.optionalNumber)`. - If `optionalNumber` hasn’t been defined, then the expression short-circuits since `!has(params.optionalNumber)` will evaluate to true. - If `optionalNumber` has been defined, then the latter half of the CEL expression will be evaluated, and optionalNumber will be checked to ensure that it contains a value between 5 and 10 inclusive. #### Per-namespace Parameters As the author of a ValidatingAdmissionPolicy and its ValidatingAdmissionPolicyBinding, you can choose to specify cluster-wide, or per-namespace parameters. If you specify a `namespace` for the binding's `paramRef`, the control plane only searches for parameters in that namespace. However, if `namespace` is not specified in the ValidatingAdmissionPolicyBinding, the API server can search for relevant parameters in the namespace that a request is against. For example, if you make a request to modify a ConfigMap in the `default` namespace and there is a relevant ValidatingAdmissionPolicyBinding with no `namespace` set, then the API server looks for a parameter object in `default`. This design enables policy configuration that depends on the namespace of the resource being manipulated, for more fine-tuned control. #### Parameter selector In addition to specify a parameter in a binding by `name`, you may choose instead to specify label selector, such that all resources of the policy's `paramKind`, and the param's `namespace` (if applicable) that match the label selector are selected for evaluation. See {{< glossary\_tooltip text="selector" term\_id="selector">}} for more information on how label selectors match resources. If multiple parameters are found to meet the condition, the policy's rules are evaluated for each parameter found and the results will be ANDed together. If `namespace` is provided, only objects of the `paramKind` in the provided namespace are eligible for selection. Otherwise, when `namespace` is empty and `paramKind` is namespace-scoped, the `namespace` used in the request being admitted will be used. #### Authorization checks {#authorization-check} We introduced the authorization check for parameter resources. User is expected to have `read` access to the resources referenced by `paramKind` in `ValidatingAdmissionPolicy` and `paramRef` in `ValidatingAdmissionPolicyBinding`. Note that if a resource in `paramKind` fails resolving via the restmapper, `read` access to all resources of groups is required. #### `paramRef` The `paramRef` field specifies the parameter resource used by the policy. It has the following fields: - \*\*name\*\*: The name of the parameter resource. - \*\*namespace\*\*: The namespace of the parameter resource. - \*\*selector\*\*: A label selector to match multiple parameter resources. - \*\*parameterNotFoundAction\*\*: (Required) Controls the behavior when the specified parameters are not found. - \*\*Allowed Values\*\*: - \*\*`Allow`\*\*: The absence of matched parameters is treated as a successful validation by the binding. - \*\*`Deny`\*\*: The absence of matched parameters is subject to the `failurePolicy` of the policy. One of `name` or `selector` must be set, but not both. {{< note >}} The `parameterNotFoundAction` field in `paramRef` is \*\*required\*\*. It specifies the action to take when no parameters are found matching the `paramRef`. If not specified, the policy binding may be considered invalid and will be | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/validating-admission-policy.md | main | kubernetes | [
-0.050291888415813446,
0.028842797502875328,
0.018164105713367462,
0.0027831646148115396,
0.01458768267184496,
0.05275430157780647,
0.055221833288669586,
0.017921151593327522,
-0.01904834248125553,
-0.0433698371052742,
0.011186178773641586,
-0.1002514660358429,
0.06347426027059555,
0.05738... | -0.001639 |
the policy. One of `name` or `selector` must be set, but not both. {{< note >}} The `parameterNotFoundAction` field in `paramRef` is \*\*required\*\*. It specifies the action to take when no parameters are found matching the `paramRef`. If not specified, the policy binding may be considered invalid and will be ignored or could lead to unexpected behavior. - \*\*`Allow`\*\*: If set to `Allow`, and no parameters are found, the binding treats the absence of parameters as a successful validation, and the policy is considered to have passed. - \*\*`Deny`\*\*: If set to `Deny`, and no parameters are found, the binding enforces the `failurePolicy` of the policy. If the `failurePolicy` is `Fail`, the request is rejected. Make sure to set `parameterNotFoundAction` according to the desired behavior when parameters are missing. {{< /note >}} #### Handling Missing Parameters with `parameterNotFoundAction` When using `paramRef` with a selector, it's possible that no parameters match the selector. The `parameterNotFoundAction` field determines how the binding behaves in this scenario. \*\*Example:\*\* ```yaml apiVersion: admissionregistration.k8s.io/v1alpha1 kind: ValidatingAdmissionPolicyBinding metadata: name: example-binding spec: policyName: example-policy paramRef: selector: matchLabels: environment: test parameterNotFoundAction: Allow validationActions: - Deny ``` ### Failure Policy `failurePolicy` defines how mis-configurations and CEL expressions evaluating to error from the admission policy are handled. Allowed values are `Ignore` or `Fail`. - `Ignore` means that an error calling the ValidatingAdmissionPolicy is ignored and the API request is allowed to continue. - `Fail` means that an error calling the ValidatingAdmissionPolicy causes the admission to fail and the API request to be rejected. Note that the `failurePolicy` is defined inside `ValidatingAdmissionPolicy`: {{% code\_sample language="yaml" file="validatingadmissionpolicy/failure-policy-ignore.yaml" %}} ### Validation Expression `spec.validations[i].expression` represents the expression which will be evaluated by CEL. To learn more, see the [CEL language specification](https://github.com/google/cel-spec) CEL expressions have access to the contents of the Admission request/response, organized into CEL variables as well as some other useful variables: - 'object' - The object from the incoming request. The value is null for DELETE requests. - 'oldObject' - The existing object. The value is null for CREATE requests. - 'request' - Attributes of the [admission request](/docs/reference/config-api/apiserver-admission.v1/#admission-k8s-io-v1-AdmissionRequest). - 'params' - Parameter resource referred to by the policy binding being evaluated. The value is null if `ParamKind` is not specified. - `namespaceObject` - The namespace, as a Kubernetes resource, that the incoming object belongs to. The value is null if the incoming object is cluster-scoped. - `authorizer` - A CEL Authorizer. May be used to perform authorization checks for the principal (authenticated user) of the request. See [AuthzSelectors](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#AuthzSelectors) and [Authz](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz) in the Kubernetes CEL library documentation for more details. - `authorizer.requestResource` - A shortcut for an authorization check configured with the request resource (group, resource, (subresource), namespace, name). In CEL expressions, variables like `object` and `oldObject` are strongly-typed. You can access any field in the object's schema, such as `object.metadata.labels` and fields in `spec`. For any Kubernetes object, including schemaless Custom Resources, CEL guarantees access to a minimal set of properties: `apiVersion`, `kind`, `metadata.name`, and `metadata.generateName`. Equality on arrays with list type of 'set' or 'map' ignores element order, i.e. [1, 2] == [2, 1]. Concatenation on arrays with x-kubernetes-list-type use the semantics of the list type: - 'set': `X + Y` performs a union where the array positions of all elements in `X` are preserved and non-intersecting elements in `Y` are appended, retaining their partial order. - 'map': `X + Y` performs a merge where the array positions of all keys in `X` are preserved but the values are overwritten by values in `Y` when the key sets of `X` and `Y` intersect. Elements in `Y` with non-intersecting keys are appended, retaining their | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/validating-admission-policy.md | main | kubernetes | [
-0.07593661546707153,
0.026622481644153595,
-0.034968309104442596,
0.012800577096641064,
0.0009047382045537233,
0.011218034662306309,
0.04984579607844353,
-0.005340107716619968,
-0.015792876482009888,
0.01598309725522995,
0.030357956886291504,
-0.07568057626485825,
0.05043402686715126,
0.0... | 0.034306 |
their partial order. - 'map': `X + Y` performs a merge where the array positions of all keys in `X` are preserved but the values are overwritten by values in `Y` when the key sets of `X` and `Y` intersect. Elements in `Y` with non-intersecting keys are appended, retaining their partial order. #### Validation expression examples | Expression | Purpose | |----------------------------------------------------------------------------------------------| ------------ | | `object.minReplicas <= object.replicas && object.replicas <= object.maxReplicas` | Validate that the three fields defining replicas are ordered appropriately | | `'Available' in object.stateCounts` | Validate that an entry with the 'Available' key exists in a map | | `(size(object.list1) == 0) != (size(object.list2) == 0)` | Validate that one of two lists is non-empty, but not both | | `!('MY_KEY' in object.map1) || object['MY_KEY'].matches('^[a-zA-Z]*$')` | Validate the value of a map for a specific key, if it is in the map | | `object.envars.filter(e, e.name == 'MY\_ENV').all(e, e.value.matches('^[a-zA-Z]\*$')` | Validate the 'value' field of a listMap entry where key field 'name' is 'MY\_ENV' | | `has(object.expired) && object.created + object.ttl < object.expired` | Validate that 'expired' date is after a 'create' date plus a 'ttl' duration | | `object.health.startsWith('ok')` | Validate a 'health' string field has the prefix 'ok' | | `object.widgets.exists(w, w.key == 'x' && w.foo < 10)` | Validate that the 'foo' property of a listMap item with a key 'x' is less than 10 | | `type(object) == string ? object == '100%' : object == 1000` | Validate an int-or-string field for both the int and string cases | | `object.metadata.name.startsWith(object.prefix)` | Validate that an object's name has the prefix of another field value | | `object.set1.all(e, !(e in object.set2))` | Validate that two listSets are disjoint | | `size(object.names) == size(object.details) && object.names.all(n, n in object.details)` | Validate the 'details' map is keyed by the items in the 'names' listSet | | `size(object.clusters.filter(c, c.name == object.primary)) == 1` | Validate that the 'primary' property has one and only one occurrence in the 'clusters' listMap | Read [Supported evaluation on CEL](https://github.com/google/cel-spec/blob/v0.6.0/doc/langdef.md#evaluation) for more information about CEL rules. `spec.validation[i].reason` represents a machine-readable description of why this validation failed. If this is the first validation in the list to fail, this reason, as well as the corresponding HTTP response code, are used in the HTTP response to the client. The currently supported reasons are: `Unauthorized`, `Forbidden`, `Invalid`, `RequestEntityTooLarge`. If not set, `StatusReasonInvalid` is used in the response to the client. ### Matching requests: `matchConditions` You can define \_match conditions\_ for a `ValidatingAdmissionPolicy` if you need fine-grained request filtering. These conditions are useful if you find that match rules, `objectSelectors` and `namespaceSelectors` still doesn't provide the filtering you want. Match conditions are [CEL expressions](/docs/reference/using-api/cel/). All match conditions must evaluate to true for the resource to be evaluated. Here is an example illustrating a few different uses for match conditions: {{% code\_sample file="access/validating-admission-policy-match-conditions.yaml" %}} Match conditions have access to the same CEL variables as validation expressions. In the event of an error evaluating a match condition the policy is not evaluated. Whether to reject the request is determined as follows: 1. If \*\*any\*\* match condition evaluated to `false` (regardless of other errors), the API server skips the policy. 2. Otherwise: - for [`failurePolicy: Fail`](#failure-policy), reject the request (without evaluating the policy). - for [`failurePolicy: Ignore`](#failure-policy), proceed with the request but skip the policy. ### Audit annotations `auditAnnotations` may be used to include audit annotations in the audit event of the API request. For example, here is an admission policy with an audit annotation: {{% code\_sample file="access/validating-admission-policy-audit-annotation.yaml" %}} When an API request is validated with this | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/validating-admission-policy.md | main | kubernetes | [
-0.017376119270920753,
0.009803482331335545,
0.035244401544332504,
-0.021637439727783203,
-0.018046708777546883,
-0.012820704840123653,
-0.014647970907390118,
-0.0514785572886467,
0.022992441430687904,
0.026509372517466545,
0.004574431572109461,
0.041475750505924225,
0.02470638044178486,
-... | 0.034011 |
proceed with the request but skip the policy. ### Audit annotations `auditAnnotations` may be used to include audit annotations in the audit event of the API request. For example, here is an admission policy with an audit annotation: {{% code\_sample file="access/validating-admission-policy-audit-annotation.yaml" %}} When an API request is validated with this admission policy, the resulting audit event will look like: ``` # the audit event recorded { "kind": "Event", "apiVersion": "audit.k8s.io/v1", "annotations": { "demo-policy.example.com/high-replica-count": "Deployment spec.replicas set to 128" # other annotations ... } # other fields ... } ``` In this example the annotation will only be included if the `spec.replicas` of the Deployment is more than 50, otherwise the CEL expression evaluates to null and the annotation will not be included. Note that audit annotation keys are prefixed by the name of the `ValidatingAdmissionPolicy` and a `/`. If another admission controller, such as an admission webhook, uses the exact same audit annotation key, the value of the first admission controller to include the audit annotation will be included in the audit event and all other values will be ignored. ### Message expression To return a more friendly message when the policy rejects a request, we can use a CEL expression to composite a message with `spec.validations[i].messageExpression`. Similar to the validation expression, a message expression has access to `object`, `oldObject`, `request`, `params`, and `namespaceObject`. Unlike validations, message expression must evaluate to a string. For example, to better inform the user of the reason of denial when the policy refers to a parameter, we can have the following validation: {{% code\_sample file="access/deployment-replicas-policy.yaml" %}} After creating a params object that limits the replicas to 3 and setting up the binding, when we try to create a deployment with 5 replicas, we will receive the following message. ``` $ kubectl create deploy --image=nginx nginx --replicas=5 error: failed to create deployment: deployments.apps "nginx" is forbidden: ValidatingAdmissionPolicy 'deploy-replica-policy.example.com' with binding 'demo-binding-test.example.com' denied request: object.spec.replicas must be no greater than 3 ``` This is more informative than a static message of "too many replicas". The message expression takes precedence over the static message defined in `spec.validations[i].message` if both are defined. However, if the message expression fails to evaluate, the static message will be used instead. Additionally, if the message expression evaluates to a multi-line string, the evaluation result will be discarded and the static message will be used if present. Note that static message is validated against multi-line strings. ### Type checking When a policy definition is created or updated, the validation process parses the expressions it contains and reports any syntax errors, rejecting the definition if any errors are found. Afterward, the referred variables are checked for type errors, including missing fields and type confusion, against the matched types of `spec.matchConstraints`. The result of type checking can be retrieved from `status.typeChecking`. The presence of `status.typeChecking` indicates the completion of type checking, and an empty `status.typeChecking` means that no errors were detected. For example, given the following policy definition: {{< code\_sample language="yaml" file="validatingadmissionpolicy/typechecking.yaml" >}} The status will yield the following information: ```yaml status: typeChecking: expressionWarnings: - fieldRef: spec.validations[0].expression warning: |- apps/v1, Kind=Deployment: ERROR: :1:7: undefined field 'replicas' | object.replicas > 1 | ......^ ``` If multiple resources are matched in `spec.matchConstraints`, all of matched resources will be checked against. For example, the following policy definition {{% code\_sample language="yaml" file="validatingadmissionpolicy/typechecking-multiple-match.yaml" %}} will have multiple types and type checking result of each type in the warning message. ```yaml status: typeChecking: expressionWarnings: - fieldRef: spec.validations[0].expression warning: |- apps/v1, Kind=Deployment: ERROR: :1:7: undefined field 'replicas' | object.replicas > 1 | ......^ apps/v1, Kind=ReplicaSet: ERROR: :1:7: undefined field 'replicas' | object.replicas | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/validating-admission-policy.md | main | kubernetes | [
-0.023017484694719315,
0.13734252750873566,
0.053319528698921204,
0.00014361525245476514,
0.09360611438751221,
-0.0011407894780859351,
0.058945558965206146,
-0.05177147313952446,
0.0608631856739521,
0.04513176903128624,
-0.00764503376558423,
-0.13216987252235413,
0.02588575892150402,
0.069... | 0.083739 |
code\_sample language="yaml" file="validatingadmissionpolicy/typechecking-multiple-match.yaml" %}} will have multiple types and type checking result of each type in the warning message. ```yaml status: typeChecking: expressionWarnings: - fieldRef: spec.validations[0].expression warning: |- apps/v1, Kind=Deployment: ERROR: :1:7: undefined field 'replicas' | object.replicas > 1 | ......^ apps/v1, Kind=ReplicaSet: ERROR: :1:7: undefined field 'replicas' | object.replicas > 1 | ......^ ``` Type Checking has the following limitation: - No wildcard matching. If `spec.matchConstraints.resourceRules` contains `"\*"` in any of `apiGroups`, `apiVersions` or `resources`, the types that `"\*"` matches will not be checked. - The number of matched types is limited to 10. This is to prevent a policy that manually specifying too many types. to consume excessive computing resources. In the order of ascending group, version, and then resource, 11th combination and beyond are ignored. - Type Checking does not affect the policy behavior in any way. Even if the type checking detects errors, the policy will continue to evaluate. If errors do occur during evaluate, the failure policy will decide its outcome. - Type Checking does not apply to CRDs, including matched CRD types and reference of paramKind. The support for CRDs will come in future release. ### Variable composition If an expression grows too complicated, or part of the expression is reusable and computationally expensive to evaluate, you can extract some part of the expressions into variables. A variable is a named expression that can be referred later in `variables` in other expressions. ```yaml spec: variables: - name: foo expression: "'foo' in object.spec.metadata.labels ? object.spec.metadata.labels['foo'] : 'default'" validations: - expression: variables.foo == 'bar' ``` A variable is lazily evaluated when it is first referred. Any error that occurs during the evaluation will be reported during the evaluation of the referring expression. Both the result and potential error are memorized and count only once towards the runtime cost. The order of variables are important because a variable can refer to other variables that are defined before it. This ordering prevents circular references. The following is a more complex example of enforcing that image repo names match the environment defined in its namespace. {{< code\_sample file="access/image-matches-namespace-environment.policy.yaml" >}} With the policy bound to the namespace `default`, which is labeled `environment: prod`, the following attempt to create a deployment would be rejected. ```shell kubectl create deploy --image=dev.example.com/nginx invalid ``` The error message is similar to this. ```console error: failed to create deployment: deployments.apps "invalid" is forbidden: ValidatingAdmissionPolicy 'image-matches-namespace-environment.policy.example.com' with binding 'demo-binding-test.example.com' denied request: only prod images are allowed in namespace default ``` ## API kinds exempt from admission validation There are certain API kinds that are exempt from admission-time validation checks. For example, you can't create a ValidatingAdmissionPolicy that prevents changes to ValidatingAdmissionPolicyBindings. The list of exempt API kinds is: \* [ValidatingAdmissionPolicies]({{< relref "/docs/reference/kubernetes-api/policy-resources/validating-admission-policy-v1/" >}}) \* [ValidatingAdmissionPolicyBindings]({{< relref "/docs/reference/kubernetes-api/policy-resources/validating-admission-policy-binding-v1/" >}}) \* MutatingAdmissionPolicies \* MutatingAdmissionPolicyBindings \* [TokenReviews]({{< relref "/docs/reference/kubernetes-api/authentication-resources/token-review-v1/" >}}) \* [LocalSubjectAccessReviews]({{< relref "/docs/reference/kubernetes-api/authorization-resources/local-subject-access-review-v1/" >}}) \* [SelfSubjectAccessReviews]({{< relref "/docs/reference/kubernetes-api/authorization-resources/self-subject-access-review-v1/" >}}) \* [SelfSubjectReviews]({{< relref "/docs/reference/kubernetes-api/authentication-resources/self-subject-review-v1/" >}}) | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/validating-admission-policy.md | main | kubernetes | [
-0.010584810748696327,
0.017592545598745346,
0.04105319455265999,
-0.029034961014986038,
0.06872615218162537,
-0.035025451332330704,
0.06236371397972107,
-0.05150245502591133,
-0.0015813452191650867,
0.017847489565610886,
-0.03195221349596977,
-0.08248662203550339,
0.02402501367032528,
0.0... | 0.060206 |
{{< feature-state for\_k8s\_version="v1.34" state="beta" >}} This page provides an overview of \_MutatingAdmissionPolicies\_. MutatingAdmissionPolicies allow you to change what happens when someone writes a change to the Kubernetes API. If you want to use declarative policies just to prevent a particular kind of change to resources (for example: protecting platform namespaces from deletion), [ValidatingAdmissionPolicy](/docs/reference/access-authn-authz/validating-admission-policy/) is a simpler and more effective alternative. To use the feature, enable the `MutatingAdmissionPolicy` feature gate (which is off by default) and set `--runtime-config=admissionregistration.k8s.io/v1beta1=true` on the kube-apiserver. ## What are MutatingAdmissionPolicies? Mutating admission policies offer a declarative, in-process alternative to mutating admission webhooks. Mutating admission policies use the Common Expression Language (CEL) to declare mutations to resources. Mutations can be defined either with an \*apply configuration\* that is merged using the [server side apply merge strategy](/docs/reference/using-api/server-side-apply/#merge-strategy), or a [JSON patch](https://jsonpatch.com/). Mutating admission policies are highly configurable, enabling policy authors to define policies that can be parameterized and scoped to resources as needed by cluster administrators. ## What resources make a policy A policy is generally made up of three resources: - The MutatingAdmissionPolicy describes the abstract logic of a policy (think: "this policy sets a particular label to a particular value"). - A \_parameter resource\_ provides information to a MutatingAdmissionPolicy to make it a concrete statement (think "set the `owner` label to something like `company.example.com`"). Parameter resources refer to Kubernetes resources, available in the Kubernetes API. They can be built-in types or extensions, such as a {{< glossary\_tooltip term\_id="CustomResourceDefinition" text="CustomResourceDefinition" >}} (CRD). For example, you can use a ConfigMap as a parameter. - A MutatingAdmissionPolicyBinding links the above (MutatingAdmissionPolicy and parameter) resources together and provides scoping. If you only want to set an `owner` label for `Pods`, and not other API kinds, the binding is where you specify this mutation. At least a MutatingAdmissionPolicy and a corresponding MutatingAdmissionPolicyBinding must be defined for a policy to have an effect. If a MutatingAdmissionPolicy does not need to be configured via parameters, simply leave `spec.paramKind` in MutatingAdmissionPolicy not specified. ## Getting Started with MutatingAdmissionPolicies Mutating admission policy is part of the cluster control-plane. You should write and deploy them with great caution. The following describes how to quickly experiment with Mutating admission policy. ### Create a MutatingAdmissionPolicy The following is an example of a MutatingAdmissionPolicy. This policy mutates newly created Pods to have a sidecar container if it does not exist. {{% code\_sample language="yaml" file="mutatingadmissionpolicy/applyconfiguration-example.yaml" %}} The `.spec.mutations` field consists of a list of expressions that evaluate to resource patches. The emitted patches may be either [apply configurations](#patch-type-apply-configuration) or [JSON Patch](#patch-type-json-patch) patches. You cannot specify an empty list of mutations. After evaluating all the expressions, the API server applies those changes to the resource that is passing through admission. To configure a mutating admission policy for use in a cluster, a binding is required. The MutatingAdmissionPolicy will only be active if a corresponding binding exists with the referenced `spec.policyName` matching the `spec.name` of a policy. Once the binding and policy are created, any resource request that matches the `spec.matchConditions` of a policy will trigger the set of mutations defined. In the example above, creating a Pod will add the `mesh-proxy` initContainer mutation: ```yaml apiVersion: v1 kind: Pod metadata: name: myapp namespace: default spec: ... initContainers: - name: mesh-proxy image: mesh/proxy:v1.0.0 args: ["proxy", "sidecar"] restartPolicy: Always - name: myapp-initializer image: example/initializer:v1.0.0 ... ``` #### Parameter resources Parameter resources allow a policy configuration to be separate from its definition. A policy can define `paramKind`, which outlines GVK of the parameter resource, and then a policy binding ties a policy by name (via `policyName`) to a particular parameter resource via `paramRef`. Please refer | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/mutating-admission-policy.md | main | kubernetes | [
0.001747864531353116,
0.06955107301473618,
0.08370572328567505,
-0.05743084475398064,
0.00878540612757206,
-0.011899402365088463,
0.04212099313735962,
-0.03531763330101967,
0.0319865383207798,
0.04624156281352043,
-0.05261054262518883,
-0.034505587071180344,
0.028245382010936737,
0.0052550... | 0.14239 |
... ``` #### Parameter resources Parameter resources allow a policy configuration to be separate from its definition. A policy can define `paramKind`, which outlines GVK of the parameter resource, and then a policy binding ties a policy by name (via `policyName`) to a particular parameter resource via `paramRef`. Please refer to [parameter resources](/docs/reference/access-authn-authz/validating-admission-policy/#parameter-resources) for more information. #### `ApplyConfiguration` {#patch-type-apply-configuration} MutatingAdmissionPolicy expressions are always CEL. Each apply configuration `expression` must evaluate to a CEL object (declared using `Object()` initialization). Apply configurations may not modify atomic structs, maps or arrays due to the risk of accidental deletion of values not included in the apply configuration. CEL expressions have access to the object types needed to create apply configurations: - `Object` - CEL type of the resource object. - `Object.` - CEL type of object field (such as `Object.spec`) - `Object.....` - CEL type of nested field (such as `Object.spec.containers`) CEL expressions have access to the contents of the API request, organized into CEL variables as well as some other useful variables: - `object` - The object from the incoming request. The value is null for DELETE requests. - `oldObject` - The existing object. The value is null for CREATE requests. - `request` - Attributes of the API request. - `params` - Parameter resource referred to by the policy binding being evaluated. Only populated if the policy has a ParamKind. - `namespaceObject` - The namespace object that the incoming object belongs to. The value is null for cluster-scoped resources. - `variables` - Map of composited variables, from its name to its lazily evaluated value. For example, a variable named `foo` can be accessed as `variables.foo`. - `authorizer` - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request. See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz - `authorizer.requestResource` - A CEL ResourceCheck constructed from the `authorizer` and configured with the request resource. The `apiVersion`, `kind`, `metadata.name`, `metadata.generateName` and `metadata.labels` are always accessible from the root of the object. No other metadata properties are accessible. #### `JSONPatch` {#patch-type-json-patch} The same mutation can be written as a [JSON Patch](https://jsonpatch.com/) as follows: {{% code\_sample language="yaml" file="mutatingadmissionpolicy/json-patch-example.yaml" %}} The expression will be evaluated by CEL to create a [JSON patch](https://jsonpatch.com/). ref: https://github.com/google/cel-spec Each evaluated `expression` must return an array of `JSONPatch` values. The `JSONPatch` type represents one operation from a JSON patch. For example, this CEL expression returns a JSON patch to conditionally modify a value: ``` [ JSONPatch{op: "test", path: "/spec/example", value: "Red"}, JSONPatch{op: "replace", path: "/spec/example", value: "Green"} ] ``` To define a JSON object for the patch operation `value`, use CEL `Object` types. For example: ``` [ JSONPatch{ op: "add", path: "/spec/selector", value: Object.spec.selector{matchLabels: {"environment": "test"}} } ] ``` To use strings containing '/' and '~' as JSONPatch path keys, use `jsonpatch.escapeKey()`. For example: ``` [ JSONPatch{ op: "add", path: "/metadata/labels/" + jsonpatch.escapeKey("example.com/environment"), value: "test" }, ] ``` CEL expressions have access to the types needed to create JSON patches and objects: - `JSONPatch` - CEL type of JSON Patch operations. JSONPatch has the fields `op`, `from`, `path` and `value`. See [JSON patch](https://jsonpatch.com/) for more details. The `value` field may be set to any of: string, integer, array, map or object. If set, the `path` and `from` fields must be set to a [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901/) string, where the `jsonpatch.escapeKey()` CEL function may be used to escape path keys containing `/` and `~`. - `Object` - CEL type of the resource object. - `Object.` - CEL type of object field (such as `Object.spec`) - `Object.....` - CEL type of nested field (such as `Object.spec.containers`) CEL expressions have access to the contents | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/mutating-admission-policy.md | main | kubernetes | [
-0.07963556796312332,
0.033674634993076324,
-0.027731306850910187,
-0.011363951489329338,
0.010161037556827068,
-0.03326096385717392,
0.0955117791891098,
0.059442054480314255,
-0.08080590516328812,
-0.006568476557731628,
0.01153756957501173,
-0.09434567391872406,
0.08100086450576782,
0.031... | 0.077476 |
function may be used to escape path keys containing `/` and `~`. - `Object` - CEL type of the resource object. - `Object.` - CEL type of object field (such as `Object.spec`) - `Object.....` - CEL type of nested field (such as `Object.spec.containers`) CEL expressions have access to the contents of the API request, organized into CEL variables as well as some other useful variables: - `object` - The object from the incoming request. The value is null for DELETE requests. - `oldObject` - The existing object. The value is null for CREATE requests. - `request` - Attributes of the API request. - `params` - Parameter resource referred to by the policy binding being evaluated. Only populated if the policy has a ParamKind. - `namespaceObject` - The namespace object that the incoming object belongs to. The value is null for cluster-scoped resources. - `variables` - Map of composited variables, from its name to its lazily evaluated value. For example, a variable named `foo` can be accessed as `variables.foo`. - `authorizer` - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request. See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz - `authorizer.requestResource` - A CEL ResourceCheck constructed from the `authorizer` and configured with the request resource. CEL expressions have access to [Kubernetes CEL function libraries](/docs/reference/using-api/cel/#cel-options-language-features-and-libraries) as well as: - `jsonpatch.escapeKey` - Performs JSONPatch key escaping. `~` and `/` are escaped as `~0` and `~1` respectively. Only property names of the form `[a-zA-Z\_.-/][a-zA-Z0-9\_.-/]\*` are accessible. ## API kinds exempt from mutating admission There are certain API kinds that are exempt from admission-time mutation. For example, you can't create a MutatingAdmissionPolicy that changes a MutatingAdmissionPolicy. The list of exempt API kinds is: \* [ValidatingAdmissionPolicies]({{< relref "/docs/reference/kubernetes-api/policy-resources/validating-admission-policy-v1/" >}}) \* [ValidatingAdmissionPolicyBindings]({{< relref "/docs/reference/kubernetes-api/policy-resources/validating-admission-policy-binding-v1/" >}}) \* MutatingAdmissionPolicies \* MutatingAdmissionPolicyBindings \* [TokenReviews]({{< relref "/docs/reference/kubernetes-api/authentication-resources/token-review-v1/" >}}) \* [LocalSubjectAccessReviews]({{< relref "/docs/reference/kubernetes-api/authorization-resources/local-subject-access-review-v1/" >}}) \* [SelfSubjectAccessReviews]({{< relref "/docs/reference/kubernetes-api/authorization-resources/self-subject-access-review-v1/" >}}) \* [SelfSubjectReviews]({{< relref "/docs/reference/kubernetes-api/authentication-resources/self-subject-review-v1/" >}}) | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/mutating-admission-policy.md | main | kubernetes | [
-0.05963698774576187,
0.022222360596060753,
-0.08142662048339844,
0.07906146347522736,
-0.020620061084628105,
-0.01839280314743519,
0.021563943475484848,
0.007382647600024939,
0.013185791671276093,
0.01722773164510727,
-0.012620382010936737,
-0.10479681193828583,
0.013887573964893818,
0.01... | 0.149928 |
A WebHook is an HTTP callback: an HTTP POST that occurs when something happens; a simple event-notification via HTTP POST. A web application implementing WebHooks will POST a message to a URL when certain things happen. When specified, mode `Webhook` causes Kubernetes to query an outside REST service when determining user privileges. ## Configuration File Format Mode `Webhook` requires a file for HTTP configuration, specify by the `--authorization-webhook-config-file=SOME\_FILENAME` flag. The configuration file uses the [kubeconfig](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) file format. Within the file "users" refers to the API Server webhook and "clusters" refers to the remote service. A configuration example which uses HTTPS client auth: ```yaml # Kubernetes API version apiVersion: v1 # kind of the API object kind: Config # clusters refers to the remote service. clusters: - name: name-of-remote-authz-service cluster: # CA for verifying the remote service. certificate-authority: /path/to/ca.pem # URL of remote service to query. Must use 'https'. May not include parameters. server: https://authz.example.com/authorize # users refers to the API Server's webhook configuration. users: - name: name-of-api-server user: client-certificate: /path/to/cert.pem # cert for the webhook plugin to use client-key: /path/to/key.pem # key matching the cert # kubeconfig files require a context. Provide one for the API Server. current-context: webhook contexts: - context: cluster: name-of-remote-authz-service user: name-of-api-server name: webhook ``` ## Request Payloads When faced with an authorization decision, the API Server POSTs a JSON- serialized `authorization.k8s.io/v1beta1` `SubjectAccessReview` object describing the action. This object contains fields describing the user attempting to make the request, and either details about the resource being accessed or requests attributes. Note that webhook API objects are subject to the same [versioning compatibility rules](/docs/concepts/overview/kubernetes-api/) as other Kubernetes API objects. Implementers should be aware of looser compatibility promises for beta objects and check the "apiVersion" field of the request to ensure correct deserialization. Additionally, the API Server must enable the `authorization.k8s.io/v1beta1` API extensions group (`--runtime-config=authorization.k8s.io/v1beta1=true`). An example request body: ```json { "apiVersion": "authorization.k8s.io/v1beta1", "kind": "SubjectAccessReview", "spec": { "resourceAttributes": { "namespace": "kittensandponies", "verb": "get", "group": "unicorn.example.org", "resource": "pods" }, "user": "jane", "group": [ "group1", "group2" ] } } ``` The remote service is expected to fill the `status` field of the request and respond to either allow or disallow access. The response body's `spec` field is ignored and may be omitted. A permissive response would return: ```json { "apiVersion": "authorization.k8s.io/v1beta1", "kind": "SubjectAccessReview", "status": { "allowed": true } } ``` For disallowing access there are two methods. The first method is preferred in most cases, and indicates the authorization webhook does not allow, or has "no opinion" about the request, but if other authorizers are configured, they are given a chance to allow the request. If there are no other authorizers, or none of them allow the request, the request is forbidden. The webhook would return: ```json { "apiVersion": "authorization.k8s.io/v1beta1", "kind": "SubjectAccessReview", "status": { "allowed": false, "reason": "user does not have read access to the namespace" } } ``` The second method denies immediately, short-circuiting evaluation by other configured authorizers. This should only be used by webhooks that have detailed knowledge of the full authorizer configuration of the cluster. The webhook would return: ```json { "apiVersion": "authorization.k8s.io/v1beta1", "kind": "SubjectAccessReview", "status": { "allowed": false, "denied": true, "reason": "user does not have read access to the namespace" } } ``` Access to non-resource paths are sent as: ```json { "apiVersion": "authorization.k8s.io/v1beta1", "kind": "SubjectAccessReview", "spec": { "nonResourceAttributes": { "path": "/debug", "verb": "get" }, "user": "jane", "group": [ "group1", "group2" ] } } ``` {{< feature-state feature\_gate\_name="AuthorizeWithSelectors" >}} When calling out to an authorization webhook, Kubernetes passes label and field selectors in the request to the authorization webhook. The authorization webhook can make authorization | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/webhook.md | main | kubernetes | [
-0.03848256170749664,
0.09242745488882065,
-0.04898955672979355,
-0.02482299879193306,
-0.023684576153755188,
-0.07313866168260574,
-0.008829929865896702,
-0.03523866459727287,
0.08030274510383606,
0.0031319449190050364,
-0.012299607507884502,
-0.05813031643629074,
0.025787536054849625,
-0... | 0.187884 |
"SubjectAccessReview", "spec": { "nonResourceAttributes": { "path": "/debug", "verb": "get" }, "user": "jane", "group": [ "group1", "group2" ] } } ``` {{< feature-state feature\_gate\_name="AuthorizeWithSelectors" >}} When calling out to an authorization webhook, Kubernetes passes label and field selectors in the request to the authorization webhook. The authorization webhook can make authorization decisions informed by the scoped field and label selectors, if it wishes. The [SubjectAccessReview API documentation](/docs/reference/kubernetes-api/authorization-resources/subject-access-review-v1/) gives guidelines for how these fields should be interpreted and handled by authorization webhooks, specifically using the parsed requirements rather than the raw selector strings, and how to handle unrecognized operators safely. ```json { "apiVersion": "authorization.k8s.io/v1beta1", "kind": "SubjectAccessReview", "spec": { "resourceAttributes": { "verb": "list", "group": "", "resource": "pods", "fieldSelector": { "requirements": [ {"key":"spec.nodeName", "operator":"In", "values":["mynode"]} ] }, "labelSelector": { "requirements": [ {"key":"example.com/mykey", "operator":"In", "values":["myvalue"]} ] } }, "user": "jane", "group": [ "group1", "group2" ] } } ``` Non-resource paths include: `/api`, `/apis`, `/metrics`, `/logs`, `/debug`, `/healthz`, `/livez`, `/openapi/v2`, `/readyz`, and `/version.` Clients require access to `/api`, `/api/\*`, `/apis`, `/apis/\*`, and `/version` to discover what resources and versions are present on the server. Access to other non-resource paths can be disallowed without restricting access to the REST api. For further information, refer to the [SubjectAccessReview API documentation](/docs/reference/kubernetes-api/authorization-resources/subject-access-review-v1/) and [webhook.go implementation](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go). | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/webhook.md | main | kubernetes | [
-0.044859856367111206,
0.12388762086629868,
-0.031814008951187134,
0.0034210996236652136,
0.024722542613744736,
-0.04316006600856781,
0.0456821508705616,
-0.0518215149641037,
0.03286315128207207,
0.009366445243358612,
-0.02447621338069439,
-0.136530801653862,
0.0005563513259403408,
0.01312... | 0.132591 |
## Overview A kubelet's HTTPS endpoint exposes APIs which give access to data of varying sensitivity, and allow you to perform operations with varying levels of power on the node and within containers. This document describes how to authenticate and authorize access to the kubelet's HTTPS endpoint. ## Kubelet authentication By default, requests to the kubelet's HTTPS endpoint that are not rejected by other configured authentication methods are treated as anonymous requests, and given a username of `system:anonymous` and a group of `system:unauthenticated`. To disable anonymous access and send `401 Unauthorized` responses to unauthenticated requests: \* start the kubelet with the `--anonymous-auth=false` flag To enable X509 client certificate authentication to the kubelet's HTTPS endpoint: \* start the kubelet with the `--client-ca-file` flag, providing a CA bundle to verify client certificates with \* start the apiserver with `--kubelet-client-certificate` and `--kubelet-client-key` flags \* see the [apiserver authentication documentation](/docs/reference/access-authn-authz/authentication/#x509-client-certificates) for more details To enable API bearer tokens (including service account tokens) to be used to authenticate to the kubelet's HTTPS endpoint: \* ensure the `authentication.k8s.io/v1beta1` API group is enabled in the API server \* start the kubelet with the `--authentication-token-webhook` and `--kubeconfig` flags \* the kubelet calls the `TokenReview` API on the configured API server to determine user information from bearer tokens ## Kubelet authorization Any request that is successfully authenticated (including an anonymous request) is then authorized. The default authorization mode is `AlwaysAllow`, which allows all requests. There are many possible reasons to subdivide access to the kubelet API: \* anonymous auth is enabled, but anonymous users' ability to call the kubelet API should be limited \* bearer token auth is enabled, but arbitrary API users' (like service accounts) ability to call the kubelet API should be limited \* client certificate auth is enabled, but only some of the client certificates signed by the configured CA should be allowed to use the kubelet API To subdivide access to the kubelet API, delegate authorization to the API server: \* ensure the `authorization.k8s.io/v1beta1` API group is enabled in the API server \* start the kubelet with the `--authorization-mode=Webhook` and the `--kubeconfig` flags \* the kubelet calls the `SubjectAccessReview` API on the configured API server to determine whether each request is authorized The kubelet authorizes API requests using the same [request attributes](/docs/reference/access-authn-authz/authorization/#review-your-request-attributes) approach as the apiserver. The verb is determined from the incoming request's HTTP verb: HTTP verb | request verb ----------|--------------- POST | create GET, HEAD | get PUT | update PATCH | patch DELETE | delete The resource and subresource is determined from the incoming request's path: Kubelet API | resource | subresource --------------------|----------|------------ /stats/\\* | nodes | stats /metrics/\\* | nodes | metrics /logs/\\* | nodes | log /spec/\\* | nodes | spec /checkpoint/\\* | nodes | checkpoint \*all others\* | nodes | proxy The namespace and API group attributes are always an empty string, and the resource name is always the name of the kubelet's `Node` API object. When running in this mode, ensure the user identified by the `--kubelet-client-certificate` and `--kubelet-client-key` flags passed to the apiserver is authorized for the following attributes: \* verb=\\*, resource=nodes, subresource=proxy \* verb=\\*, resource=nodes, subresource=stats \* verb=\\*, resource=nodes, subresource=log \* verb=\\*, resource=nodes, subresource=spec \* verb=\\*, resource=nodes, subresource=metrics ### Fine-grained authorization {{< feature-state feature\_gate\_name="KubeletFineGrainedAuthz" >}} When the feature gate `KubeletFineGrainedAuthz` is enabled kubelet performs a fine-grained check before falling back to the `proxy` subresource for the `/pods`, `/runningPods`, `/configz` and `/healthz` endpoints. The resource and subresource are determined from the incoming request's path: Kubelet API | resource | subresource --------------|----------|------------ /stats/\\* | nodes | stats /metrics/\\* | nodes | metrics /logs/\\* | nodes | log /pods | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/kubelet-authn-authz.md | main | kubernetes | [
-0.025183457881212234,
0.11842744797468185,
-0.016387205570936203,
-0.02579955942928791,
-0.12154239416122437,
-0.058599282056093216,
-0.013192516751587391,
-0.00019034584693145007,
0.11643461883068085,
-0.04060380905866623,
-0.042591068893671036,
-0.09927963465452194,
0.026834484189748764,
... | 0.122945 |
check before falling back to the `proxy` subresource for the `/pods`, `/runningPods`, `/configz` and `/healthz` endpoints. The resource and subresource are determined from the incoming request's path: Kubelet API | resource | subresource --------------|----------|------------ /stats/\\* | nodes | stats /metrics/\\* | nodes | metrics /logs/\\* | nodes | log /pods | nodes | pods, proxy /runningPods/ | nodes | pods, proxy /healthz | nodes | healthz, proxy /configz | nodes | configz, proxy \*all others\* | nodes | proxy When the feature-gate `KubeletFineGrainedAuthz` is enabled, ensure the user identified by the `--kubelet-client-certificate` and `--kubelet-client-key` flags passed to the API server is authorized for the following attributes: \* verb=\\*, resource=nodes, subresource=proxy \* verb=\\*, resource=nodes, subresource=stats \* verb=\\*, resource=nodes, subresource=log \* verb=\\*, resource=nodes, subresource=metrics \* verb=\\*, resource=nodes, subresource=configz \* verb=\\*, resource=nodes, subresource=healthz \* verb=\\*, resource=nodes, subresource=pods If [RBAC authorization](/docs/reference/access-authn-authz/rbac/) is used, enabling this gate also ensure that the builtin `system:kubelet-api-admin` ClusterRole is updated with permissions to access all the above mentioned subresources. | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/kubelet-authn-authz.md | main | kubernetes | [
-0.0008017368381842971,
0.021056650206446648,
0.04637379199266434,
-0.01373315416276455,
-0.05930805206298828,
-0.04596647247672081,
-0.00583784282207489,
-0.014105776324868202,
0.016101833432912827,
0.0049619488418102264,
-0.05259624868631363,
-0.06617619842290878,
0.0057385945692658424,
... | 0.079023 |
This page provides an overview of \_admission controllers\_. An admission controller is a piece of code that intercepts requests to the Kubernetes API server prior to persistence of the resource, but after the request is authenticated and authorized. Several important features of Kubernetes require an admission controller to be enabled in order to properly support the feature. As a result, a Kubernetes API server that is not properly configured with the right set of admission controllers is an incomplete server that will not support all the features you expect. ## What are they? Admission controllers are code within the Kubernetes {{< glossary\_tooltip term\_id="kube-apiserver" text="API server" >}} that check the data arriving in a request to modify a resource. Admission controllers apply to requests that create, delete, or modify objects. Admission controllers can also block custom verbs, such as a request to connect to a pod via an API server proxy. Admission controllers do \_not\_ (and cannot) block requests to read (\*\*get\*\*, \*\*watch\*\* or \*\*list\*\*) objects, because reads bypass the admission control layer. Admission control mechanisms may be \_validating\_, \_mutating\_, or both. Mutating controllers may modify the data for the resource being modified; validating controllers may not. The admission controllers in Kubernetes {{< skew currentVersion >}} consist of the [list](#what-does-each-admission-controller-do) below, are compiled into the `kube-apiserver` binary, and may only be configured by the cluster administrator. ### Admission control extension points Within the full [list](#what-does-each-admission-controller-do), there are three special controllers: [MutatingAdmissionWebhook](#mutatingadmissionwebhook), [ValidatingAdmissionWebhook](#validatingadmissionwebhook), and [ValidatingAdmissionPolicy](#validatingadmissionpolicy). The two webhook controllers execute the mutating and validating (respectively) [admission control webhooks](/docs/reference/access-authn-authz/extensible-admission-controllers/#admission-webhooks) which are configured in the API. ValidatingAdmissionPolicy provides a way to embed declarative validation code within the API, without relying on any external HTTP callouts. You can use these three admission controllers to customize cluster behavior at admission time. ### Admission control phases The admission control process proceeds in two phases. In the first phase, mutating admission controllers are run. In the second phase, validating admission controllers are run. Note again that some of the controllers are both. If any of the controllers in either phase reject the request, the entire request is rejected immediately and an error is returned to the end-user. Finally, in addition to sometimes mutating the object in question, admission controllers may sometimes have side effects, that is, mutate related resources as part of request processing. Incrementing quota usage is the canonical example of why this is necessary. Any such side-effect needs a corresponding reclamation or reconciliation process, as a given admission controller does not know for sure that a given request will pass all of the other admission controllers. The ordering of these calls can be seen below. {{< figure src="/docs/reference/access-authn-authz/admission-control-phases.svg" alt="Sequence diagram for kube-apiserver handling requests during the admission phase showing mutation webhooks, followed by validatingadmissionpolicies and finally validating webhooks. It shows that the continue until the first rejection, or being accepted by all of them. It also shows that mutations by mutating webhooks cause all previously called webhooks to be called again." class="diagram-large" link="[https://mermaid.live/edit#pako:eNqtVm1r3DgQ\_iuDj9CUc3aPlBa6HIFeSu\_CEQhNr4XiL7I9a6srSz5J3mQb9r93RrK9jjcp9-H8xdZoXh7N80jyQ1KYEpNV4vDfDnWB76WorGgynemTE\_hLbBG8AYce1kb7W\_kdoVImF0rtQDjwtXQgnX7hwaJrsfBYQtmFoNr71q2Wy0r6ussXhWmWDdpGyPLsmxs-l9K5Dt3y1du3v3HJB6mlXz1kia-xwSxZZYnGzluhsiTNkgEETUCWnJ-392SmrwE-2ym4kdYa-67wxjoyedvhPs000NNn\_iysFLlCFyPCVJwWHPXHpgq1f3l1\_qbA11x77vIJ7\_2lUcYGx7taepy5KWPaqRc8l08bj1Rx4ldZ3M2cnlp6pvf7\_ckJsxVdibNPkRKiBkEof-YJAZFnQRQFOidzqaTfpSB0Ca42nSohR-jaUjB3uEW7Ay8bDAnKKAfKt4gFKMl7dIWd9uy2b\_7ozdU2XY5nopUOLaWEmsopqSuSCTk770gllscBZtmQDKTR0NbCIcO647mm88Kz-Q7z2piNSym1UuaOgOY72AolCTV5jglao2Qh0YXVraUOOj34jYkWcIB\_5UNB7pjwAU9BrZaaVNzRWwXTWlrHGv9GEqc6KdASc-SU3NbWR0RUDsyaA5pZBaGcmZYZluY4LA4m8KAQncOQrrW4laZztI6CxlRndKI9Rsz1VlEJqXuS9oMcWmE99aMV2sM\_xARv2fA-nn53c8WzfxNtVqOnFrLlNrD3hHfna3bnN1KTisjTr8FgrPwexqMmH4WWzaW3KkSPvF9Sx61RMSA39\_Anrcblxho49oLfc3txGZcdGZqxc4z3uu\_wl9g7Lj6YoLedupfHcZ9H6dyYAPlgmOC66VX3s\_hJ5UmOeW3U5WEzB6bOLi4CEyv4GHcOnOKiWqRQWKQdCwJaU77sCWXHEEAsrKbkkJQD\_bQruHlFjcUmmlo6h-My3FCXzy34wCcG6W\_eJneQdRABl5t1dwVXems2-LPYOSEH1NemlOsd76\_IJ5g8vE7lGjRiieW0V0d4J819TMuI9hGnI9Zn4x5L4IDz439ER3J4CtzQEpCaXVjN6lmg88Y-kef\_ATvWJiWRgPisnTDRn92DToLa2JmFyjVcSypCGBTqunDjcALk-5iKJWnSX\_z0zxGukMNNT5-lsJtwq5Gf6Ly53ekiXt9pYk1X1clqTScpjeJ91f-tjFYsJd3M1\_GXJvzZpAntw6\_GDD77H6uICLI](https://mermaid.live/edit#pako:eNqtVm1r3DgQ\_iuDj9CUc3aPlBa6HIFeSu\_CEQhNr4XiL7I9a6srSz5J3mQb9r93RrK9jjcp9-H8xdZoXh7N80jyQ1KYEpNV4vDfDnWB76WorGgynemTE\_hLbBG8AYce1kb7W\_kdoVImF0rtQDjwtXQgnX7hwaJrsfBYQtmFoNr71q2Wy0r6ussXhWmWDdpGyPLsmxs-l9K5Dt3y1du3v3HJB6mlXz1kia-xwSxZZYnGzluhsiTNkgEETUCWnJ-392SmrwE-2ym4kdYa-67wxjoyedvhPs000NNn\_iysFLlCFyPCVJwWHPXHpgq1f3l1\_qbA11x77vIJ7\_2lUcYGx7taepy5KWPaqRc8l08bj1Rx4ldZ3M2cnlp6pvf7\_ckJsxVdibNPkRKiBkEof-YJAZFnQRQFOidzqaTfpSB0Ca42nSohR-jaUjB3uEW7Ay8bDAnKKAfKt4gFKMl7dIWd9uy2b\_7ozdU2XY5nopUOLaWEmsopqSuSCTk770gllscBZtmQDKTR0NbCIcO647mm88Kz-Q7z2piNSym1UuaOgOY72AolCTV5jglao2Qh0YXVraUOOj34jYkWcIB\_5UNB7pjwAU9BrZaaVNzRWwXTWlrHGv9GEqc6KdASc-SU3NbWR0RUDsyaA5pZBaGcmZYZluY4LA4m8KAQncOQrrW4laZztI6CxlRndKI9Rsz1VlEJqXuS9oMcWmE99aMV2sM\_xARv2fA-nn53c8WzfxNtVqOnFrLlNrD3hHfna3bnN1KTisjTr8FgrPwexqMmH4WWzaW3KkSPvF9Sx61RMSA39\_Anrcblxho49oLfc3txGZcdGZqxc4z3uu\_wl9g7Lj6YoLedupfHcZ9H6dyYAPlgmOC66VX3s\_hJ5UmOeW3U5WEzB6bOLi4CEyv4GHcOnOKiWqRQWKQdCwJaU77sCWXHEEAsrKbkkJQD\_bQruHlFjcUmmlo6h-My3FCXzy34wCcG6W\_eJneQdRABl5t1dwVXems2-LPYOSEH1NemlOsd76\_IJ5g8vE7lGjRiieW0V0d4J819TMuI9hGnI9Zn4x5L4IDz439ER3J4CtzQEpCaXVjN6lmg88Y-kef\_ATvWJiWRgPisnTDRn92DToLa2JmFyjVcSypCGBTqunDjcALk-5iKJWnSX\_z0zxGukMNNT5-lsJtwq5Gf6Ly53ekiXt9pYk1X1clqTScpjeJ91f-tjFYsJd3M1\_GXJvzZpAntw6\_GDD77H6uICLI)" >}} ## Why do I need them? Several important features of Kubernetes require an admission controller to be enabled in order to properly support the feature. As a result, a Kubernetes API server that is not properly configured with the right set of admission controllers is an incomplete server and will not support all the features you expect. ## How do I turn on an admission controller? The Kubernetes API server flag `enable-admission-plugins` takes a comma-delimited list of admission control plugins to invoke prior to modifying objects in the cluster. For example, the following command line enables the `NamespaceLifecycle` and the `LimitRanger` admission | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/admission-controllers.md | main | kubernetes | [
-0.010011225007474422,
-0.030115487053990364,
0.04914440959692001,
-0.033060166984796524,
-0.019382722675800323,
0.003721927758306265,
0.046760838478803635,
-0.06876390427350998,
0.07810287177562714,
0.10152389109134674,
0.001734261866658926,
-0.011496943421661854,
0.0061814566142857075,
-... | 0.105059 |
all the features you expect. ## How do I turn on an admission controller? The Kubernetes API server flag `enable-admission-plugins` takes a comma-delimited list of admission control plugins to invoke prior to modifying objects in the cluster. For example, the following command line enables the `NamespaceLifecycle` and the `LimitRanger` admission control plugins: ```shell kube-apiserver --enable-admission-plugins=NamespaceLifecycle,LimitRanger ... ``` {{< note >}} Depending on the way your Kubernetes cluster is deployed and how the API server is started, you may need to apply the settings in different ways. For example, you may have to modify the systemd unit file if the API server is deployed as a systemd service, you may modify the manifest file for the API server if Kubernetes is deployed in a self-hosted way. {{< /note >}} ## How do I turn off an admission controller? The Kubernetes API server flag `disable-admission-plugins` takes a comma-delimited list of admission control plugins to be disabled, even if they are in the list of plugins enabled by default. ```shell kube-apiserver --disable-admission-plugins=PodNodeSelector,AlwaysDeny ... ``` ## Which plugins are enabled by default? To see which admission plugins are enabled: ```shell kube-apiserver -h | grep enable-admission-plugins ``` In Kubernetes {{< skew currentVersion >}}, the default ones are: ```shell CertificateApproval, CertificateSigning, CertificateSubjectRestriction, DefaultIngressClass, DefaultStorageClass, DefaultTolerationSeconds, LimitRanger, MutatingAdmissionWebhook, NamespaceLifecycle, PersistentVolumeClaimResize, PodSecurity, Priority, ResourceQuota, RuntimeClass, ServiceAccount, StorageObjectInUseProtection, TaintNodesByCondition, ValidatingAdmissionPolicy, ValidatingAdmissionWebhook ``` ## What does each admission controller do? ### AlwaysAdmit {#alwaysadmit} {{< feature-state for\_k8s\_version="v1.13" state="deprecated" >}} \*\*Type\*\*: Validating. This admission controller allows all pods into the cluster. It is \*\*deprecated\*\* because its behavior is the same as if there were no admission controller at all. ### AlwaysDeny {#alwaysdeny} {{< feature-state for\_k8s\_version="v1.13" state="deprecated" >}} \*\*Type\*\*: Validating. Rejects all requests. AlwaysDeny is \*\*deprecated\*\* as it has no real meaning. ### AlwaysPullImages {#alwayspullimages} \*\*Type\*\*: Mutating and Validating. This admission controller modifies every new Pod to force the image pull policy to `Always`. This is useful in a multitenant cluster so that users can be assured that their private images can only be used by those who have the credentials to pull them. Without this admission controller, once an image has been pulled to a node, any pod from any user can use it by knowing the image's name (assuming the Pod is scheduled onto the right node), without any authorization check against the image. When this admission controller is enabled, images are always pulled prior to starting containers, which means valid credentials are required. ### CertificateApproval {#certificateapproval} \*\*Type\*\*: Validating. This admission controller observes requests to approve CertificateSigningRequest resources and performs additional authorization checks to ensure the approving user has permission to \*\*approve\*\* certificate requests with the `spec.signerName` requested on the CertificateSigningRequest resource. See [Certificate Signing Requests](/docs/reference/access-authn-authz/certificate-signing-requests/) for more information on the permissions required to perform different actions on CertificateSigningRequest resources. ### CertificateSigning {#certificatesigning} \*\*Type\*\*: Validating. This admission controller observes updates to the `status.certificate` field of CertificateSigningRequest resources and performs an additional authorization checks to ensure the signing user has permission to \*\*sign\*\* certificate requests with the `spec.signerName` requested on the CertificateSigningRequest resource. See [Certificate Signing Requests](/docs/reference/access-authn-authz/certificate-signing-requests/) for more information on the permissions required to perform different actions on CertificateSigningRequest resources. ### CertificateSubjectRestriction {#certificatesubjectrestriction} \*\*Type\*\*: Validating. This admission controller observes creation of CertificateSigningRequest resources that have a `spec.signerName` of `kubernetes.io/kube-apiserver-client`. It rejects any request that specifies a 'group' (or 'organization attribute') of `system:masters`. ### DefaultIngressClass {#defaultingressclass} \*\*Type\*\*: Mutating. This admission controller observes creation of `Ingress` objects that do not request any specific ingress class and automatically adds a default ingress class to them. This way, users that do not request any special ingress class do not need to care about them at | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/admission-controllers.md | main | kubernetes | [
0.0018124935450032353,
0.004231198690831661,
0.009509800933301449,
-0.015003111213445663,
-0.015513164922595024,
0.029385024681687355,
-0.026784531772136688,
-0.021057207137346268,
0.046494998037815094,
0.09701195359230042,
0.0017393737798556685,
-0.015750739723443985,
0.0017124009318649769,... | 0.12884 |
`system:masters`. ### DefaultIngressClass {#defaultingressclass} \*\*Type\*\*: Mutating. This admission controller observes creation of `Ingress` objects that do not request any specific ingress class and automatically adds a default ingress class to them. This way, users that do not request any special ingress class do not need to care about them at all and they will get the default one. This admission controller does not do anything when no default ingress class is configured. When more than one ingress class is marked as default, it rejects any creation of `Ingress` with an error and an administrator must revisit their `IngressClass` objects and mark only one as default (with the annotation "ingressclass.kubernetes.io/is-default-class"). This admission controller ignores any `Ingress` updates; it acts only on creation. See the [Ingress](/docs/concepts/services-networking/ingress/) documentation for more about ingress classes and how to mark one as default. ### DefaultStorageClass {#defaultstorageclass} \*\*Type\*\*: Mutating. This admission controller observes creation of `PersistentVolumeClaim` objects that do not request any specific storage class and automatically adds a default storage class to them. This way, users that do not request any special storage class do not need to care about them at all and they will get the default one. This admission controller does nothing when no default `StorageClass` exists. When more than one storage class is marked as default, and you then create a `PersistentVolumeClaim` with no `storageClassName` set, Kubernetes uses the most recently created default `StorageClass`. When a `PersistentVolumeClaim` is created with a specified `volumeName`, it remains in a pending state if the static volume's `storageClassName` does not match the `storageClassName` on the `PersistentVolumeClaim` after any default StorageClass is applied to it. This admission controller ignores any `PersistentVolumeClaim` updates; it acts only on creation. See [persistent volume](/docs/concepts/storage/persistent-volumes/) documentation about persistent volume claims and storage classes and how to mark a storage class as default. ### DefaultTolerationSeconds {#defaulttolerationseconds} \*\*Type\*\*: Mutating. This admission controller sets the default forgiveness toleration for pods to tolerate the taints `notready:NoExecute` and `unreachable:NoExecute` based on the k8s-apiserver input parameters `default-not-ready-toleration-seconds` and `default-unreachable-toleration-seconds` if the pods don't already have toleration for taints `node.kubernetes.io/not-ready:NoExecute` or `node.kubernetes.io/unreachable:NoExecute`. The default value for `default-not-ready-toleration-seconds` and `default-unreachable-toleration-seconds` is 5 minutes. ### DenyServiceExternalIPs \*\*Type\*\*: Validating. This admission controller rejects all net-new usage of the `Service` field `externalIPs`. This feature is very powerful (allows network traffic interception) and not well controlled by policy. When enabled, users of the cluster may not create new Services which use `externalIPs` and may not add new values to `externalIPs` on existing `Service` objects. Existing uses of `externalIPs` are not affected, and users may remove values from `externalIPs` on existing `Service` objects. Most users do not need this feature at all, and cluster admins should consider disabling it. Clusters that do need to use this feature should consider using some custom policy to manage usage of it. This admission controller is disabled by default. ### EventRateLimit {#eventratelimit} {{< feature-state for\_k8s\_version="v1.13" state="alpha" >}} \*\*Type\*\*: Validating. This admission controller mitigates the problem where the API server gets flooded by requests to store new Events. The cluster admin can specify event rate limits by: \* Enabling the `EventRateLimit` admission controller; \* Referencing an `EventRateLimit` configuration file from the file provided to the API server's command line flag `--admission-control-config-file`: ```yaml apiVersion: apiserver.config.k8s.io/v1 kind: AdmissionConfiguration plugins: - name: EventRateLimit path: eventconfig.yaml ... ``` There are four types of limits that can be specified in the configuration: \* `Server`: All Event requests (creation or modifications) received by the API server share a single bucket. \* `Namespace`: Each namespace has a dedicated bucket. \* `User`: Each user is allocated a bucket. \* `SourceAndObject`: A bucket is assigned by each combination of | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/admission-controllers.md | main | kubernetes | [
-0.004290517885237932,
-0.009757719933986664,
0.07777120172977448,
-0.004067599307745695,
0.012298627756536007,
-0.0013059437042102218,
0.08425263315439224,
-0.04127679765224457,
0.050249941647052765,
0.08486469089984894,
0.03149445727467537,
-0.02792303077876568,
0.020018331706523895,
-0.... | 0.148584 |
that can be specified in the configuration: \* `Server`: All Event requests (creation or modifications) received by the API server share a single bucket. \* `Namespace`: Each namespace has a dedicated bucket. \* `User`: Each user is allocated a bucket. \* `SourceAndObject`: A bucket is assigned by each combination of source and involved object of the event. Below is a sample `eventconfig.yaml` for such a configuration: ```yaml apiVersion: eventratelimit.admission.k8s.io/v1alpha1 kind: Configuration limits: - type: Namespace qps: 50 burst: 100 cacheSize: 2000 - type: User qps: 10 burst: 50 ``` See the [EventRateLimit Config API (v1alpha1)](/docs/reference/config-api/apiserver-eventratelimit.v1alpha1/) for more details. This admission controller is disabled by default. ### ExtendedResourceToleration {#extendedresourcetoleration} \*\*Type\*\*: Mutating. This plug-in facilitates creation of dedicated nodes with extended resources. If operators want to create dedicated nodes with extended resources (like GPUs, FPGAs etc.), they are expected to [taint the node](/docs/concepts/scheduling-eviction/taint-and-toleration/#example-use-cases) with the extended resource name as the key. This admission controller, if enabled, automatically adds tolerations for such taints to pods requesting extended resources, so users don't have to manually add these tolerations. This admission controller is disabled by default. ### ImagePolicyWebhook {#imagepolicywebhook} \*\*Type\*\*: Validating. The ImagePolicyWebhook admission controller allows a backend webhook to make admission decisions. This admission controller is disabled by default. #### Configuration file format {#imagereview-config-file-format} ImagePolicyWebhook uses a configuration file to set options for the behavior of the backend. This file may be json or yaml and has the following format: ```yaml imagePolicy: kubeConfigFile: /path/to/kubeconfig/for/backend # time in s to cache approval allowTTL: 50 # time in s to cache denial denyTTL: 50 # time in ms to wait between retries retryBackoff: 500 # determines behavior if the webhook backend fails defaultAllow: true ``` Reference the ImagePolicyWebhook configuration file from the file provided to the API server's command line flag `--admission-control-config-file`: ```yaml apiVersion: apiserver.config.k8s.io/v1 kind: AdmissionConfiguration plugins: - name: ImagePolicyWebhook path: imagepolicyconfig.yaml ... ``` Alternatively, you can embed the configuration directly in the file: ```yaml apiVersion: apiserver.config.k8s.io/v1 kind: AdmissionConfiguration plugins: - name: ImagePolicyWebhook configuration: imagePolicy: kubeConfigFile: allowTTL: 50 denyTTL: 50 retryBackoff: 500 defaultAllow: true ``` The ImagePolicyWebhook config file must reference a [kubeconfig](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) formatted file which sets up the connection to the backend. It is required that the backend communicate over TLS. The kubeconfig file's `cluster` field must point to the remote service, and the `user` field must contain the returned authorizer. ```yaml # clusters refers to the remote service. clusters: - name: name-of-remote-imagepolicy-service cluster: certificate-authority: /path/to/ca.pem # CA for verifying the remote service. server: https://images.example.com/policy # URL of remote service to query. Must use 'https'. # users refers to the API server's webhook configuration. users: - name: name-of-api-server user: client-certificate: /path/to/cert.pem # cert for the webhook admission controller to use client-key: /path/to/key.pem # key matching the cert ``` For additional HTTP configuration, refer to the [kubeconfig](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) documentation. #### Request payloads When faced with an admission decision, the API Server POSTs a JSON serialized `imagepolicy.k8s.io/v1alpha1` `ImageReview` object describing the action. This object contains fields describing the containers being admitted, as well as any pod annotations that match `\*.image-policy.k8s.io/\*`. {{< note >}} The webhook API objects are subject to the same versioning compatibility rules as other Kubernetes API objects. Implementers should be aware of looser compatibility promises for alpha objects and check the `apiVersion` field of the request to ensure correct deserialization. Additionally, the API Server must enable the `imagepolicy.k8s.io/v1alpha1` API extensions group (`--runtime-config=imagepolicy.k8s.io/v1alpha1=true`). {{< /note >}} An example request body: ```json { "apiVersion": "imagepolicy.k8s.io/v1alpha1", "kind": "ImageReview", "spec": { "containers": [ { "image": "myrepo/myimage:v1" }, { "image": "myrepo/myimage@sha256:beb6bd6a68f114c1dc2ea4b28db81bdf91de202a9014972bec5e4d9171d90ed" } ], "annotations": { "mycluster.image-policy.k8s.io/ticket-1234": "break-glass" }, "namespace": "mynamespace" } } ``` The remote service is expected to | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/admission-controllers.md | main | kubernetes | [
-0.023082908242940903,
-0.0005668812082149088,
0.016614258289337158,
-0.01432514376938343,
-0.02828601747751236,
-0.026729902252554893,
0.01396552100777626,
-0.03486961871385574,
0.11942277103662491,
0.05263558775186539,
-0.03574512526392937,
-0.044276654720306396,
0.02367081493139267,
-0.... | 0.102232 |
must enable the `imagepolicy.k8s.io/v1alpha1` API extensions group (`--runtime-config=imagepolicy.k8s.io/v1alpha1=true`). {{< /note >}} An example request body: ```json { "apiVersion": "imagepolicy.k8s.io/v1alpha1", "kind": "ImageReview", "spec": { "containers": [ { "image": "myrepo/myimage:v1" }, { "image": "myrepo/myimage@sha256:beb6bd6a68f114c1dc2ea4b28db81bdf91de202a9014972bec5e4d9171d90ed" } ], "annotations": { "mycluster.image-policy.k8s.io/ticket-1234": "break-glass" }, "namespace": "mynamespace" } } ``` The remote service is expected to fill the `status` field of the request and respond to either allow or disallow access. The response body's `spec` field is ignored, and may be omitted. A permissive response would return: ```json { "apiVersion": "imagepolicy.k8s.io/v1alpha1", "kind": "ImageReview", "status": { "allowed": true } } ``` To disallow access, the service would return: ```json { "apiVersion": "imagepolicy.k8s.io/v1alpha1", "kind": "ImageReview", "status": { "allowed": false, "reason": "image currently blacklisted" } } ``` For further documentation refer to the [`imagepolicy.v1alpha1` API](/docs/reference/config-api/imagepolicy.v1alpha1/). #### Extending with Annotations All annotations on a Pod that match `\*.image-policy.k8s.io/\*` are sent to the webhook. Sending annotations allows users who are aware of the image policy backend to send extra information to it, and for different backends implementations to accept different information. Examples of information you might put here are: \* request to "break glass" to override a policy, in case of emergency. \* a ticket number from a ticket system that documents the break-glass request \* provide a hint to the policy server as to the imageID of the image being provided, to save it a lookup In any case, the annotations are provided by the user and are not validated by Kubernetes in any way. ### LimitPodHardAntiAffinityTopology {#limitpodhardantiaffinitytopology} \*\*Type\*\*: Validating. This admission controller denies any pod that defines `AntiAffinity` topology key other than `kubernetes.io/hostname` in `requiredDuringSchedulingRequiredDuringExecution`. This admission controller is disabled by default. ### LimitRanger {#limitranger} \*\*Type\*\*: Mutating and Validating. This admission controller will observe the incoming request and ensure that it does not violate any of the constraints enumerated in the `LimitRange` object in a `Namespace`. If you are using `LimitRange` objects in your Kubernetes deployment, you MUST use this admission controller to enforce those constraints. LimitRanger can also be used to apply default resource requests to Pods that don't specify any; currently, the default LimitRanger applies a 0.1 CPU requirement to all Pods in the `default` namespace. See the [LimitRange API reference](/docs/reference/kubernetes-api/policy-resources/limit-range-v1/) and the [example of LimitRange](/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/) for more details. ### MutatingAdmissionWebhook {#mutatingadmissionwebhook} \*\*Type\*\*: Mutating. This admission controller calls any mutating webhooks which match the request. Matching webhooks are called in serial; each one may modify the object if it desires. This admission controller (as implied by the name) only runs in the mutating phase. If a webhook called by this has side effects (for example, decrementing quota) it \*must\* have a reconciliation system, as it is not guaranteed that subsequent webhooks or validating admission controllers will permit the request to finish. If you disable the MutatingAdmissionWebhook, you must also disable the `MutatingWebhookConfiguration` object in the `admissionregistration.k8s.io/v1` group/version via the `--runtime-config` flag, both are on by default. #### Use caution when authoring and installing mutating webhooks \* Users may be confused when the objects they try to create are different from what they get back. \* Built in control loops may break when the objects they try to create are different when read back. \* Setting originally unset fields is less likely to cause problems than overwriting fields set in the original request. Avoid doing the latter. \* Future changes to control loops for built-in resources or third-party resources may break webhooks that work well today. Even when the webhook installation API is finalized, not all possible webhook behaviors will be guaranteed to be supported indefinitely. ### NamespaceAutoProvision {#namespaceautoprovision} \*\*Type\*\*: Mutating. This admission controller examines all incoming requests | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/admission-controllers.md | main | kubernetes | [
-0.01611204259097576,
0.06090326979756355,
0.051549818366765976,
-0.02946551889181137,
0.05944816768169403,
-0.04504048824310303,
-0.03326800465583801,
-0.006953071337193251,
0.00012298459478188306,
0.02016298659145832,
-0.004271958954632282,
-0.049490343779325485,
0.004718678537756205,
0.... | 0.025347 |
Future changes to control loops for built-in resources or third-party resources may break webhooks that work well today. Even when the webhook installation API is finalized, not all possible webhook behaviors will be guaranteed to be supported indefinitely. ### NamespaceAutoProvision {#namespaceautoprovision} \*\*Type\*\*: Mutating. This admission controller examines all incoming requests on namespaced resources and checks if the referenced namespace does exist. It creates a namespace if it cannot be found. This admission controller is useful in deployments that do not want to restrict creation of a namespace prior to its usage. ### NamespaceExists {#namespaceexists} \*\*Type\*\*: Validating. This admission controller checks all requests on namespaced resources other than `Namespace` itself. If the namespace referenced from a request doesn't exist, the request is rejected. ### NamespaceLifecycle {#namespacelifecycle} \*\*Type\*\*: Validating. This admission controller enforces that a `Namespace` that is undergoing termination cannot have new objects created in it, and ensures that requests in a non-existent `Namespace` are rejected. This admission controller also prevents deletion of three system reserved namespaces `default`, `kube-system`, `kube-public`. A `Namespace` deletion kicks off a sequence of operations that remove all objects (pods, services, etc.) in that namespace. In order to enforce integrity of that process, we strongly recommend running this admission controller. ### NodeDeclaredFeatureValidator {#nodedeclaredfeaturevalidator} {{< feature-state feature\_gate\_name="NodeDeclaredFeatures" >}} \*\*Type\*\*: Validating. This admission controller intercepts writes to bound Pods, to ensure that the changes are compatible with the features declared by the node where the Pod is currently running. It uses the `.status.declaredFeatures` field of the Node to determine the set of enabled features. If a Pod update requires a feature that is not listed in the features of its current node, the admission controller will reject the update request. This prevents runtime failures due to feature mismatch after a Pod has been scheduled. This admission controller is enabled by default if the [`NodeDeclaredFeatures`](/docs/reference/command-line-tools-reference/feature-gates/#NodeDeclaredFeatures) feature gate is enabled. ### NodeRestriction {#noderestriction} \*\*Type\*\*: Validating. This admission controller limits the `Node` and `Pod` objects a kubelet can modify. In order to be limited by this admission controller, kubelets must use credentials in the `system:nodes` group, with a username in the form `system:node:`. Such kubelets will only be allowed to modify their own `Node` API object, and only modify `Pod` API objects that are bound to their node. kubelets are not allowed to update or remove taints from their `Node` API object. The `NodeRestriction` admission plugin prevents kubelets from deleting their `Node` API object, and enforces kubelet modification of labels under the `kubernetes.io/` or `k8s.io/` prefixes as follows: \* \*\*Prevents\*\* kubelets from adding/removing/updating labels with a `node-restriction.kubernetes.io/` prefix. This label prefix is reserved for administrators to label their `Node` objects for workload isolation purposes, and kubelets will not be allowed to modify labels with that prefix. \* \*\*Allows\*\* kubelets to add/remove/update these labels and label prefixes: \* `kubernetes.io/hostname` \* `kubernetes.io/arch` \* `kubernetes.io/os` \* `beta.kubernetes.io/instance-type` \* `node.kubernetes.io/instance-type` \* `failure-domain.beta.kubernetes.io/region` (deprecated) \* `failure-domain.beta.kubernetes.io/zone` (deprecated) \* `topology.kubernetes.io/region` \* `topology.kubernetes.io/zone` \* `kubelet.kubernetes.io/`-prefixed labels \* `node.kubernetes.io/`-prefixed labels Use of any other labels under the `kubernetes.io` or `k8s.io` prefixes by kubelets is reserved, and may be disallowed or allowed by the `NodeRestriction` admission plugin in the future. Future versions may add additional restrictions to ensure kubelets have the minimal set of permissions required to operate correctly. ### OwnerReferencesPermissionEnforcement {#ownerreferencespermissionenforcement} \*\*Type\*\*: Validating. This admission controller protects the access to the `metadata.ownerReferences` of an object so that only users with \*\*delete\*\* permission to the object can change it. This admission controller also protects the access to `metadata.ownerReferences[x].blockOwnerDeletion` of an object, so that only users with \*\*update\*\* permission to the `finalizers` subresource of the referenced \*owner\* can change it. ### PersistentVolumeClaimResize | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/admission-controllers.md | main | kubernetes | [
-0.1076999381184578,
-0.015590894967317581,
-0.023370468989014626,
-0.008279641158878803,
0.05907423421740532,
-0.09093320369720459,
0.01950554922223091,
-0.10399476438760757,
0.01456414069980383,
0.04944073036313057,
0.03636081889271736,
-0.06993825733661652,
0.06499428302049637,
-0.03652... | 0.086277 |
the `metadata.ownerReferences` of an object so that only users with \*\*delete\*\* permission to the object can change it. This admission controller also protects the access to `metadata.ownerReferences[x].blockOwnerDeletion` of an object, so that only users with \*\*update\*\* permission to the `finalizers` subresource of the referenced \*owner\* can change it. ### PersistentVolumeClaimResize {#persistentvolumeclaimresize} {{< feature-state for\_k8s\_version="v1.24" state="stable" >}} \*\*Type\*\*: Validating. This admission controller implements additional validations for checking incoming `PersistentVolumeClaim` resize requests. Enabling the `PersistentVolumeClaimResize` admission controller is recommended. This admission controller prevents resizing of all claims by default unless a claim's `StorageClass` explicitly enables resizing by setting `allowVolumeExpansion` to `true`. For example: all `PersistentVolumeClaim`s created from the following `StorageClass` support volume expansion: ```yaml apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: gluster-vol-default provisioner: kubernetes.io/glusterfs parameters: resturl: "http://192.168.10.100:8080" restuser: "" secretNamespace: "" secretName: "" allowVolumeExpansion: true ``` For more information about persistent volume claims, see [PersistentVolumeClaims](/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims). ### PodNodeSelector {#podnodeselector} {{< feature-state for\_k8s\_version="v1.5" state="alpha" >}} \*\*Type\*\*: Validating. This admission controller defaults and limits what node selectors may be used within a namespace by reading a namespace annotation and a global configuration. This admission controller is disabled by default. #### Configuration file format `PodNodeSelector` uses a configuration file to set options for the behavior of the backend. Note that the configuration file format will move to a versioned file in a future release. This file may be json or yaml and has the following format: ```yaml podNodeSelectorPluginConfig: clusterDefaultNodeSelector: name-of-node-selector namespace1: name-of-node-selector namespace2: name-of-node-selector ``` Reference the `PodNodeSelector` configuration file from the file provided to the API server's command line flag `--admission-control-config-file`: ```yaml apiVersion: apiserver.config.k8s.io/v1 kind: AdmissionConfiguration plugins: - name: PodNodeSelector path: podnodeselector.yaml ... ``` #### Configuration Annotation Format `PodNodeSelector` uses the annotation key `scheduler.alpha.kubernetes.io/node-selector` to assign node selectors to namespaces. ```yaml apiVersion: v1 kind: Namespace metadata: annotations: scheduler.alpha.kubernetes.io/node-selector: name-of-node-selector name: namespace3 ``` #### Internal Behavior This admission controller has the following behavior: 1. If the `Namespace` has an annotation with a key `scheduler.alpha.kubernetes.io/node-selector`, use its value as the node selector. 2. If the namespace lacks such an annotation, use the `clusterDefaultNodeSelector` defined in the `PodNodeSelector` plugin configuration file as the node selector. 3. Evaluate the pod's node selector against the namespace node selector for conflicts. Conflicts result in rejection. 4. Evaluate the pod's node selector against the namespace-specific allowed selector defined the plugin configuration file. Conflicts result in rejection. {{< note >}} PodNodeSelector allows forcing pods to run on specifically labeled nodes. Also see the PodTolerationRestriction admission plugin, which allows preventing pods from running on specifically tainted nodes. {{< /note >}} ### PodSecurity {#podsecurity} {{< feature-state for\_k8s\_version="v1.25" state="stable" >}} \*\*Type\*\*: Validating. The PodSecurity admission controller checks new Pods before they are admitted, determines if it should be admitted based on the requested security context and the restrictions on permitted [Pod Security Standards](/docs/concepts/security/pod-security-standards/) for the namespace that the Pod would be in. See the [Pod Security Admission](/docs/concepts/security/pod-security-admission/) documentation for more information. PodSecurity replaced an older admission controller named PodSecurityPolicy. ### PodTolerationRestriction {#podtolerationrestriction} {{< feature-state for\_k8s\_version="v1.7" state="alpha" >}} \*\*Type\*\*: Mutating and Validating. The PodTolerationRestriction admission controller verifies any conflict between tolerations of a pod and the tolerations of its namespace. It rejects the pod request if there is a conflict. It then merges the tolerations annotated on the namespace into the tolerations of the pod. The resulting tolerations are checked against a list of allowed tolerations annotated to the namespace. If the check succeeds, the pod request is admitted otherwise it is rejected. If the namespace of the pod does not have any associated default tolerations or allowed tolerations annotated, the cluster-level default tolerations or cluster-level list of allowed tolerations are used instead if they are specified. Tolerations | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/admission-controllers.md | main | kubernetes | [
-0.004177080001682043,
0.04995721951127052,
-0.011621098965406418,
-0.0060440064407885075,
0.03915046900510788,
0.016536468639969826,
0.08021806925535202,
0.01415347307920456,
-0.013677606359124184,
0.09294199198484421,
0.02487560734152794,
0.015857994556427002,
0.0343206450343132,
0.01986... | 0.086386 |
the namespace. If the check succeeds, the pod request is admitted otherwise it is rejected. If the namespace of the pod does not have any associated default tolerations or allowed tolerations annotated, the cluster-level default tolerations or cluster-level list of allowed tolerations are used instead if they are specified. Tolerations to a namespace are assigned via the `scheduler.alpha.kubernetes.io/defaultTolerations` annotation key. The list of allowed tolerations can be added via the `scheduler.alpha.kubernetes.io/tolerationsWhitelist` annotation key. Example for namespace annotations: ```yaml apiVersion: v1 kind: Namespace metadata: name: apps-that-need-nodes-exclusively annotations: scheduler.alpha.kubernetes.io/defaultTolerations: '[{"operator": "Exists", "effect": "NoSchedule", "key": "dedicated-node"}]' scheduler.alpha.kubernetes.io/tolerationsWhitelist: '[{"operator": "Exists", "effect": "NoSchedule", "key": "dedicated-node"}]' ``` This admission controller is disabled by default. ### PodTopologyLabels {#podtopologylabels} {{< feature-state feature\_gate\_name="PodTopologyLabelsAdmission" >}} \*\*Type\*\*: Mutating The PodTopologyLabels admission controller mutates the `pods/binding` subresources for all pods bound to a Node, adding topology labels matching those of the bound Node. This allows Node topology labels to be available as pod labels, which can be surfaced to running containers using the [Downward API](docs/concepts/workloads/pods/downward-api/). The labels available as a result of this controller are the [topology.kubernetes.io/region](docs/reference/labels-annotations-taints/#topologykubernetesioregion) and [topology.kuberentes.io/zone](docs/reference/labels-annotations-taints/#topologykubernetesiozone) labels. {{}} If any mutating admission webhook adds or modifies labels of the `pods/binding` subresource, these changes will propagate to pod labels as a result of this controller, overwriting labels with conflicting keys. {{}} This admission controller is enabled when the `PodTopologyLabelsAdmission` feature gate is enabled. ### Priority {#priority} \*\*Type\*\*: Mutating and Validating. The priority admission controller uses the `priorityClassName` field and populates the integer value of the priority. If the priority class is not found, the Pod is rejected. ### ResourceQuota {#resourcequota} \*\*Type\*\*: Validating. This admission controller will observe the incoming request and ensure that it does not violate any of the constraints enumerated in the `ResourceQuota` object in a `Namespace`. If you are using `ResourceQuota` objects in your Kubernetes deployment, you MUST use this admission controller to enforce quota constraints. See the [ResourceQuota API reference](/docs/reference/kubernetes-api/policy-resources/resource-quota-v1/) and the [example of Resource Quota](/docs/concepts/policy/resource-quotas/) for more details. ### RuntimeClass {#runtimeclass} \*\*Type\*\*: Mutating and Validating. If you define a RuntimeClass with [Pod overhead](/docs/concepts/scheduling-eviction/pod-overhead/) configured, this admission controller checks incoming Pods. When enabled, this admission controller rejects any Pod create requests that have the overhead already set. For Pods that have a RuntimeClass configured and selected in their `.spec`, this admission controller sets `.spec.overhead` in the Pod based on the value defined in the corresponding RuntimeClass. See also [Pod Overhead](/docs/concepts/scheduling-eviction/pod-overhead/) for more information. ### ServiceAccount {#serviceaccount} \*\*Type\*\*: Mutating and Validating. This admission controller implements automation for [serviceAccounts](/docs/tasks/configure-pod-container/configure-service-account/). The Kubernetes project strongly recommends enabling this admission controller. You should enable this admission controller if you intend to make any use of Kubernetes `ServiceAccount` objects. To enhance the security measures around Secrets, use separate namespaces to isolate access to mounted secrets. ### StorageObjectInUseProtection \*\*Type\*\*: Mutating. The `StorageObjectInUseProtection` plugin adds the `kubernetes.io/pvc-protection` or `kubernetes.io/pv-protection` finalizers to newly created Persistent Volume Claims (PVCs) or Persistent Volumes (PV). In case a user deletes a PVC or PV the PVC or PV is not removed until the finalizer is removed from the PVC or PV by PVC or PV Protection Controller. Refer to the [Storage Object in Use Protection](/docs/concepts/storage/persistent-volumes/#storage-object-in-use-protection) for more detailed information. ### TaintNodesByCondition {#taintnodesbycondition} \*\*Type\*\*: Mutating. This admission controller {{< glossary\_tooltip text="taints" term\_id="taint" >}} newly created Nodes as `NotReady` and `NoSchedule`. That tainting avoids a race condition that could cause Pods to be scheduled on new Nodes before their taints were updated to accurately reflect their reported conditions. ### ValidatingAdmissionPolicy {#validatingadmissionpolicy} \*\*Type\*\*: Validating. [This admission controller](/docs/reference/access-authn-authz/validating-admission-policy/) implements the CEL validation for incoming matched requests. It is enabled when both feature gate `validatingadmissionpolicy` and `admissionregistration.k8s.io/v1alpha1` group/version are enabled. If any of | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/admission-controllers.md | main | kubernetes | [
0.02185858227312565,
-0.019983839243650436,
0.04047798737883568,
0.03338493034243584,
0.06874577701091766,
-0.022991564124822617,
0.041687946766614914,
-0.10898227989673615,
0.06914355605840683,
0.04321276769042015,
-0.05122046917676926,
-0.06685328483581543,
-0.026431318372488022,
0.02650... | 0.187753 |
Pods to be scheduled on new Nodes before their taints were updated to accurately reflect their reported conditions. ### ValidatingAdmissionPolicy {#validatingadmissionpolicy} \*\*Type\*\*: Validating. [This admission controller](/docs/reference/access-authn-authz/validating-admission-policy/) implements the CEL validation for incoming matched requests. It is enabled when both feature gate `validatingadmissionpolicy` and `admissionregistration.k8s.io/v1alpha1` group/version are enabled. If any of the ValidatingAdmissionPolicy fails, the request fails. ### ValidatingAdmissionWebhook {#validatingadmissionwebhook} \*\*Type\*\*: Validating. This admission controller calls any validating webhooks which match the request. Matching webhooks are called in parallel; if any of them rejects the request, the request fails. This admission controller only runs in the validation phase; the webhooks it calls may not mutate the object, as opposed to the webhooks called by the `MutatingAdmissionWebhook` admission controller. If a webhook called by this has side effects (for example, decrementing quota) it \*must\* have a reconciliation system, as it is not guaranteed that subsequent webhooks or other validating admission controllers will permit the request to finish. If you disable the ValidatingAdmissionWebhook, you must also disable the `ValidatingWebhookConfiguration` object in the `admissionregistration.k8s.io/v1` group/version via the `--runtime-config` flag. ## Is there a recommended set of admission controllers to use? Yes. The recommended admission controllers are enabled by default (shown [here](/docs/reference/command-line-tools-reference/kube-apiserver/#options)), so you do not need to explicitly specify them. You can enable additional admission controllers beyond the default set using the `--enable-admission-plugins` flag (\*\*order doesn't matter\*\*). | https://github.com/kubernetes/website/blob/main//content/en/docs/reference/access-authn-authz/admission-controllers.md | main | kubernetes | [
-0.00696900486946106,
-0.0030746045522391796,
0.10137443989515305,
-0.00527278333902359,
0.026825720444321632,
-0.03801336511969566,
0.013714499771595001,
-0.05643581971526146,
0.025067677721381187,
0.024308878928422928,
-0.015980245545506477,
-0.05914997681975365,
0.02321801520884037,
0.0... | 0.092556 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.