You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/concepts/security/controlling-access.md
+29-10Lines changed: 29 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,6 @@ weight: 50
10
10
<!-- overview -->
11
11
This page provides an overview of controlling access to the Kubernetes API.
12
12
13
-
14
13
<!-- body -->
15
14
Users access the [Kubernetes API](/docs/concepts/overview/kubernetes-api/) using `kubectl`,
16
15
client libraries, or by making REST requests. Both human users and
@@ -23,11 +22,15 @@ following diagram:
23
22
24
23
## Transport security
25
24
26
-
By default, the Kubernetes API server listens on port 6443 on the first non-localhost network interface, protected by TLS. In a typical production Kubernetes cluster, the API serves on port 443. The port can be changed with the `--secure-port`, and the listening IP address with the `--bind-address` flag.
25
+
By default, the Kubernetes API server listens on port 6443 on the first non-localhost
26
+
network interface, protected by TLS. In a typical production Kubernetes cluster, the
27
+
API serves on port 443. The port can be changed with the `--secure-port`, and the
28
+
listening IP address with the `--bind-address` flag.
27
29
28
30
The API server presents a certificate. This certificate may be signed using
29
31
a private certificate authority (CA), or based on a public key infrastructure linked
30
-
to a generally recognized CA. The certificate and corresponding private key can be set by using the `--tls-cert-file` and `--tls-private-key-file` flags.
32
+
to a generally recognized CA. The certificate and corresponding private key can be set
33
+
by using the `--tls-cert-file` and `--tls-private-key-file` flags.
31
34
32
35
If your cluster uses a private certificate authority, you need a copy of that CA
33
36
certificate configured into your `~/.kube/config` on the client, so that you can
@@ -65,9 +68,12 @@ users in its API.
65
68
66
69
## Authorization
67
70
68
-
After the request is authenticated as coming from a specific user, the request must be authorized. This is shown as step **2** in the diagram.
71
+
After the request is authenticated as coming from a specific user, the request must
72
+
be authorized. This is shown as step **2** in the diagram.
69
73
70
-
A request must include the username of the requester, the requested action, and the object affected by the action. The request is authorized if an existing policy declares that the user has permissions to complete the requested action.
74
+
A request must include the username of the requester, the requested action, and
75
+
the object affected by the action. The request is authorized if an existing policy
76
+
declares that the user has permissions to complete the requested action.
71
77
72
78
For example, if Bob has the policy below, then he can read pods only in the namespace `projectCaribou`:
73
79
@@ -83,7 +89,9 @@ For example, if Bob has the policy below, then he can read pods only in the name
83
89
}
84
90
}
85
91
```
86
-
If Bob makes the following request, the request is authorized because he is allowed to read objects in the `projectCaribou` namespace:
92
+
93
+
If Bob makes the following request, the request is authorized because he is
94
+
allowed to read objects in the `projectCaribou` namespace:
87
95
88
96
```json
89
97
{
@@ -99,14 +107,25 @@ If Bob makes the following request, the request is authorized because he is allo
99
107
}
100
108
}
101
109
```
102
-
If Bob makes a request to write (`create` or `update`) to the objects in the `projectCaribou` namespace, his authorization is denied. If Bob makes a request to read (`get`) objects in a different namespace such as `projectFish`, then his authorization is denied.
103
110
104
-
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.
111
+
If Bob makes a request to write (`create` or `update`) to the objects in the
112
+
`projectCaribou` namespace, his authorization is denied. If Bob makes a request
113
+
to read (`get`) objects in a different namespace such as `projectFish`, then his authorization is denied.
105
114
106
-
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).
115
+
Kubernetes authorization requires that you use common REST attributes to interact
116
+
with existing organization-wide or cloud-provider-wide access control systems.
117
+
It is important to use REST formatting because these control systems might
118
+
interact with other APIs besides the Kubernetes API.
107
119
108
-
To learn more about Kubernetes authorization, including details about creating policies using the supported authorization modules, see [Authorization](/docs/reference/access-authn-authz/authorization/).
120
+
Kubernetes supports multiple authorization modules, such as ABAC mode, RBAC Mode,
121
+
and Webhook mode. When an administrator creates a cluster, they configure the
122
+
authorization modules that should be used in the API server. If more than one
123
+
authorization modules are configured, Kubernetes checks each module, and if
124
+
any module authorizes the request, then the request can proceed. If all of
125
+
the modules deny the request, then the request is denied (HTTP status code 403).
109
126
127
+
To learn more about Kubernetes authorization, including details about creating
128
+
policies using the supported authorization modules, see [Authorization](/docs/reference/access-authn-authz/authorization/).
For clarity, this guide defines the following terms:
24
23
25
24
* Node: A worker machine in Kubernetes, part of a cluster.
26
-
* Cluster: A set of Nodes that run containerized applications managed by Kubernetes. For this example, and in most common Kubernetes deployments, nodes in the cluster are not part of the public internet.
27
-
* Edge router: A router that enforces the firewall policy for your cluster. This could be a gateway managed by a cloud provider or a physical piece of hardware.
28
-
* Cluster network: A set of links, logical or physical, that facilitate communication within a cluster according to the Kubernetes [networking model](/docs/concepts/cluster-administration/networking/).
29
-
* Service: A Kubernetes {{< glossary_tooltip term_id="service" >}} that identifies a set of Pods using {{< glossary_tooltip text="label" term_id="label" >}} selectors. Unless mentioned otherwise, Services are assumed to have virtual IPs only routable within the cluster network.
25
+
* Cluster: A set of Nodes that run containerized applications managed by Kubernetes.
26
+
For this example, and in most common Kubernetes deployments, nodes in the cluster
27
+
are not part of the public internet.
28
+
* Edge router: A router that enforces the firewall policy for your cluster. This
29
+
could be a gateway managed by a cloud provider or a physical piece of hardware.
30
+
* Cluster network: A set of links, logical or physical, that facilitate communication
31
+
within a cluster according to the Kubernetes [networking model](/docs/concepts/cluster-administration/networking/).
32
+
* Service: A Kubernetes {{< glossary_tooltip term_id="service" >}} that identifies
33
+
a set of Pods using {{< glossary_tooltip text="label" term_id="label" >}} selectors.
34
+
Unless mentioned otherwise, Services are assumed to have virtual IPs only routable within the cluster network.
30
35
31
36
## What is Ingress?
32
37
33
-
[Ingress](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#ingress-v1-networking-k8s-io) exposes HTTP and HTTPS routes from outside the cluster to
An Ingress may be configured to give Services externally-reachable URLs, load balance traffic, terminate SSL / TLS, and offer name-based virtual hosting. An [Ingress controller](/docs/concepts/services-networking/ingress-controllers) is responsible for fulfilling the Ingress, usually with a load balancer, though it may also configure your edge router or additional frontends to help handle the traffic.
47
+
An Ingress may be configured to give Services externally-reachable URLs,
You must have an [Ingress controller](/docs/concepts/services-networking/ingress-controllers) to satisfy an Ingress. Only creating an Ingress resource has no effect.
59
+
You must have an [Ingress controller](/docs/concepts/services-networking/ingress-controllers)
60
+
to satisfy an Ingress. Only creating an Ingress resource has no effect.
50
61
51
-
You may need to deploy an Ingress controller such as [ingress-nginx](https://kubernetes.github.io/ingress-nginx/deploy/). You can choose from a number of
For general information about working with config files, see [deploying applications](/docs/tasks/run-application/run-stateless-application-deployment/), [configuring containers](/docs/tasks/configure-pod-container/configure-pod-configmap/), [managing resources](/docs/concepts/cluster-administration/manage-deployment/).
71
-
Ingress frequently uses annotations to configure some options depending on the Ingress controller, an example of which
72
-
is the [rewrite-target annotation](https://github.com/kubernetes/ingress-nginx/blob/main/docs/examples/rewrite/README.md).
73
-
Different [Ingress controllers](/docs/concepts/services-networking/ingress-controllers) support different annotations. Review the documentation for
74
-
your choice of Ingress controller to learn which annotations are supported.
82
+
Ingress frequently uses annotations to configure some options depending on the Ingress controller, an example of which
83
+
is the [rewrite-target annotation](https://github.com/kubernetes/ingress-nginx/blob/main/docs/examples/rewrite/README.md).
84
+
Different [Ingress controllers](/docs/concepts/services-networking/ingress-controllers) support different annotations.
85
+
Review the documentation for your choice of Ingress controller to learn which annotations are supported.
75
86
76
87
The Ingress [spec](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status)
77
88
has all the information needed to configure a load balancer or proxy server. Most importantly, it
@@ -100,7 +111,8 @@ Each HTTP rule contains the following information:
100
111
incoming request before the load balancer directs traffic to the referenced
101
112
Service.
102
113
* A backend is a combination of Service and port names as described in the
103
-
[Service doc](/docs/concepts/services-networking/service/) or a [custom resource backend](#resource-backend) by way of a {{< glossary_tooltip term_id="CustomResourceDefinition" text="CRD" >}}. HTTP (and HTTPS) requests to the
114
+
[Service doc](/docs/concepts/services-networking/service/) or a [custom resource backend](#resource-backend)
115
+
by way of a {{< glossary_tooltip term_id="CustomResourceDefinition" text="CRD" >}}. HTTP (and HTTPS) requests to the
104
116
Ingress that match the host and path of the rule are sent to the listed backend.
105
117
106
118
A `defaultBackend` is often configured in an Ingress controller to service any requests that do not
@@ -168,9 +180,11 @@ supported path types:
168
180
match for path _p_ if every _p_ is an element-wise prefix of _p_ of the
169
181
request path.
170
182
171
-
{{< note >}} If the last element of the path is a substring of the last
183
+
{{< note >}}
184
+
If the last element of the path is a substring of the last
172
185
element in request path, it is not a match (for example: `/foo/bar`
173
-
matches `/foo/bar/baz`, but does not match `/foo/barbaz`). {{< /note >}}
186
+
matches `/foo/bar/baz`, but does not match `/foo/barbaz`).
@@ -435,7 +453,6 @@ Name-based virtual hosts support routing HTTP traffic to multiple host names at
435
453
436
454
{{< figure src="/docs/images/ingressNameBased.svg" alt="ingress-namebase-diagram" class="diagram-large" caption="Figure. Ingress Name Based Virtual hosting" link="https://mermaid.live/edit#pako:eNqNkl9PwyAUxb8KYS-atM1Kp05m9qSJJj4Y97jugcLtRqTQAPVPdN_dVlq3qUt8gZt7zvkBN7xjbgRgiteW1Rt0_zjLNUJcSdD-ZBn21WmcoDu9tuBcXDHN1iDQVWHnSBkmUMEU0xwsSuK5DK5l745QejFNLtMkJVmSZmT1Re9NcTz_uDXOU1QakxTMJtxUHw7ss-SQLhehQEODTsdH4l20Q-zFyc84-Y67pghv5apxHuweMuj9eS2_NiJdPhix-kMgvwQShOyYMNkJoEUYM3PuGkpUKyY1KqVSdCSEiJy35gnoqCzLvo5fpPAbOqlfI26UsXQ0Ho9nB5CnqesRGTnncPYvSqsdUvqp9KRdlI6KojjEkB0mnLgjDRONhqENBYm6oXbLV5V1y6S7-l42_LowlIN2uFm_twqOcAW2YlK0H_i9c-bYb6CCHNO2FFCyRvkc53rbWptaMA83QnpjMS2ZchBh1nizeNMcU28bGEzXkrV_pArN7Sc0rBTu" >}}
437
455
438
-
439
456
The following Ingress tells the backing load balancer to route requests based on
440
457
the [Host header](https://tools.ietf.org/html/rfc7230#section-5.4).
441
458
@@ -446,7 +463,9 @@ web traffic to the IP address of your Ingress controller can be matched without
446
463
virtual host being required.
447
464
448
465
For example, the following Ingress routes traffic
449
-
requested for `first.bar.com` to `service1`, `second.bar.com` to `service2`, and any traffic whose request host header doesn't match `first.bar.com` and `second.bar.com` to `service3`.
466
+
requested for `first.bar.com` to `service1`, `second.bar.com` to `service2`,
467
+
and any traffic whose request host header doesn't match `first.bar.com`
@@ -25,7 +23,6 @@ topology of the cluster. For example, a service can specify that traffic be
25
23
preferentially routed to endpoints that are on the same Node as the client, or
26
24
in the same availability zone.
27
25
28
-
29
26
<!-- body -->
30
27
31
28
## Topology-aware traffic routing
@@ -51,7 +48,8 @@ same top-of-rack switch for the lowest latency.
51
48
52
49
## Using Service Topology
53
50
54
-
If your cluster has the `ServiceTopology`[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) enabled, you can control Service traffic
51
+
If your cluster has the `ServiceTopology`[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
52
+
enabled, you can control Service traffic
55
53
routing by specifying the `topologyKeys` field on the Service spec. This field
56
54
is a preference-order list of Node labels which will be used to sort endpoints
57
55
when accessing this Service. Traffic will be directed to a Node whose value for
@@ -83,8 +81,6 @@ traffic as follows.
83
81
none are available within this zone:
84
82
`["topology.kubernetes.io/zone", "*"]`.
85
83
86
-
87
-
88
84
## Constraints
89
85
90
86
* Service topology is not compatible with `externalTrafficPolicy=Local`, and
@@ -101,7 +97,6 @@ traffic as follows.
101
97
* The catch-all value, `"*"`, must be the last value in the topology keys, if
102
98
it is used.
103
99
104
-
105
100
## Examples
106
101
107
102
The following are common examples of using the Service Topology feature.
@@ -147,12 +142,10 @@ spec:
147
142
- "*"
148
143
```
149
144
150
-
151
145
### Only Zonal or Regional Endpoints
152
146
153
147
A Service that prefers zonal then regional endpoints. If no endpoints exist in either, traffic is dropped.
0 commit comments