Skip to content

Commit 78351ec

Browse files
author
Tim Bannister
committed
Transfer “Controlling Access to the Kubernetes API” to the Concepts section
Readers from several different backgrounds will find it useful to know about how Kubernetes controls access to its API. Promote this overview to the Security subsection of Concepts.
1 parent 3edb970 commit 78351ec

File tree

13 files changed

+108
-60
lines changed

13 files changed

+108
-60
lines changed

content/en/docs/concepts/cluster-administration/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Before choosing a guide, here are some considerations:
5151

5252
* [Kubernetes Container Environment](/docs/concepts/containers/container-environment/) describes the environment for Kubelet managed containers on a Kubernetes node.
5353

54-
* [Controlling Access to the Kubernetes API](/docs/reference/access-authn-authz/controlling-access/) describes how to set up permissions for users and service accounts.
54+
* [Controlling Access to the Kubernetes API](/docs/concepts/security/controlling-access) describes how Kubernetes implements access control for its own API.
5555

5656
* [Authenticating](/docs/reference/access-authn-authz/authentication/) explains authentication in Kubernetes, including the various authentication options.
5757

content/en/docs/concepts/extend-kubernetes/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Adding an API does not directly let you affect the behavior of existing APIs (e.
130130

131131
### API Access Extensions
132132

133-
When a request reaches the Kubernetes API Server, it is first Authenticated, then Authorized, then subject to various types of Admission Control. See [Controlling Access to the Kubernetes API](/docs/reference/access-authn-authz/controlling-access/) for more on this flow.
133+
When a request reaches the Kubernetes API Server, it is first Authenticated, then Authorized, then subject to various types of Admission Control. See [Controlling Access to the Kubernetes API](/docs/concepts/security/controlling-access/) for more on this flow.
134134

135135
Each of these steps offers extension points.
136136

content/en/docs/concepts/extend-kubernetes/extend-cluster.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Adding an API does not directly let you affect the behavior of existing APIs (e.
131131

132132
### API Access Extensions
133133

134-
When a request reaches the Kubernetes API Server, it is first Authenticated, then Authorized, then subject to various types of Admission Control. See [Controlling Access to the Kubernetes API](/docs/reference/access-authn-authz/controlling-access/) for more on this flow.
134+
When a request reaches the Kubernetes API Server, it is first Authenticated, then Authorized, then subject to various types of Admission Control. See [Controlling Access to the Kubernetes API](/docs/concepts/security/controlling-access/) for more on this flow.
135135

136136
Each of these steps offers extension points.
137137

content/en/docs/concepts/overview/kubernetes-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ The Kubernetes API can be extended in one of two ways:
131131

132132
- Learn how to extend the Kubernetes API by adding your own
133133
[CustomResourceDefinition](/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/).
134-
- [Controlling API Access](/docs/reference/access-authn-authz/controlling-access/) describes
134+
- [Controlling Access To The Kubernetes API](/docs/concepts/security/controlling-access/) describes
135135
how the cluster manages authentication and authorization for API access.
136136
- Learn about API endpoints, resource types and samples by reading
137137
[API Reference](/docs/reference/kubernetes-api/).

content/en/docs/concepts/policy/pod-security-policy.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,17 @@ For a complete example of authorizing a PodSecurityPolicy, see
140140

141141
### Troubleshooting
142142

143-
- The [Controller Manager](/docs/reference/command-line-tools-reference/kube-controller-manager/) must be run
144-
against [the secured API port](/docs/reference/access-authn-authz/controlling-access/),
145-
and must not have superuser permissions. Otherwise requests would bypass
146-
authentication and authorization modules, all PodSecurityPolicy objects would be
147-
allowed, and users would be able to create privileged containers. For more details
148-
on configuring Controller Manager authorization, see
149-
[Controller Roles](/docs/reference/access-authn-authz/rbac/#controller-roles).
143+
- The [controller manager](/docs/reference/command-line-tools-reference/kube-controller-manager/)
144+
must be run against the secured API port and must not have superuser permissions. See
145+
[Controlling Access to the Kubernetes API](/docs/concepts/security/controlling-access)
146+
to learn about API server access controls.
147+
If the controller manager connected through the trusted API port (also known as the
148+
`localhost` listener), requests would bypass authentication and authorization modules;
149+
all PodSecurityPolicy objects would be allowed, and users would be able to create grant
150+
themselves the ability to create privileged containers.
151+
152+
For more details on configuring controller manager authorization, see
153+
[Controller Roles](/docs/reference/access-authn-authz/rbac/#controller-roles).
150154

151155
## Policy Order
152156

content/en/docs/reference/access-authn-authz/controlling-access.md renamed to content/en/docs/concepts/security/controlling-access.md

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ reviewers:
44
- lavalamp
55
title: Controlling Access to the Kubernetes API
66
content_type: concept
7-
weight: 5
87
---
98

109
<!-- overview -->
1110
This page provides an overview of controlling access to the Kubernetes API.
1211

1312

1413
<!-- body -->
15-
Users [access the API](/docs/tasks/access-application-cluster/access-cluster/) using `kubectl`,
14+
Users access the [Kubernetes API](/docs/concepts/overview/kubernetes-api/) using `kubectl`,
1615
client libraries, or by making REST requests. Both human users and
1716
[Kubernetes service accounts](/docs/tasks/configure-pod-container/configure-service-account/) can be
1817
authorized for API access.
@@ -21,45 +20,46 @@ following diagram:
2120

2221
![Diagram of request handling steps for Kubernetes API request](/images/docs/admin/access-control-overview.svg)
2322

24-
## Transport Security
23+
## Transport security
2524

26-
In a typical Kubernetes cluster, the API serves on port 443.
27-
The API server presents a certificate. This certificate is
28-
often self-signed, so `$USER/.kube/config` on the user's machine typically
29-
contains the root certificate for the API server's certificate, which when specified
30-
is used in place of the system default root certificate. This certificate is typically
31-
automatically written into your `$USER/.kube/config` when you create a cluster yourself
32-
using `kube-up.sh`. If the cluster has multiple users, then the creator needs to share
33-
the certificate with other users.
25+
In a typical Kubernetes cluster, the API serves on port 443, protected by TLS.
26+
The API server presents a certificate. This certificate may be signed using
27+
a private certificate authority (CA), or based on a public key infrastructure linked
28+
to a generally recognized CA.
29+
30+
If your cluster uses a private certificate authority, you need a copy of that CA
31+
certifcate configured into your `~/.kube/config` on the client, so that you can
32+
trust the connection and be confident it was not intercepted.
33+
34+
Your client can present a TLS client certificate at this stage.
3435

3536
## Authentication
3637

3738
Once TLS is established, the HTTP request moves to the Authentication step.
3839
This is shown as step **1** in the diagram.
3940
The cluster creation script or cluster admin configures the API server to run
40-
one or more Authenticator Modules.
41-
Authenticators are described in more detail [here](/docs/reference/access-authn-authz/authentication/).
41+
one or more Authenticator modules.
42+
Authenticators are described in more detail in
43+
[Authentication](/docs/reference/access-authn-authz/authentication/).
4244

43-
The input to the authentication step is the entire HTTP request, however, it typically
45+
The input to the authentication step is the entire HTTP request; however, it typically
4446
just examines the headers and/or client certificate.
4547

46-
Authentication modules include Client Certificates, Password, and Plain Tokens,
47-
Bootstrap Tokens, and JWT Tokens (used for service accounts).
48+
Authentication modules include client certificates, password, and plain tokens,
49+
bootstrap tokens, and JSON Web Tokens (used for service accounts).
4850

4951
Multiple authentication modules can be specified, in which case each one is tried in sequence,
5052
until one of them succeeds.
5153

52-
On GCE, Client Certificates, Password, Plain Tokens, and JWT Tokens are all enabled.
53-
5454
If the request cannot be authenticated, it is rejected with HTTP status code 401.
5555
Otherwise, the user is authenticated as a specific `username`, and the user name
5656
is available to subsequent steps to use in their decisions. Some authenticators
5757
also provide the group memberships of the user, while other authenticators
5858
do not.
5959

60-
While Kubernetes uses `usernames` for access control decisions and in request logging,
61-
it does not have a `user` object nor does it store usernames or other information about
62-
users in its object store.
60+
While Kubernetes uses usernames for access control decisions and in request logging,
61+
it does not have a `User` object nor does it store usernames or other information about
62+
users in its API.
6363

6464
## Authorization
6565

@@ -101,43 +101,43 @@ If Bob makes a request to write (`create` or `update`) to the objects in the `pr
101101

102102
Kubernetes authorization requires that you use common REST attributes to interact with existing organization-wide or cloud-provider-wide access control systems. It is important to use REST formatting because these control systems might interact with other APIs besides the Kubernetes API.
103103

104-
Kubernetes supports multiple authorization modules, such as ABAC mode, RBAC Mode, and Webhook mode. When an administrator creates a cluster, they configured the authorization modules that should be used in the API server. If more than one authorization modules are configured, Kubernetes checks each module, and if any module authorizes the request, then the request can proceed. If all of the modules deny the request, then the request is denied (HTTP status code 403).
104+
Kubernetes supports multiple authorization modules, such as ABAC mode, RBAC Mode, and Webhook mode. When an administrator creates a cluster, they configure the authorization modules that should be used in the API server. If more than one authorization modules are configured, Kubernetes checks each module, and if any module authorizes the request, then the request can proceed. If all of the modules deny the request, then the request is denied (HTTP status code 403).
105105

106-
To learn more about Kubernetes authorization, including details about creating policies using the supported authorization modules, see [Authorization Overview](/docs/reference/access-authn-authz/authorization/).
106+
To learn more about Kubernetes authorization, including details about creating policies using the supported authorization modules, see [Authorization](/docs/reference/access-authn-authz/authorization/).
107107

108108

109-
## Admission Control
109+
## Admission control
110110

111-
Admission Control Modules are software modules that can modify or reject requests.
112-
In addition to the attributes available to Authorization Modules, Admission
113-
Control Modules can access the contents of the object that is being created or modified.
111+
Admission Control modules are software modules that can modify or reject requests.
112+
In addition to the attributes available to Authorization modules, Admission
113+
Control modules can access the contents of the object that is being created or modified.
114114

115115
Admission controllers act on requests that create, modify, delete, or connect to (proxy) an object.
116116
Admission controllers do not act on requests that merely read objects.
117117
When multiple admission controllers are configured, they are called in order.
118118

119119
This is shown as step **3** in the diagram.
120120

121-
Unlike Authentication and Authorization Modules, if any admission controller module
121+
Unlike Authentication and Authorization modules, if any admission controller module
122122
rejects, then the request is immediately rejected.
123123

124124
In addition to rejecting objects, admission controllers can also set complex defaults for
125125
fields.
126126

127-
The available Admission Control Modules are described [here](/docs/reference/access-authn-authz/admission-controllers/).
127+
The available Admission Control modules are described in [Admission Controllers](/docs/reference/access-authn-authz/admission-controllers/).
128128

129129
Once a request passes all admission controllers, it is validated using the validation routines
130130
for the corresponding API object, and then written to the object store (shown as step **4**).
131131

132132

133-
## API Server Ports and IPs
133+
## API server ports and IPs
134134

135135
The previous discussion applies to requests sent to the secure port of the API server
136136
(the typical case). The API server can actually serve on 2 ports:
137137

138138
By default the Kubernetes API server serves HTTP on 2 ports:
139139

140-
1. `Localhost Port`:
140+
1. `localhost` port:
141141

142142
- is intended for testing and bootstrap, and for other components of the master node
143143
(scheduler, controller-manager) to talk to the API
@@ -148,7 +148,7 @@ By default the Kubernetes API server serves HTTP on 2 ports:
148148
- request handled by admission control module(s).
149149
- protected by need to have host access
150150

151-
2. `Secure Port`:
151+
2. Secure port”:
152152

153153
- use whenever possible
154154
- uses TLS. Set cert with `--tls-cert-file` and key with `--tls-private-key-file` flag.
@@ -158,8 +158,27 @@ By default the Kubernetes API server serves HTTP on 2 ports:
158158
- request handled by admission control module(s).
159159
- authentication and authorization modules run.
160160

161-
When the cluster is created by `kube-up.sh`, on Google Compute Engine (GCE),
162-
and on several other cloud providers, the API server serves on port 443. On
163-
GCE, a firewall rule is configured on the project to allow external HTTPS
164-
access to the API. Other cluster setup methods vary.
165-
161+
## {{% heading "whatsnext" %}}
162+
163+
Read more documentation on authentication, authorization and API access control:
164+
165+
- [Authenticating](/docs/reference/access-authn-authz/authentication/)
166+
- [Authenticating with Bootstrap Tokens](/docs/reference/access-authn-authz/bootstrap-tokens/)
167+
- [Admission Controllers](/docs/reference/access-authn-authz/admission-controllers/)
168+
- [Dynamic Admission Control](/docs/reference/access-authn-authz/extensible-admission-controllers/)
169+
- [Authorization](/docs/reference/access-authn-authz/authorization/)
170+
- [Role Based Access Control](/docs/reference/access-authn-authz/rbac/)
171+
- [Attribute Based Access Control](/docs/reference/access-authn-authz/abac/)
172+
- [Node Authorization](/docs/reference/access-authn-authz/node/)
173+
- [Webhook Authorization](/docs/reference/access-authn-authz/webhook/)
174+
- [Certificate Signing Requests](/docs/reference/access-authn-authz/certificate-signing-requests/)
175+
- including [CSR approval](/docs/reference/access-authn-authz/certificate-signing-requests/#approval-rejection)
176+
and [certificate signing](/docs/reference/access-authn-authz/certificate-signing-requests/#signing)
177+
- Service accounts
178+
- [Developer guide](/docs/tasks/configure-pod-container/configure-service-account/)
179+
- [Administration](/docs/reference/access-authn-authz/service-accounts-admin/)
180+
181+
You can learn about:
182+
- how Pods can use
183+
[Secrets](/docs/concepts/configuration/secret/#service-accounts-automatically-create-and-attach-secrets-with-api-credentials)
184+
to obtain API credentials.

content/en/docs/concepts/security/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ areas of security concerns and recommendations for securing workloads running in
103103
Area of Concern for Workload Security | Recommendation |
104104
------------------------------ | --------------------- |
105105
RBAC Authorization (Access to the Kubernetes API) | https://kubernetes.io/docs/reference/access-authn-authz/rbac/
106-
Authentication | https://kubernetes.io/docs/reference/access-authn-authz/controlling-access/
106+
Authentication | https://kubernetes.io/docs/concepts/security/controlling-access/
107107
Application secrets management (and encrypting them in etcd at rest) | https://kubernetes.io/docs/concepts/configuration/secret/ <br> https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/
108108
Pod Security Policies | https://kubernetes.io/docs/concepts/policy/pod-security-policy/
109109
Quality of Service (and Cluster resource management) | https://kubernetes.io/docs/tasks/configure-pod-container/quality-service-pod/
@@ -147,8 +147,8 @@ Learn about related Kubernetes security topics:
147147

148148
* [Pod security standards](/docs/concepts/security/pod-security-standards/)
149149
* [Network policies for Pods](/docs/concepts/services-networking/network-policies/)
150+
* [Controlling Access to the Kubernetes API](/docs/concepts/security/controlling-access)
150151
* [Securing your cluster](/docs/tasks/administer-cluster/securing-a-cluster/)
151-
* [API access control](/docs/reference/access-authn-authz/controlling-access/)
152152
* [Data encryption in transit](/docs/tasks/tls/managing-tls-in-a-cluster/) for the control plane
153153
* [Data encryption at rest](/docs/tasks/administer-cluster/encrypt-data/)
154154
* [Secrets in Kubernetes](/docs/concepts/configuration/secret/)
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
---
2-
title: Accessing the API
2+
title: API Access Control
33
weight: 20
4-
---
4+
no_list: true
5+
---
6+
7+
For an introduction to how Kubernetes implements and controls API access,
8+
read [Controlling Access to the Kubernetes API](/docs/concepts/security/controlling-access/).
9+
10+
Reference documentation:
11+
12+
- [Authenticating](/docs/reference/access-authn-authz/authentication/)
13+
- [Authenticating with Bootstrap Tokens](/docs/reference/access-authn-authz/bootstrap-tokens/)
14+
- [Admission Controllers](/docs/reference/access-authn-authz/admission-controllers/)
15+
- [Dynamic Admission Control](/docs/reference/access-authn-authz/extensible-admission-controllers/)
16+
- [Authorization](/docs/reference/access-authn-authz/authorization/)
17+
- [Role Based Access Control](/docs/reference/access-authn-authz/rbac/)
18+
- [Attribute Based Access Control](/docs/reference/access-authn-authz/abac/)
19+
- [Node Authorization](/docs/reference/access-authn-authz/node/)
20+
- [Webhook Authorization](/docs/reference/access-authn-authz/webhook/)
21+
- [Certificate Signing Requests](/docs/reference/access-authn-authz/certificate-signing-requests/)
22+
- including [CSR approval](/docs/reference/access-authn-authz/certificate-signing-requests/#approval-rejection)
23+
and [certificate signing](/docs/reference/access-authn-authz/certificate-signing-requests/#signing)
24+
- Service accounts
25+
- [Developer guide](/docs/tasks/configure-pod-container/configure-service-account/)
26+
- [Administration](/docs/reference/access-authn-authz/service-accounts-admin/)

content/en/docs/reference/access-authn-authz/authorization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ policies using the supported authorization modules.
1717
<!-- body -->
1818
In Kubernetes, you must be authenticated (logged in) before your request can be
1919
authorized (granted permission to access). For information about authentication,
20-
see [Controlling Access to the Kubernetes API](/docs/reference/access-authn-authz/controlling-access/).
20+
see [Controlling Access to the Kubernetes API](/docs/concepts/security/controlling-access/).
2121

2222
Kubernetes expects attributes that are common to REST API requests. This means
2323
that Kubernetes authorization works with existing organization-wide or

content/en/docs/reference/using-api/_index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ lists the API for Kubernetes version {{< param "version" >}}.
2727

2828
For general background information, read
2929
[The Kubernetes API](/docs/concepts/overview/kubernetes-api/).
30+
[Controlling Access to the Kubernetes API](/docs/concepts/security/controlling-access/)
31+
describes how clients can authenticate to the Kubernetes API server, and how their
32+
requests are authorized.
3033

3134
<!-- body -->
3235

0 commit comments

Comments
 (0)